Stripe
Stripe.com offers 2 different APIs for payments :
Charge
In our code base we have implemented both APIs. The preferred is the payment intent API.
As of September 2019, a regulation called Strong Customer Authentication (SCA) requires businesses in Europe to request additional authentication for online payments. Businesses in Europe must start building their Stripe integrations with the Payment Intents and Payment Methods APIs instead of the Sources API to be ready for these rule changes.
Usage guide
Complete a basic payment for a basic order
Make a product (when no product exist in your environment)
POST /productsCreate an order linked to a payment intent
POST /stripe/paymentIntentswith in the body the property productId with the value from the product of step 1In the response body from the request, in step 2, will be the property
stripeClientSecretstore its value as well as theorderIdMake sure you can handle the payment method details on your frontend
Use the "stripeClientSecret" (from step 3) in the stripe.confirmCardPayment method to complete the payment on the stripe.com service
Poll the order page with the id (from step 3)
GET /orders?id=...until the response contains the propertystatuswith valuetask_started(if it never changes totask_started, contact the Extra Horizon team)You have now successfully completed a payment for an order
Payment in a currency different from the default (EUR)
Make a product
POST /productswith the body containing"prices": { "eur": { "amount": 1000 }, "usd": { "amount": 1500 } }Create an order linked to a payment intent
POST /stripe/paymentIntentswith the body containing"productId": ...(from step1), "currency": "usd"Follow step 3, 4, 5 and 6 from "Complete a basic payment for a basic order"
You have now successfully completed a payment with a currency different from the default (EUR)
Payment method type different from the default (card)
In this service we have implemented 4 different payment method types from the stripe.com api: The default payment method type is card (visa, mastercard, ...). The other 3 supported types are: bancontact, giropay and ideal.
Follow step 1 from "Complete a basic payment for a basic order"
Create an order linked to a payment intent
POST /stripe/paymentIntentswith the body containing"productId": ...(from step1), "paymentMethodType": "bancontact"Follow step 3 and 4 from "Complete a basic payment for a basic order"
Use the "stripeClientSecret" (from step 3) in the stripe.confirmBancontactPayment method to complete the payment on the stripe.com service
Follow step 6 from "Complete a basic payment for a basic order"
You have now successfully completed a payment with a different payment method type (bancontact) than the default (card)
You can repeat the process above but instead of specifying bancontact as the paymentMethodType (in step 2) specify giropay or ideal. You'll need to use the respective confirm...Payment method in step 4.
See stripe.com documentation for more information about the confirm..Payment method: bancontact giropay ideal
Recurring payments
First create a payment intent with the setupPaymentMethodReuse option set to offSession:
POST /stripe/paymentIntent
{
"productId": "5ce26e7a2b9e674d0c7fd3d6",
"setupPaymentMethodReuse": "offSession"
}Use the returned stripeClientSecret to complete the payment with Stripe.
Then the payment_method returned by Stripe can be submitted reuse it later on:
POST /stripe/users/5d3f321b59080100065b2ee7/paymentMethods
{
"stripeId": "pm_1FPngmI6N8mPcPA74shsTsmP"
}Now that the payment method is saved it can be used for future payments.
The saved payment method can be specified during the creation of a payment intent. Adding the paymentMethodId and offSession: true to the request make the API try to automatically complete the payment intent:
POST /stripe/paymentIntent
{
"productId": "5ce26e7a2b9e674d0c7fd3d6",
"paymentMethodId": "5d961cd8adf66e0402c188ca",
"offSession": true
}Setup payment details without initial payment
First create a setup intent with the setupPaymentMethodReuse option set to offSession:
POST /stripe/setupIntents
{
"setupPaymentMethodReuse": "offSession"
}Use the returned stripeClientSecret to complete the setup with Stripe using the confirmCardSetup method in stripe.js.
Last updated