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


PHP PaymentExecution::setPayer_id方法代码示例

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


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

示例1: executePayment

 public function executePayment($orderid, $userid)
 {
     $result = array("status" => true, "message" => "");
     if ($orderid > 0) {
         $orderid = (int) $orderid;
         $paypalCredentials = $this->getPaypalCredentials();
         $apiContext = new ApiContext(new OAuthTokenCredential($paypalCredentials["clientid"], $paypalCredentials["secret"]));
         $apiContext->setConfig($this->paypalConfig);
         $paypal_paymentinfo = $this->getOrderPaypalInfo($orderid);
         if (strlen($paypal_paymentinfo["paypal_paymentid"]) > 0 && strlen($paypal_paymentinfo["paypal_payerid"]) > 0) {
             try {
                 $payment = Payment::get($paypal_paymentinfo["paypal_paymentid"], $apiContext);
                 $execution = new PaymentExecution();
                 $execution->setPayer_id($paypal_paymentinfo["paypal_payerid"]);
                 $payment_result = $payment->execute($execution, $apiContext);
                 //Save payment info
                 if ($this->saveExecutedPayment($payment_result, $orderid, $userid)) {
                     $result["status"] = true;
                     $result["message"] = "Payment processed successfully";
                     //Notify the customer and notification list that payment for the order has been approved
                     $this->setNotificationOrderPaid($orderid, $userid);
                 } else {
                     $result["status"] = false;
                     $result["message"] = "There was an error saving payment information";
                 }
                 return $result;
             } catch (PayPal\Exception\PPConnectionException $ex) {
                 $result["status"] = false;
                 $result["message"] = "There was an error processing the payment.";
                 $this->log->addError($ex->getMessage() . LOG_LINESEPARATOR . "TRACE: " . $ex->getTraceAsString() . LOG_LINESEPARATOR);
                 return $result;
             }
         } else {
             $result["status"] = false;
             $result["message"] = "Invalid payment id.";
             $params = "orderid = {$orderid} - paymend_id = " . $paypal_paymentinfo["paypal_paymentid"] . " - payer_id = " . $paypal_paymentinfo["paypal_payerid"];
             $this->log->addError("executePayment " . $result["message"] . " {$params} " . LOG_LINESEPARATOR);
             return $result;
         }
     } else {
         $result["status"] = false;
         $result["message"] = "Invalid order id.";
         return $result;
     }
 }
开发者ID:wangshipeng,项目名称:license_manager,代码行数:45,代码来源:payments.php

示例2: PaymentExecution

// a payment that has been approved by
// the buyer by logging into paypal site.
// You can optionally update transaction
// information by passing in one or more transactions.
// API used: POST '/v1/payments/payment/<payment-id>/execute'.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\ExecutePayment;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
session_start();
if (isset($_GET['success']) && $_GET['success'] == 'true') {
    // Get the payment Object by passing paymentId
    // payment id was previously stored in session in
    // CreatePaymentUsingPayPal.php
    $paymentId = $_SESSION['paymentId'];
    $payment = Payment::get($paymentId, $apiContext);
    // PaymentExecution object includes information necessary
    // to execute a PayPal account payment.
    // The payer_id is added to the request query parameters
    // when the user is redirected from paypal back to your site
    $execution = new PaymentExecution();
    $execution->setPayer_id($_GET['PayerID']);
    //Execute the payment
    // (See bootstrap.php for more on `ApiContext`)
    $payment->execute($execution, $apiContext);
    echo "<html><body><pre>";
    var_dump($payment->toArray());
    echo "</pre><a href='../index.html'>Back</a></body></html>";
} else {
    echo "User cancelled payment.";
}
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:31,代码来源:ExecutePayment.php


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