Process a refund in the payment gateway.
| Available in: Salesforce Spring ’20 and later |
| Available in: API 48.0 and later |
-
Get the referenced refund request object from the PaymentGatewayContext Class.
commercepayments.ReferencedRefundRequest = (commercepayments.ReferencedRefundRequest)gatewayContext.getPaymentRequest();
-
Set the HTTP request object.
HttpRequest req = new HttpRequest(); req.setHeader('Content-Type', 'application/json');
- Read the parameters from the ReferencedRefundRequest object and prepare the HTTP request body.
-
Make the HTTP call to the gateway using thePaymentsHttp Class.
commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp(); HttpResponse res = http.send(req); -
Parse the httpResponse and prepare the ReferencedRefundResponse object.
commercepayments.ReferencedRefundResponse referencedRefundResponse = new commercepayments.ReferencedRefundResponse(); referencedRefundResponse.setGatewayResultCode(“”); referencedRefundResponse.setGatewayResultCodeDescription(“”); referencedRefundResponse.setGatewayReferenceNumber(“”); referencedRefundResponse.setSalesforceResultCodeInfo(getSalesforceResultCodeInfo(commercepayments.SalesforceResultCode.SUCCESS.name())); referencedRefundResponse.setGatewayReferenceDetails(“”); referencedRefundResponse.setAmount(double.valueOf(100); - Return the referencedRefundResponse.