当前位置: 首页>>代码示例>>PHP>>正文


PHP PayPalAPIInterfaceServiceService::RefundTransaction方法代码示例

本文整理汇总了PHP中PayPalAPIInterfaceServiceService::RefundTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPalAPIInterfaceServiceService::RefundTransaction方法的具体用法?PHP PayPalAPIInterfaceServiceService::RefundTransaction怎么用?PHP PayPalAPIInterfaceServiceService::RefundTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPalAPIInterfaceServiceService的用法示例。


在下文中一共展示了PayPalAPIInterfaceServiceService::RefundTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: refund

 public function refund()
 {
     $logger = new PPLoggingManager('RefundTransaction');
     // ## RefundTransactionReq
     $refundTransactionReq = new RefundTransactionReq();
     $refundTransactionRequest = new RefundTransactionRequestType();
     // Either the `transaction ID` or the `payer ID` must be specified.
     // PayerID is unique encrypted merchant identification number
     // For setting `payerId`,
     // `refundTransactionRequest.setPayerID("A9BVYX8XCR9ZQ");`
     // Unique identifier of the transaction to be refunded.
     $refundTransactionRequest->TransactionID = "1GF88795WC5643301";
     // Type of refund you are making. It is one of the following values:
     //
     // * `Full` - Full refund (default).
     // * `Partial` - Partial refund.
     // * `ExternalDispute` - External dispute. (Value available since
     // version
     // 82.0)
     // * `Other` - Other type of refund. (Value available since version
     // 82.0)
     $refundTransactionRequest->RefundType = "Partial";
     // `Refund amount`, which contains
     //
     // * `Currency Code`
     // * `Amount`
     // The amount is required if RefundType is Partial.
     // `Note:
     // If RefundType is Full, do not set the amount.`
     $amount = new BasicAmountType("USD", "1.00");
     $refundTransactionRequest->Amount = $amount;
     $refundTransactionReq->RefundTransactionRequest = $refundTransactionRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->RefundTransaction($refundTransactionReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Unique transaction ID of the refund.
         $logger->log("Refund Transaction ID" . $response->RefundTransactionID);
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
开发者ID:andrewwakeling,项目名称:codesamples-php,代码行数:56,代码来源:RefundTransaction.php

示例2: PPLoggingManager

 */
$logger = new PPLoggingManager('RefundTransaction');
$refundReqest = new RefundTransactionRequestType();
if ($_REQUEST['amt'] != "" && strtoupper($_POST['refundType']) != "FULL") {
    $refundReqest->Amount = new BasicAmountType($_REQUEST['currencyID'], $_REQUEST['amt']);
}
$refundReqest->RefundType = $_REQUEST['refundType'];
$refundReqest->TransactionID = $_REQUEST['transID'];
$refundReqest->RefundSource = $_REQUEST['refundSource'];
$refundReqest->Memo = $_REQUEST['memo'];
$refundReqest->RetryUntil = $_REQUEST['retryUntil'];
$refundReq = new RefundTransactionReq();
$refundReq->RefundTransactionRequest = $refundReqest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
    /* wrap API method calls on the service object with a try catch */
    $refundResponse = $paypalService->RefundTransaction($refundReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($refundResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$refundResponse->Ack}</div> </td></tr>";
    //echo "<tr><td>RefundStatus :</td><td><div id='RefundStatus'>$refundResponse->RefundInfo->RefundStatus</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($refundResponse);
    echo "</pre>";
}
require_once '../Response.php';
开发者ID:rrehbeindoi,项目名称:merchant-sdk-php,代码行数:31,代码来源:Refund.php

示例3: refund

 public function refund($transactionId, $refundAmount = NULL)
 {
     $logger = new PPLoggingManager('GetTransactionDetails');
     //load transaction
     try {
         $transaction = $this->getTxnDetails($transactionId);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     if ($transaction->Ack == "Success") {
         $transactionCurrencyType = $transaction->PaymentTransactionDetails->PaymentInfo->GrossAmount->currencyID;
         $transactionAmount = $transaction->PaymentTransactionDetails->PaymentInfo->GrossAmount->value;
         $transactionStatus = $transaction->PaymentTransactionDetails->PaymentInfo->PaymentStatus;
     } else {
         $logger->error("Error retrieving txn : " + $transaction->Errors[0]->LongMessage);
         return FALSE;
     }
     //check status - only 'Completed' or 'Partially-Refunded' should
     //be attempted
     //For 'Partially-Refunded' status, there is no known way to get
     //the remaining amount, so we need to rely on the api to tell us
     //if the refundAmount is too much.
     if ($transactionStatus != "Completed" && $transactionStatus != "Partially-Refunded") {
         $logger->error("Cannot refund this transaction.");
         return FALSE;
     }
     //verify amt, determine if refund type
     if ($refundAmount === NULL) {
         $refundAmount = $transactionAmount;
         $refundType = 'Full';
     } else {
         if ($refundAmount == $transactionAmount) {
             //still full refund
             $refundType = 'Full';
         } else {
             if ($refundAmount < $transactionAmount) {
                 //partial refund
                 $refundType = 'Partial';
             } else {
                 //error
                 $logger->error("Invalid refund amount");
                 return FALSE;
             }
         }
     }
     //do refund
     $refundTransactionReq = new RefundTransactionReq();
     $refundTransactionRequest = new RefundTransactionRequestType();
     $refundTransactionRequest->TransactionID = $transactionId;
     // Type of refund you are making. It is one of the following values:
     //
     // * `Full` - Full refund (default).
     // * `Partial` - Partial refund.
     // * `ExternalDispute` - External dispute. (Value available since
     // version
     // 82.0)
     // * `Other` - Other type of refund. (Value available since version
     // 82.0)
     $refundTransactionRequest->RefundType = $refundType;
     $amount = new BasicAmountType($transactionCurrencyType, $refundAmount);
     $refundTransactionRequest->Amount = $amount;
     $refundTransactionReq->RefundTransactionRequest = $refundTransactionRequest;
     $service = new PayPalAPIInterfaceServiceService();
     try {
         $response = $service->RefundTransaction($refundTransactionReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     if ($response->Ack == "Success") {
         return $response;
     } else {
         $logger->error("Error Message : " + $response->Errors[0]->LongMessage);
         return FALSE;
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:75,代码来源:PaypalComponent.php


注:本文中的PayPalAPIInterfaceServiceService::RefundTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。