Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-4559

Stripe Payments: Transaction statuses not updated for errors

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.4.0-b1
    • Component/s: None
    • Labels:
      None

      Description

      To reproduce:

      • Visit the client payment page
      • Start a payment
      • Use the test number "4000008400001629"
      • Continue to payment confirmation
      • Submit the payment
      • See error "Your card was declined"
      • Then view the new transaction in the widget, see that it is in the pending tab instead of the declined tab

        Activity

        Hide
        jonathan Jonathan Reissmueller added a comment - - edited

        One thing we can consider is changing StripePayments::captureStoredCc:

                $payment_intent = $this->handleApiRequest(
                    ['Stripe\PaymentIntent', 'retrieve'],
                    [$transaction_reference_id],
                    $this->base_url . 'payment_intents - retrieve'
                );
        

        To

                $payment_intent = $this->handleApiRequest(
                    ['Stripe\PaymentIntent', 'retrieve'],
                    [$transaction_reference_id],
                    $this->base_url . 'payment_intents - retrieve'
                );
                
                if (!empty($payment_intent->charges->data[0]->failure_code)) {
                    return [
                        'status' => in_array(
                                $payment_intent->charges->data[0]->failure_code,
                                ['card_declined', 'bank_account_declined']
                            )
                            ? 'declined'
                            : 'error',
                        'reference_id' => (isset($payment_intent->id) ? $payment_intent->id : null),
                        'transaction_id' => (isset($payment_intent->charges->data[0]->id) ? $payment_intent->charges->data[0]->id : null),
                        'message' => $payment_intent->charges->data[0]->failure_message
                    ];
                }
        

        And views/default/cc_form.pdt

                        if (result.error) {
                            var errorElement = document.getElementById('stripe-error-box');
                            errorElement.textContent = result.error.message;
                            $(this).blestaEnableFormSubmission($('#stripe-error-box').closest('form'));
                        } else {
                            // Resubmit the form, bypassing this handler
                            resubmitPaymentConfirmation();
                        }
        

        To

                            // Resubmit the form, bypassing this handler
                            resubmitPaymentConfirmation();
        

        This would resolve the proposed situation, but might not be ideal in every circumstance.

        Show
        jonathan Jonathan Reissmueller added a comment - - edited One thing we can consider is changing StripePayments::captureStoredCc: $payment_intent = $ this ->handleApiRequest( ['Stripe\PaymentIntent', 'retrieve'], [$transaction_reference_id], $ this ->base_url . 'payment_intents - retrieve' ); To $payment_intent = $ this ->handleApiRequest( ['Stripe\PaymentIntent', 'retrieve'], [$transaction_reference_id], $ this ->base_url . 'payment_intents - retrieve' ); if (!empty($payment_intent->charges->data[0]->failure_code)) { return [ 'status' => in_array( $payment_intent->charges->data[0]->failure_code, ['card_declined', 'bank_account_declined'] ) ? 'declined' : 'error', 'reference_id' => (isset($payment_intent->id) ? $payment_intent->id : null ), 'transaction_id' => (isset($payment_intent->charges->data[0]->id) ? $payment_intent->charges->data[0]->id : null ), 'message' => $payment_intent->charges->data[0]->failure_message ]; } And views/default/cc_form.pdt if (result.error) { var errorElement = document.getElementById('stripe-error-box'); errorElement.textContent = result.error.message; $( this ).blestaEnableFormSubmission($('#stripe-error-box').closest('form')); } else { // Resubmit the form, bypassing this handler resubmitPaymentConfirmation(); } To // Resubmit the form, bypassing this handler resubmitPaymentConfirmation(); This would resolve the proposed situation, but might not be ideal in every circumstance.
        Hide
        jonathan Jonathan Reissmueller added a comment -

        A better, more involved option is to set up a callback endpoint for merchant gateways to which stripe could send ipn notifications and update transactions

        Show
        jonathan Jonathan Reissmueller added a comment - A better, more involved option is to set up a callback endpoint for merchant gateways to which stripe could send ipn notifications and update transactions

          People

          • Assignee:
            abdy Abdy Franco
            Reporter:
            jonathan Jonathan Reissmueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              13/Apr/22

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 day, 3 hours, 58 minutes
              1d 3h 58m

                Agile