Refund Invoice
- 04 Apr 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Refund Invoice
- Updated on 04 Apr 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Use the Refund Invoice Web Service to refund a created invoice, successfully paid using the SmartLink interface.
Syntax
POST rest/InvoicesService/refundInvoice
Service Specifications
Property and Information |
|
Input Parameters
Parameter | Description |
merchantID required | An alphanumeric value that represents the Merchant ID. The Payment Gateway operation team provides this value based on the merchant enrollment.
|
authenticationToken required | An alphanumeric value that represents the Authentication Token. The Payment Gateway operation team provides this value based on the merchant enrollment.
|
invoiceID required | An alphanumeric value that represents the Invoice Id that is unique per invoice.
|
refundAmount optional | The numeric value represents the amount to be refunded. If not provided, then a full refund will be performed.
|
Sample Request
Refund Invoice service request contains the details of the invoice desired to be refunded.
It is a JSON format that contains the following details:
- merchantID
- authenticationToken
- invoiceID
- refundAmount
Invoice = { "authenticationToken" : "N2FiZDRmYTQzNDUzOGM0YTI4N2I5YmZm", "merchantID" : "testMercahnt", "invoiceID" : "56534333", "refundAmount" : "1000" }
Output Parameters
Parameter | Description |
authenticationToken required | An alphanumeric value that represents the Authentication Token. The Payment Gateway operation team provides this value based on the merchant enrollment.
|
invoiceID required | An alphanumeric value that represents the Invoice ID. The invoice ID is a unique value for each invoice. The value is the same as the Invoice ID sent in the request.
|
amount required | A numeric value that represents the refunded amount.
|
currency required | The currency of the refunded amount. A numeric ISO Code for the currency. For example, 840 for the US Dollar.
|
invoiceStatus required | An alphanumeric value that represents the Invoice Status. The expected invoice status could be: REFUNDED SUCCESSFULLY or PENDING REFUND APPROVAL.
|
rrn required | The Reference Retrieval Number of the refund.
|
Sample Response
Refund Invoice service returns the response in JSON format.
The returned response contains the following details:
{ "currency" : "840", "amount" : "2000", "invoiceID" : "39291144", "rrn" : "130908878366598", "invoiceStatus" : "REFUNDED SUCCESSFULLY" "authenticationToken" : "N2FiZDRmYTQzNDUzOGM0YTI4N2I5YmZm" }
Sample Code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection; . . .
// Prepare the invoice String authenticationToken="N2FiZDRmYTQzNDUzOGM0YTI4N2I5YmZm";
String merchantId="testMerchant";
// Create Invoice Object and putting merhantID,authenticationToken,invoiceID in it
JSONObject invoice = new JSONObject(); invoice.put("invoicID","1431540Inv"); invoice.put("authenticationToken",authenticationToken); invoice.put("merchantID",merchantId);
// Now we have the Parameter Ready we need to send ther request StringBuilder querySB= new StringBuilder("invoice=").append(invoice.toString());
URL url = new URL("http://SMARTLINK_DOMAIN/URL2PayAdminWeb/rest/InvoicesService/refundInvoice");
URLConnection conn = url.openConnection(); conn.setConnectTimeout(200000);
conn.setReadTimeout(200000);
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
// Write parameters writer.write(querySB.toString());
writer.flush();
// Get the response StringBuffer output = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line; while ((line = reader.readLine()) != null) { output.append(line); }
writer.close();
reader.close();
//Output the response System.out.println("response"+output.toString());