Create 3D Secure Transaction
2 min
Note: This is currently only supported for the Stripe payment processor.
To create a Transaction in the Payment processor with 3DS secure authentication, please follow the below process:
- Call the "ChargeProcessor" action as you normally would. See here. This is the normal flow for any charge.
- If the related Payment method has 3D secure authentication enabled, the response will return an authenitcation_url.
- { "authentication_url" : "https://hooks.stripe.com/...", }
- The authentication_url is a link to a form that will do the 3D Secure authorization. This needs to be loaded in an iFrame hosted by you.
- After the 3DS authentication, Stripe will redirect to Breadwinner to process the success or failure of the authentication.
- After the completion of additional authentication, Breadwinner will post the payment_intent_id to your top-level page (the one hosting the iFrame)
- window.parent.postMessage({message: '3DS-authentication-complete', params: {payment_intent: payment_intent_id}, '*');
- You must extract payment_intent from postMessage and then retrieve the transaction with the "fetchTransaction" Global API action (example below). This will create the charge in Salesforce if successful or return a 402 error if the authentication fails.
Example of "ChargeProcessor" Global API action request and response for a 3DS credit card.
{
Action=ChargeProcessor,
Version=1.0,
responseJSON={
"authentication_url" : "https://hooks.stripe.com/..."
},
statusCode=200,
timestamp=1711117871901,
validRequest=true
}Example of "FetchTransaction" Global API action request and response for authentication success and failure.
Map<String, Object> chargeData = new Map<String, Object>();
chargeData.put('paymentIntentId', 'paymentIntentId');
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('transaction', new List<Object>{chargeData});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version','1.0');
reqObj.put('action','FetchTransaction');
reqObj.put('processorId', 'processorId');
reqObj.put('requestJSON',reqJSON);
// Placing a request to Breadwinner Global API
Map<String,Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
System.debug(resp);