function _generatePaymentResponse in Ubercart Stripe 7.3
Used to return the appropriate response after checking Stripe Payment Intent status
Parameters
Object $intent:
Return value
string response
1 call to _generatePaymentResponse()
- _uc_stripe_confirm_payment in ./
uc_stripe.module - Ajax page callback for callback uc_stripe/ajax/confirm_payment page This is used to send payment and intent status back to JS client
File
- ./
uc_stripe.module, line 1020 - A stripe.js PCI-compliant payment gateway Forked from Bitcookie's work (thanks!) which was posted at http://bitcookie.com/blog/pci-compliant-ubercart-and-stripe-js from discussion in the uc_stripe issue queue, https://www.drupal.org/node/1467886
Code
function _generatePaymentResponse($intent) {
if ($intent->status == 'requires_action' && $intent->next_action->type == 'use_stripe_sdk') {
# Tell the client to handle the action
$response = [
'requires_action' => true,
'payment_intent_client_secret' => $intent->client_secret,
];
}
else {
if ($intent->status == 'succeeded') {
# The payment didn’t need any additional actions and completed!
# Handle post-payment fulfillment
$response = [
'success' => true,
];
}
else {
# Invalid status
http_response_code(500);
$response = [
'error' => 'Invalid PaymentIntent status',
];
}
}
return $response;
}