function payment_commerce_payment_status_change in Payment for Drupal Commerce 7
Same name and namespace in other branches
- 7.2 payment_commerce.module \payment_commerce_payment_status_change()
Implements hook_payment_status_change().
File
- ./
payment_commerce.module, line 94 - Hook implementations and shared functions.
Code
function payment_commerce_payment_status_change(Payment $payment, PaymentStatusItem $previous_status_item) {
if ($payment->context == 'payment_commerce') {
$transaction_id = payment_commerce_transaction_id_load($payment->pid);
if ($transaction_id) {
$transaction = commerce_payment_transaction_load($transaction_id);
if ($transaction) {
// Update the Commerce Payment transaction.
payment_commerce_transaction_fill($transaction, $payment);
commerce_payment_transaction_save($transaction);
// A status change from new to pending is caused by Payment and as it
// is built-in we should not respond to it.
if (!(payment_status_is_or_has_ancestor($previous_status_item->status, PAYMENT_STATUS_NEW) && payment_status_is_or_has_ancestor($payment
->getStatus()->status, PAYMENT_STATUS_PENDING))) {
payment_commerce_redirect_pane($payment);
}
}
}
}
}