Problem with SCA-enabled cards

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #20588
    Karl Erik Hofseth
    Participant

    There seems to be a problem in the payment handling code.

    Specifically, when I make a payment in test mode with a Stripe test card that requires SCA, the page starts the request, and then nothing happens.

    Digging a little, I found that the first request from the browser to the stripe API returns 200 OK with all the correct data. Then a second request to /wp-admin/admin-ajax.php?action=payment_intents returns 500 with error “invalid paymentIntents status”.

    Going over to my stripe dashboard, I find that a request from my webserver was made to create a payment intent, which returned 200 OK, and in the paymentIntents object the “status” attribute was set to “requires_action”. My guess is that the plugin doesn’t know what to do woth this value and just throws a 500 instead.

    #20605
    Support Team
    Keymaster

    Hello @karlerikhofseth,

    The issue may have raised due to the lower PHP version so make sure you have the latest PHP version. Also, our plugin strip recommends PHP versions 7 and above.

    Also, please refer to below-given screenshot and if you can, replace the bracket with the array and see if that work or not.

    https://prnt.sc/pjvkrh

    Hope this helps.

    Thank you.

    #20615
    Karl Erik Hofseth
    Participant

    So I’ve updated the server from PHP 7.2 to 7.3, no effect.

    Replaced the square braces with array() also to no effect.

    I looked into the error code, and I can’t find it in Stripe’s docs, confirming my suspicion that Stripe isn’t generating these errors. Currently looking at the plugin code to see if I can make sense of it.

    #20616
    Karl Erik Hofseth
    Participant

    Ok, so a quick scan of the code later lands me in

    function wp_travel_generate_payment_response( $intent ) {
    	if ( 'requires_source_action' === $intent->status &&
    	'use_stripe_sdk' === $intent->next_action->type ) {
    		// Tell the client to handle the action.
    		echo wp_json_encode(
    			array(
    				'id'                           => $intent->id,
    				'requires_action'              => true,
    				'payment_intent_client_secret' => $intent->client_secret,
    			)
    		);
    	} elseif ( 'succeeded' === $intent->status ) {
    		// The payment didn’t need any additional actions and completed!
    		// Handle post-payment fulfillment.
    		echo wp_json_encode(
    			array(
    				'id'                           => $intent->id,
    				'success'                      => true,
    				'payment_intent_client_secret' => $intent->client_secret,
    			)
    		);
    	} else {
    		// Invalid status.
    		http_response_code( 500 );
    		echo wp_json_encode( array( 'error' => 'Invalid PaymentIntent status' ) );
    	}
    	die;
    }

    It seems to be looking out for the status “requires_source_action”, but the API is returning an object with status “requires_action” as well as next_action->type = “use_stripe_sdk”. Thus the code skips to the else block and throws a 500 error.

    Digging in the Stripe docs reveals a name change in API version 2019-02-11 “requires_source_action is now requires_action”, so a simple rename in the code above should fix it. I’ll test and report back.

    #20617
    Karl Erik Hofseth
    Participant

    Tested and succeeded. Don’t know how you want to handle this with presumably customers on both sides of the API update, but there’s the fix.

    #20618
    wensolutions
    Keymaster

    Hello @karlerikhofseth,

    Thank you for reporting it and glad that you found the workaround.

    We will work on the issue on our side and release the update soon.

    Thank you very much for the co-operation.

    Regards!!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘WP Travel Stripe Checkout’ is closed to new topics and replies.