Afterpay is a buy now - pay later solution.
To use AfterPay for Stripe, setup the stripe merchant to accept the Afterpay payment method.
Using the API:
Supported for one-time sales only
The API will return an error if there is a recurring offer.
Step 1 - Create and process the order on Sublytics
Run the doAdd
and doProcess
, or doAddProcess
endpoint in to create the order. And we will create the payment intent on stripe.
In doProcess or doAddProcess, need to pass the payment method id of 11 (Afterpay) and the redirect_url
defining where to redirect the customer after they approve the transaction.
Request for doProcess or doAddProcess
1{
2 "payment_method_id":"11", // for afterpay
3 "redirect_url":"https://test.com"
4}
Step 2 - Redirect the customer to the Afterpay page
The response from the previous call contains the url where you need to redirect the customer to in order to finalize the transaction in the post_data
attribute.
Response from doProcess or doAddProcess
1{
2 "post_data": "https://hooks.stripe.com/afterpay_clearpay/acct_1CE2WICwGoLKL4Li/pa_nonce_KBYd3nMkQAhlS1GxY6anE1ja8aUjjUq/redirect"
3}
Once completed by the customer, they will be redirected to the redirect_url you passed in the initial request, in all cases (approve and cancel).
Step 3 - Finalize the order by requesting order/doProcessAfterpay
Finally you need to call order/doProcessAfterpay
to finalize the process in sublytics.
Request for doProcessAfterpay
1{
2 "order_id": "122664", // (sublytics order id)
3 "transaction_token": "pi_3JXBWBCwGoCXM4Lt0iHURTEb" // payment intent id
4}
You get transaction_token in either the response from the previous call in the gateway_response_gateway_id
attribute, or as query parameter payment_intent
in the redirect url.