I just go through lots of the posts related this topic but can't found the solution. I just want to refund my partial amount to buyer. Like if buyer paid $50 for service and now want to refund, then buyer will get back with 2% deduction.
Bellow code is working fine with full amount refund, but I want partial amount.
Here is my code:
/* Refund API*/
$refundRequest = new RefundRequest(new RequestEnvelope("en_US"));
//The receiver's email address, where n is between 0 and 5 for a maximum of 6 receivers
if(isset($_POST['receiverEmail'])) {
$receiver = array();
for($i=0; $i<count($_POST['receiverEmail']); $i++) {
$receiver[$i] = new Receiver();
$receiver[$i]->email = $_POST['receiverEmail'][$i];
$receiver[$i]->amount = $_POST['receiverAmount'][$i];
$receiver[$i]->primary = $_POST['primaryReceiver'][$i];
if($_POST['invoiceId'][$i] != "") {
$receiver[$i]->invoiceId = $_POST['invoiceId'][$i];
}
if($_POST['paymentType'][$i] != "" && $_POST['paymentType'][$i] != DEFAULT_SELECT) {
$receiver[$i]->paymentType = $_POST['paymentType'][$i];
}
if($_POST['paymentSubType'][$i] != "") {
$receiver[$i]->paymentSubType = $_POST['paymentSubType'][$i];
}
if($_POST['phoneCountry'][$i] != "" && $_POST['phoneNumber'][$i]) {
$receiver[$i]->phone = new PhoneNumberType($_POST['phoneCountry'][$i], $_POST['phoneNumber'][$i]);
if($_POST['phoneExtn'][$i] != "") {
$receiver[$i]->phone->extension = $_POST['phoneExtn'][$i];
}
}
}
$receiverList = new ReceiverList($receiver);
}
if($_POST['currencyCode'] != "") {
$refundRequest->currencyCode = $_POST["currencyCode"];
}
if($_POST['payKey'] != "") {
$refundRequest->payKey = $_POST["payKey"];
}
if($_POST['transactionId'] != "") {
$refundRequest->transactionId = $_POST["transactionId"];
}
if($_POST['trackingId'] != "") {
$refundRequest->trackingId = $_POST["trackingId"];
}
//Creating service wrapper object
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
/* wrap API method calls on the service object with a try catch */
$response = $service->Refund($refundRequest);
} catch(Exception $ex) {
require_once 'Common/Error.php';
exit;
}
$ack = strtoupper($response->responseEnvelope->ack);
if($ack != "SUCCESS"){
echo 'error:';
} else {
$status = $response->refundInfoList->refundInfo[0]->refundStatus;
print_r($response);
}
Can anyone let me know what's wrong in this code?
Thanks