function stripe_payment_payment_update in Stripe 7
Implements hook_ENTITY_TYPE_ACTION().
1 call to stripe_payment_payment_update()
- stripe_payment_payment_insert in stripe_payment/
stripe_payment.module - Implements hook_ENTITY_TYPE_ACTION().
File
- stripe_payment/
stripe_payment.module, line 328 - Stripe Payment module.
Code
function stripe_payment_payment_update(Payment $payment) {
if ($payment->method->controller->name === 'StripePaymentMethodController') {
$record = array();
foreach (array(
'charge',
'customer',
'token',
) as $type) {
if (isset($payment->method_data[$type])) {
$record = array(
'type' => $type,
'id' => $payment->method_data[$type],
);
break;
}
}
if ($record) {
// Insert/Update stored data.
db_merge('stripe_payment_data')
->key(array(
'pid' => $payment->pid,
))
->fields($record)
->execute();
}
else {
// Delete stored data (if any).
db_delete('stripe_payment_data')
->condition('pid', $payment->pid)
->execute();
}
}
}