author lvairamani
Load SDK configuration for the resource. This intialization code can be done as Init Servlet.
Sample showing how to refund a sale
A sale transaction. Create a Sale object with the given sale transaction id.
A refund transaction. Use the amount to create a refund object
Create an Amount object to represent the amount to be refunded. Create the refund object, if the refund is partial
Retrieve the access token from OAuthTokenCredential by passing in ClientID and ClientSecret It is not mandatory to generate Access Token on a per call basis. Typically the access token can be generated once and reused within the expiry window
Pass in a ApiContext
object to authenticate
the call and to send a unique request id
(that ensures idempotency). The SDK generates
a request id if you do not pass one explicitly.
Use this variant if you want to pass in a request id
that is meaningful in your application, ideally
a order id.
String requestId = Long.toString(System.nanoTime();
APIContext apiContext = new APIContext(accessToken, requestId ));
Refund by posting to the APIService using a valid AccessToken
SaleRefund Sample
This sample code demonstrate how you can process a refund on a sale transaction created using the Payments API. API used: /v1/payments/sale/{sale-id}/refund