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

        jonathan Jonathan Reissmueller created issue -
        jonathan Jonathan Reissmueller made changes -
        Field Original Value New Value
        Rank Ranked higher
        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
        jonathan Jonathan Reissmueller made changes -
        Fix Version/s 5.4.0-b1 [ 11719 ]
        Fix Version/s Short Term [ 10800 ]
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.4.0 Sprint 1 [ 148 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked lower
        abdy Abdy Franco made changes -
        Assignee Abdy Franco [ abdy ]
        abdy Abdy Franco made changes -
        Remaining Estimate 0 minutes [ 0 ]
        Time Spent 4 hours, 52 minutes [ 17520 ]
        Worklog Id 15471 [ 15471 ]
        abdy Abdy Franco made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        abdy Abdy Franco made changes -
        Status In Progress [ 3 ] In Review [ 5 ]
        Resolution Fixed [ 1 ]
        abdy Abdy Franco made changes -
        Time Spent 4 hours, 52 minutes [ 17520 ] 1 day, 1 hour, 22 minutes [ 33720 ]
        Worklog Id 15472 [ 15472 ]
        abdy Abdy Franco made changes -
        Time Spent 1 day, 1 hour, 22 minutes [ 33720 ] 1 day, 1 hour, 33 minutes [ 34380 ]
        Worklog Id 15528 [ 15528 ]
        abdy Abdy Franco made changes -
        Time Spent 1 day, 1 hour, 33 minutes [ 34380 ] 1 day, 1 hour, 52 minutes [ 35520 ]
        Worklog Id 15536 [ 15536 ]
        abdy Abdy Franco made changes -
        Time Spent 1 day, 1 hour, 52 minutes [ 35520 ] 1 day, 2 hours, 15 minutes [ 36900 ]
        Worklog Id 15537 [ 15537 ]
        abdy Abdy Franco made changes -
        Time Spent 1 day, 2 hours, 15 minutes [ 36900 ] 1 day, 3 hours, 24 minutes [ 41040 ]
        Worklog Id 15553 [ 15553 ]
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.4.0 Sprint 1 [ 148 ] 5.4.0 Sprint 2 [ 149 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked higher
        abdy Abdy Franco made changes -
        Time Spent 1 day, 3 hours, 24 minutes [ 41040 ] 1 day, 3 hours, 43 minutes [ 42180 ]
        Worklog Id 15555 [ 15555 ]
        abdy Abdy Franco made changes -
        Time Spent 1 day, 3 hours, 43 minutes [ 42180 ] 1 day, 3 hours, 58 minutes [ 43080 ]
        Worklog Id 15581 [ 15581 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Review [ 5 ] Closed [ 6 ]

          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