Refund Invoice
  • 04 Apr 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Refund Invoice

  • Dark
    Light
  • PDF

Article summary

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
  • Endpoint: refundInvoice
  • Name: Refund Invoice Service
  • Method: POST
  • Input Parameters: invoice, a JSON formatted object.
  • Parameters Type: Form parameters that need to be set in the body of the HTTP request.
  • Path: rest/InvoicesService/refundInvoice. The path is prefixed with the SmartLink Context root.

Input Parameters

ParameterDescription
merchantID
required
An alphanumeric value that represents the Merchant ID. The Payment Gateway operation team provides this value based on the merchant enrollment. 
  • Field Type: Alphanumeric
  • Length: 40
  • Sample Data: testMerchant
authenticationToken
required
An alphanumeric value that represents the Authentication Token. The Payment Gateway operation team provides this value based on the merchant enrollment. 
  • Field Type: Alphanumeric
  • Length: 255
  • Sample Data: N2FiZDRmYTQzNDUzOGM0YTI4N2I5YmZm
invoiceID
required
An alphanumeric value that represents the Invoice Id that is unique per invoice
  • Field Type: Alphanumeric
  • Length: 60
  • Sample Data: 56534333
refundAmount
optional
The numeric value represents the amount to be refunded. If not provided, then a full refund will be performed.
  • Field Type: numeric
  • Length: 9
  • Sample Data: 22

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

ParameterDescription
authenticationToken
required
An alphanumeric value that represents the Authentication Token. The Payment Gateway operation team provides this value based on the merchant enrollment. 
  • Field Type: Alphanumeric
  • Length: 255
  • Sample Data: N2FiZDRmYTQzNDUzOGM0YTI4N2I5YmZm
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.
  • Field Type: Alphanumeric
  • Length: 60
  • Sample Data: 56534333
amount
required

A numeric value that represents the refunded amount.
  • Field Type: Numeric
  • Length: 9
  • Sample Data: 100
currency
required

The currency of the refunded amount. A numeric ISO Code for the currency.

For example, 840 for the US Dollar.
  • Field Type: Numeric
  • Length: 3
  • Sample Data: 840
invoiceStatus
required

An alphanumeric value that represents the Invoice Status.
The expected invoice status could be: REFUNDED SUCCESSFULLY or PENDING REFUND APPROVAL.
  • Field Type: Alphanumeric
  • Length: 10
  • Sample Data: PAID
rrn
required
The Reference Retrieval Number of the refund.

  • Field Type: Alphanumeric
  • Length: 50
  • Sample Data: 201608161029435230000000000

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());