Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Process Payments
Process a payment in the payment gateway.
| Available in: Salesforce Spring ’20 |
-
Get the payment capture request object from the PaymentGatewayContext Class.
1commercepayments.CaptureRequest = (commercepayments.CaptureRequest)gatewayContext.getPaymentRequest() -
Set the HTTP request object.
1HttpRequest req = new HttpRequest(); 2req.setHeader('Content-Type', 'application/json'); - Read the parameters from the CaptureRequest object and prepare the HTTP request body.
-
Make the HTTP call to the gateway using the PaymentsHttp Class.
1commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp(); 2HttpResponse res = http.send(req); -
Parse the httpResponse and prepare the CaptureResponse object.
1commercepayments.CaptureResponse captureResponse = new commercepayments.CaptureResponse(); 2captureResponse.setGatewayResultCode(“”); captureResponse.setGatewayResultCodeDescription(“”); captureResponse.setGatewayReferenceNumber(“”); 3captureResponse.setSalesforceResultCodeInfo(getSalesforceResultCodeInfo(commercepayments.SalesforceResultCode.SUCCESS.name())); 4captureResponse.setGatewayReferenceDetails(“”); 5captureResponse.setAmount(double.valueOf(100); - Return the captureResponse.