0

I have used ReactJS for frontend and Magento2 for the backend.

I have installed the "Stripe Payments" extension. https://marketplace.magento.com/stripe-stripe-payments.html

How can I place the order using the REST API with 'Stripe Payment Gateway'?

REST API (PUT): https://example.com/index.php/rest/V1/carts/mine/order

{
    "paymentMethod": {
    "method": "stripe_payments",
        "additional_data": {
            "number" : "4111111111111111",
            "exp_month" : "10",
            "exp_year" : "30",
            "cvv" : "123"
        }
    }
}

Result :

{
    "message": "Internal Error. Details are available in Magento log file. Report ID: webapi-5dc02747ba403"
}

Thanks

1

1 Answer 1

1

Support for Magento 2’s REST API has been added in version 1.4.0 of the official Stripe module. Examples on how to use the REST API with the module can be found at:

Notice how a payment method token is passed to the API at https://gist.github.com/snez/fe4d44ec4729b9f7d6870e50fd8e52b2#file-rest-example-php-L234. If you would like to only test the API calls, you can instead use some of the test tokens available at https://stripe.com/docs/testing#cards

However on a live website, this token should be created at the client-side before the API call is made, using Stripe.js as explained at https://stripe.com/docs/js/payment_methods/create_payment_method. For an example of how the Stripe module for Magento does this, you can review the code in app/code/StripeIntegration/Payments/view/frontend/web/js/view/payment/method-renderer/stripe_payments.js

Also note that your app should handle scenarios where 3D Secure authentication is required by the customer before the order is placed. To test an SCA order, you can use card number 4000000000003063.

With an SCA payment, the module will throw an Authentication Required error. When your app receives this error, you will need to trigger a 3DS modal from your app and then resubmit the order using the same payment method ID. On the second submission, the payment will succeed.

To see how the module triggers the 3DS modal in javascript, please refer to the handlePlaceOrderErrors() method inside app/code/StripeIntegration/Payments/view/frontend/web/js/view/payment/method-renderer/stripe_payments.js. From there, you can follow the code into the rest of the module's javascript files to see exactly how the 3DS modal is opened and used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.