Other Operations

Refund Transaction

The Refund method is used for reversing a previous successful transaction and returning the amount (or partial amount) to the customer. This method must be supported by the gateway that processed the transaction. Depending on the gateway / bank API this method can execute partial refunds or just full amount refunds, can be executed several times or only once. Please contact your Intrapay representative for your specific configuration and available options.

To implement this method:

  1. The merchant obtains all the information needed to start the refund procedure from their system;
  2. The merchant initiates a HTTPS POST method to the Intrapay endpoint URL with all the necessary information as url-encoded key-value pairs;
    URL: payment.intrapay.com/transaction/refund
  3. The system will respond to the Merchant with the result of the refund operation;
  4. The Merchant holds information about this operation and if needed shows/notifies the result to the end user.

Refund Transaction Fields

Order (pSign)Field NameDetailsMinMaxTypeRequired
01merchantIDMerchant id supplied by Intrapay18NumberYes
02refundAmountThe amount to be refunded (ex. 1.99)112DecimalYes*
03transactionIDIntrapay transaction ID150StringYes
04pSignThe SHA signature used to secure protocol4040StringYes

* Please note that usually Gateways/Banks do not support partial Refunds. Our technical team will specify if any of these are required/supported.


Example Refund Request:

[POST URL] https://payment.intrapay.com/transaction/refund

[POST PARAMS]

<?php
    	
require_once("classes/Api.php");
    	
$endPointUrl = "https://payment.intrapay.com/transaction/refund";	// api name to be process
$passCode = "PASSCODE_GOES_HERE"; //your pass Code

$postData["merchantID"] = "MERCHANT_ID_GOES_HERE"; //your merchant ID
$postData["refundAmount"] = "3.99";
$postData["transactionID"] = "TRANSACTION_ID_GOES_HERE"; //transaction ID

try {
	$api = new Api();
   
	$data = $api->generatePsign( $passCode, $postData );
   
	echo $api->apiCurlRequest( $data , $endPointUrl);
   
} catch (Exception $e) {
	echo "Caught exception: ",  $e->getMessage(), "\n";
}
   
?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" %>
<%@ page import="java.net.*, java.util.*, com.intrapay.util.*" %>
<%
	String endPointUrl = "https://payment.intrapay.com/transaction/refund";
	String passCode = "PASSCODE_GOES_HERE"; //your pass Code
	String merchantID = "MERCHANT_ID_GOES_HERE"; //your merchant ID
	String refundAmount = "3.99";
	String transactionID = "TRANSACTION_ID_GOES_HERE"; //transaction ID

	String pSign = PSignUtil.generatePSign(passCode + merchantID + refundAmount + transactionID);

	String and = "&";
	StringBuffer requestData = new StringBuffer();

	requestData.append("merchantID=" + merchantID);
	requestData.append(and + "refundAmount=" + refundAmount);
	requestData.append(and + "transactionID=" + transactionID);
	requestData.append(and + "pSign=" + pSign);

	String result = ServerPost.post(requestData.toString(), endPointUrl);
%>
<%=result%>
var request = require('request');
var querystring = require('querystring');

/*
 * 
 * Merchant's Data Variables.
 * 
 */
var postUrl = 'https://payment.intrapay.com/transaction/refund'; //api name to be process
var passCode = 'PASSCODE_GOES_HERE'; //your pass Code
var merchantID = 'MERCHANT_ID_GOES_HERE'; //your merchant ID
var refundAmount = '3.99';
var transactionID = 'TRANSACTION_ID_GOES_HERE'; //transaction ID

/*
*
* Generate pSign
*
*/
var crypto = require('crypto'), shasum = crypto.createHash('sha1');

shasum.update(passCode + merchantID + refundAmount + transactionID);
var pSign = shasum.digest('hex');

/*
*
* Ready HTTP Post with url-encoded data
*
*/

var data = {
		'passCode' : passCode,
		'merchantID' : merchantID,
		'refundAmount' : refundAmount,
		'transactionID' : transactionID,
};

var formData = querystring.stringify(data);
var contentLength = formData.length;
var headers = {
    "Content-Length" : contentLength,
    "Content-Type" : "application/x-www-form-urlencoded",
}

var options = {
    url : postUrl,
    method : "POST",
    headers : headers,
    body : formData,
}

request(options, function(err, res, body) {
    if (res && (res.statusCode === 200 || res.statusCode === 201)) {
        // return result
        console.log(body);
    }
});
require 'time'
require_relative 'classes/API'

api = API.new

postUrl = 'https://payment.intrapay.com/transaction/refund' #api name to be process
passCode = 'PASSCODE_GOES_HERE' #your pass Code
merchantID = 'MERCHANT_ID_GOES_HERE' #your merchant ID
refundAmount = '3.99'
transactionID = 'TRANSACTION_ID_GOES_HERE' //transaction ID

postData = Hash[
	'merchantID' => merchantID,
	'refundAmount' => refundAmount,
	'transactionID' => transactionID
]

postData['pSign'] = api.generatePsign(passCode, postData)

puts api.apiPostRequest(postData, postUrl)
<%@ Page Language="C#" %>
<%@ Import Namespace="Intrapay.Api.Util" %> 
<%
	String endPointUrl = "https://payment.intrapay.com/transaction/refund";
	String passCode = "PASSCODE_GOES_HERE"; //your pass Code
	String merchantID = "MERCHANT_ID_GOES_HERE"; //your merchant ID
	String refundAmount = "3.99";
	String transactionID = "TRANSACTION_ID_GOES_HERE"; //transaction ID

	String pSign = PSignUtil.GeneratePSign(passCode + merchantID + refundAmount + transactionID);
	String and = "&";
	StringBuilder requestData = new StringBuilder();

	requestData.Append("merchantID=" + merchantID);
	requestData.Append(and + "refundAmount=" + refundAmount);
	requestData.Append(and + "transactionID=" + transactionID);
	requestData.Append(and + "pSign=" + pSign);

	String result = ServerPost.Post(requestData.ToString(), endPointUrl);
	Response.Write(result);
%>
from classes.API import API

import time

postUrl = 'https://payment.intrapay.com/transaction/refund' #api name to be process
passCode = 'PASSCODE_GOES_HERE' //your pass Code
merchantID = 'MERCHANT_ID_GOES_HERE' //your merchant ID
refundAmount = '3.99'
transactionID = 'TRANSACTION_ID_GOES_HERE' //transaction ID

postData = {
	'passCode' => passCode,
	'merchantID' => merchantID,
	'refundAmount' => refundAmount,
	'transactionID' => transactionID
}

postData['pSign'] = API.generatePsign(passCode, postData)
print(API.apiPostRequest(postData, postUrl))

You will see the response here...