If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. If an error occured, show the resulting errors */ $refundRequest = new RefundRequest(); $refundRequest->currencyCode = $currencyCode; $refundRequest->payKey = $payKey; $refundRequest->requestEnvelope = new RequestEnvelope(); $refundRequest->requestEnvelope->errorLanguage = "en_US"; $refundRequest->receiverList = new ReceiverList(); $receiver1 = new Receiver(); $receiver1->email = $email; $receiver1->amount = $amount; $refundRequest->receiverList->receiver = $receiver1; $ap = new AdaptivePayments(); $response = $ap->Refund($refundRequest); if (strtoupper($ap->isSuccess) == 'FAILURE') { $_SESSION['FAULTMSG'] = $ap->getLastError(); $location = "APIError.php"; header("Location: {$location}"); } } catch (Exception $ex) { $fault = new FaultMessage(); $errorData = new ErrorData(); $errorData->errorId = $ex->getFile(); $errorData->message = $ex->getMessage(); $fault->error = $errorData; $_SESSION['FAULTMSG'] = $fault; $location = "APIError.php"; header("Location: {$location}"); }
function refund_order() { global $wpdb; if (isset($_POST['btnRefundSubmit'])) { session_start(); try { $currencyCode = $_REQUEST["currencyCode"]; $payKey = $_REQUEST["payKey"]; $email = $_REQUEST["receiveremail"]; $amount = $_REQUEST["amount"]; /* Make the call to PayPal to get the Pay token If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. If an error occured, show the resulting errors */ $refundRequest = new RefundRequest(); $refundRequest->currencyCode = $currencyCode; $refundRequest->payKey = $payKey; $refundRequest->requestEnvelope = new RequestEnvelope(); $refundRequest->requestEnvelope->errorLanguage = "en_US"; $refundRequest->receiverList = new ReceiverList(); $receiver1 = new Receiver(); $receiver1->email = $email; $receiver1->amount = $amount; $refundRequest->receiverList->receiver = $receiver1; $ap = new AdaptivePayments(); $response = $ap->Refund($refundRequest); if (strtoupper($ap->isSuccess) == 'FAILURE') { $_SESSION['FAULTMSG'] = $ap->getLastError(); $location = "APIError.php"; header("Location: {$location}"); } } catch (Exception $ex) { $fault = new FaultMessage(); $errorData = new ErrorData(); $errorData->errorId = $ex->getFile(); $errorData->message = $ex->getMessage(); $fault->error = $errorData; $_SESSION['FAULTMSG'] = $fault; $location = "APIError.php"; //header("Location: $location"); } } //end if $order_pay_info = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ign_pay_info WHERE id = '" . $_GET['orderid'] . "'"); $product_data = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ign_products WHERE product_id = '" . $order_pay_info->product_id . "'"); $paypal_settings = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ign_pay_settings WHERE product_id = '" . $order_pay_info->product_id . "'"); require 'languages/text_variables.php'; echo '<div class="wrap"> ' . admin_menu_html(); include_once 'templates/admin/_orderRefund.php'; echo '</div>'; }
function Refund($token) { $refundRequest = new RefundRequest(); $refundRequest->currencyCode = "USD"; $refundRequest->payKey = $token; $refundRequest->requestEnvelope = new RequestEnvelope(); $refundRequest->requestEnvelope->errorLanguage = "en_US"; $refundRequest->receiverList = new ReceiverList(); $receiver1 = new Receiver(); $receiver1->email = "*****@*****.**"; $receiver1->amount = "1.00"; $refundRequest->receiverList->receiver = $receiver1; $ap = new AdaptivePayments(); $response = $ap->Refund($refundRequest); if (strtoupper($ap->isSuccess) == 'FAILURE') { $FaultMsg = $ap->getLastError(); echo "Transaction Refund Failed: error Id: "; if (is_array($FaultMsg->error)) { echo $FaultMsg->error[0]->errorId . ", error message: " . $FaultMsg->error[0]->message; } else { echo $FaultMsg->error->errorId . ", error message: " . $FaultMsg->error->message; } } else { echo "Refund Transaction Successful! \n"; } }