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


PHP PayPalAPIInterfaceServiceService::DoExpressCheckoutPayment方法代码示例

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


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

示例1: doEC

 public function doEC()
 {
     $logger = new PPLoggingManager('DoExpressCheckout');
     // ## DoExpressCheckoutPaymentReq
     $doExpressCheckoutPaymentReq = new DoExpressCheckoutPaymentReq();
     $doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
     // The timestamped token value that was returned in the
     // `SetExpressCheckout` response and passed in the
     // `GetExpressCheckoutDetails` request.
     $doExpressCheckoutPaymentRequestDetails->Token = "EC-2XW434901C650622T";
     // Unique paypal buyer account identification number as returned in
     // `GetExpressCheckoutDetails` Response
     $doExpressCheckoutPaymentRequestDetails->PayerID = "A9BVYX8XCR9ZQ";
     // ### Payment Information
     // list of information about the payment
     $paymentDetailsList = array();
     // information about the first payment
     $paymentDetails1 = new PaymentDetailsType();
     // Total cost of the transaction to the buyer. If shipping cost and tax
     // charges are known, include them in this value. If not, this value
     // should be the current sub-total of the order.
     //
     // If the transaction includes one or more one-time purchases, this field must be equal to
     // the sum of the purchases. Set this field to 0 if the transaction does
     // not include a one-time purchase such as when you set up a billing
     // agreement for a recurring payment that is not immediately charged.
     // When the field is set to 0, purchase-specific fields are ignored.
     //
     // * `Currency Code` - You must set the currencyID attribute to one of the
     // 3-character currency codes for any of the supported PayPal
     // currencies.
     // * `Amount`
     $orderTotal1 = new BasicAmountType("USD", "2.00");
     $paymentDetails1->OrderTotal = $orderTotal1;
     // How you want to obtain payment. When implementing parallel payments,
     // this field is required and must be set to `Order`. When implementing
     // digital goods, this field is required and must be set to `Sale`. If the
     // transaction does not include a one-time purchase, this field is
     // ignored. It is one of the following values:
     //
     // * `Sale` - This is a final sale for which you are requesting payment
     // (default).
     // * `Authorization` - This payment is a basic authorization subject to
     // settlement with PayPal Authorization and Capture.
     // * `Order` - This payment is an order authorization subject to
     // settlement with PayPal Authorization and Capture.
     // Note:
     // You cannot set this field to Sale in SetExpressCheckout request and
     // then change the value to Authorization or Order in the
     // DoExpressCheckoutPayment request. If you set the field to
     // Authorization or Order in SetExpressCheckout, you may set the field
     // to Sale.
     $paymentDetails1->PaymentAction = "Order";
     // Unique identifier for the merchant. For parallel payments, this field
     // is required and must contain the Payer Id or the email address of the
     // merchant.
     $sellerDetails1 = new SellerDetailsType();
     $sellerDetails1->PayPalAccountID = "jb-us-seller@paypal.com";
     $paymentDetails1->SellerDetails = $sellerDetails1;
     // A unique identifier of the specific payment request, which is
     // required for parallel payments.
     $paymentDetails1->PaymentRequestID = "PaymentRequest1";
     // Your URL for receiving Instant Payment Notification (IPN) about this transaction. If you do not specify this value in the request, the notification URL from your Merchant Profile is used, if one exists.
     $paymentDetails1->NotifyURL = "http://localhost/ipn";
     // information about the second payment
     $paymentDetails2 = new PaymentDetailsType();
     // Total cost of the transaction to the buyer. If shipping cost and tax
     // charges are known, include them in this value. If not, this value
     // should be the current sub-total of the order.
     //
     // If the transaction includes one or more one-time purchases, this field must be equal to
     // the sum of the purchases. Set this field to 0 if the transaction does
     // not include a one-time purchase such as when you set up a billing
     // agreement for a recurring payment that is not immediately charged.
     // When the field is set to 0, purchase-specific fields are ignored.
     //
     // * `Currency Code` - You must set the currencyID attribute to one of the
     // 3-character currency codes for any of the supported PayPal
     // currencies.
     // * `Amount`
     $orderTotal2 = new BasicAmountType("USD", "4.00");
     $paymentDetails2->OrderTotal = $orderTotal2;
     // How you want to obtain payment. When implementing parallel payments,
     // this field is required and must be set to `Order`. When implementing
     // digital goods, this field is required and must be set to `Sale`. If the
     // transaction does not include a one-time purchase, this field is
     // ignored. It is one of the following values:
     //
     // * `Sale` - This is a final sale for which you are requesting payment
     // (default).
     // * `Authorization` - This payment is a basic authorization subject to
     // settlement with PayPal Authorization and Capture.
     // * `Order` - This payment is an order authorization subject to
     // settlement with PayPal Authorization and Capture.
     // `Note:
     // You cannot set this field to Sale in SetExpressCheckout request and
     // then change the value to Authorization or Order in the
     // DoExpressCheckoutPayment request. If you set the field to
     // Authorization or Order in SetExpressCheckout, you may set the field
     // to Sale.`
//.........这里部分代码省略.........
开发者ID:andrewwakeling,项目名称:codesamples-php,代码行数:101,代码来源:DoExpressCheckout.php

示例2: DoExpressCheckoutPaymentRequestType

$paymentDetails->OrderTotal = $orderTotal;
if (isset($_REQUEST['notifyURL'])) {
    $paymentDetails->NotifyURL = $_REQUEST['notifyURL'];
}
$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = $payerId;
$DoECRequestDetails->Token = $token;
$DoECRequestDetails->PaymentAction = $paymentAction;
$DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
$DoECRequest = new DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
$DoECReq = new DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
try {
    /* wrap API method calls on the service object with a try catch */
    $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($DoECResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$DoECResponse->Ack}</div> </td></tr>";
    if (isset($DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo)) {
        echo "<tr><td>TransactionID :</td><td><div id='TransactionID'>" . $DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo[0]->TransactionID . "</div> </td></tr>";
    }
    echo "</table>";
    echo "<pre>";
    print_r($DoECResponse);
    echo "</pre>";
}
开发者ID:rrehbeindoi,项目名称:merchant-sdk-php,代码行数:31,代码来源:DoExpressCheckout.php

示例3: doExpressCheckout

 /**
  * DoExpressCheckout実行
  *
  */
 public function doExpressCheckout()
 {
     global $mts_simple_booking;
     // トークンと買い手IDをセット
     $this->token = urlencode($_GET['token']);
     $this->payerId = urlencode($_GET['PayerID']);
     $this->_add_sessData($this->sess_name, array('token' => $this->token, 'payerId' => $this->payerId));
     // bookingデータをセットする
     $mts_simple_booking->oBooking_form->setBooking($this->sess_data['booking']);
     // 計算書を取得する
     $bill = $mts_simple_booking->oBooking_form->make_bill();
     $currencyCode = $bill->currency_code;
     // PayPalアクセス準備
     //$this->_init_paypal_sdk('DoExpressCheckout');
     // 請求合計額を計算する
     $itemTotal = $bill->get_total();
     $taxTotal = $bill->tax_type == 2 ? $bill->get_amount_tax() : 0;
     //$orderTotal = new BasicAmountType($currencyCode, $itemTotal + $taxTotal);
     $orderTotal = new BasicAmountType();
     $orderTotal->currencyID = $currencyCode;
     $orderTotal->value = $itemTotal + $taxTotal;
     // 支払明細設定
     $paymentDetails = new PaymentDetailsType();
     $paymentDetails->OrderTotal = $orderTotal;
     // API設定
     $DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $this->payerId;
     $DoECRequestDetails->Token = $this->token;
     $DoECRequestDetails->PaymentAction = 'Sale';
     $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
     $DoECRequest = new DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECReq = new DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     $paypalService = new PayPalAPIInterfaceServiceService();
     try {
         /* wrap API method calls on the service object with a try catch */
         $doECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     } catch (Exception $ex) {
         // セッションデータに例外を追加保存する
         $this->_add_sessData($this->sess_name, array('doECException' => $ex));
         throw $ex;
     }
     // セッションデータにDoExpressCheckoutの実行結果を追加する
     $this->_add_sessData($this->sess_name, array('doECResponse' => serialize($doECResponse)));
     if ($doECResponse->Ack == 'Success') {
         return true;
     }
     return false;
 }
开发者ID:pcdaiko,项目名称:mtsbase,代码行数:54,代码来源:mtssb-pp-manager.php

示例4: doExpressCheckout

 /**
  * @param $token
  * @param $paypalUserId
  * @param $amount
  * @param $currency
  * @return DoExpressCheckoutPaymentResponseType
  */
 public function doExpressCheckout($token, $paypalUserId, $amount, $currency)
 {
     $logger = new PPLoggingManager('GetTransactionDetails');
     /*
      *  Unique PayPal buyer account identification number as returned in the GetExpressCheckoutDetails response
      */
     $payerId = urlencode($paypalUserId);
     $paymentAction = urlencode("Sale");
     $paypalService = new PayPalAPIInterfaceServiceService();
     /*
      * The total cost of the transaction to the buyer. If shipping cost (not applicable to digital goods) and tax charges are known, include them in this value. If not, this value should be the current sub-total of the order. If the transaction includes one or more one-time purchases, this field must be equal to the sum of the purchases. Set this field to 0 if the transaction does not include a one-time purchase such as when you set up a billing agreement for a recurring payment that is not immediately charged. When the field is set to 0, purchase-specific fields are ignored.
      */
     $orderTotal = new BasicAmountType();
     $orderTotal->currencyID = $currency;
     $orderTotal->value = $amount;
     $paymentDetails = new PaymentDetailsType();
     $paymentDetails->OrderTotal = $orderTotal;
     //		$paymentDetails->NotifyURL = $_REQUEST['notifyURL'];
     $DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $payerId;
     $DoECRequestDetails->Token = $token;
     $DoECRequestDetails->PaymentAction = $paymentAction;
     $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
     $DoECRequest = new DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECReq = new DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     try {
         /* wrap API method calls on the service object with a try catch */
         $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     } catch (Exception $ex) {
         return FALSE;
         //todo error stuff
     }
     if ($DoECResponse->Ack == 'Success') {
         return $DoECResponse;
     } else {
         $logger->error("API Error Message : " . $DoECResponse);
         return FALSE;
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:48,代码来源:PaypalComponent.php

示例5: doCheckout

 public function doCheckout($payerId)
 {
     if (empty($this->ipnUrl)) {
         Yii::error('Ipn url haven\'t initialized');
         throw new Exception('Ipn url haven\'t initialized');
     }
     $settings = PaypalSettings::find()->one();
     $config = ['mode' => $settings->mode ? 'live' : 'sandbox', 'acct1.UserName' => $settings->api_username, 'acct1.Password' => $settings->api_password, 'acct1.Signature' => $settings->api_signature];
     $paypalService = new \PayPalAPIInterfaceServiceService($config);
     $orderTotal = new \BasicAmountType();
     $orderTotal->currencyID = $this->currency;
     $orderTotal->value = $this->payment_price;
     $paymentDetails = new \PaymentDetailsType();
     $paymentDetails->PaymentAction = 'Sale';
     $paymentDetails->NotifyURL = $this->ipnUrl;
     $paymentDetails->OrderTotal = $orderTotal;
     $DoECRequestDetails = new \DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $payerId;
     $DoECRequestDetails->Token = $this->payment_token;
     $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
     $DoECRequest = new \DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECRequest->Version = $this->ECVersion;
     $DoECReq = new \DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     if (!empty($DoECResponse->Errors)) {
         $this->errors = var_export($DoECResponse->Errors, true);
         $this->status = self::STATUS_ERROR;
         $this->save();
         Yii::error('Errors: ' . var_export($DoECResponse->Errors, true));
         return false;
     }
     $status = strtoupper($DoECResponse->DoExpressCheckoutPaymentResponseDetails->PaymentInfo[0]->PaymentStatus);
     $this->status = $status;
     $this->save();
     return true;
 }
开发者ID:achertovsky,项目名称:paypal-yii2,代码行数:38,代码来源:PaypalExpressPayment.php

示例6: confirm

 public function confirm($id, $token, $payer_id)
 {
     $products = $this->products;
     $product = $products[$id];
     if (empty($product)) {
         return;
     }
     $paypal_service = new PayPalAPIInterfaceServiceService($this->pp_settings);
     $ec_details_req_type = new GetExpressCheckoutDetailsRequestType($token);
     $ec_detail_req = new GetExpressCheckoutDetailsReq();
     $ec_detail_req->GetExpressCheckoutDetailsRequest = $ec_details_req_type;
     $ec_resp = $paypal_service->GetExpressCheckoutDetails($ec_detail_req);
     if (!$ec_resp && $ec_resp->Ack != 'Success') {
         throw new Exception("Paypal Request Failed");
     }
     //we now have the payer info
     $payer_info = $ec_resp->GetExpressCheckoutDetailsResponseDetails->PayerInfo;
     if ($product['recurring']) {
         $order_total = new BasicAmountType($product['currency'], $product['init_amount']);
     } else {
         $order_total = new BasicAmountType($product['currency'], $product['amount']);
     }
     $payment_details = new PaymentDetailsType();
     $payment_details->OrderTotal = $order_total;
     $payment_details->NotifyURL = $this->thankyou_url . '?action=ipn&id=' . $id;
     $do_ec_details = new DoExpressCheckoutPaymentRequestDetailsType();
     $do_ec_details->PayerID = $payer_id;
     $do_ec_details->Token = $token;
     $do_ec_details->PaymentDetails[0] = $payment_details;
     $do_ec_request = new DoExpressCheckoutPaymentRequestType();
     $do_ec_request->DoExpressCheckoutPaymentRequestDetails = $do_ec_details;
     if ($order_total->value > 0) {
         $do_ec = new DoExpressCheckoutPaymentReq();
         $do_ec->DoExpressCheckoutPaymentRequest = $do_ec_request;
         $do_ec_resp = $paypal_service->DoExpressCheckoutPayment($do_ec);
         if (!$do_ec_resp || $do_ec_resp->Ack != 'Success') {
             throw new Exception("Paypal Checkout Error Has Occured");
         }
         //we now have a payment info. Yeehaaa
         $payment_info = current($do_ec_resp->DoExpressCheckoutPaymentResponseDetails->PaymentInfo);
         $accept_statuses = array('Completed', 'In-Progress', 'Pending', 'Processed');
         if (!in_array($payment_info->PaymentStatus, $accept_statuses)) {
             throw new Exception("Paypal Payment Checkout Failed");
         }
     }
     if ($product['recurring']) {
         //create a recurring payment profile
         $schedule_details = new ScheduleDetailsType();
         $payment_billing_period = new BillingPeriodDetailsType();
         $payment_billing_period->BillingFrequency = $product['recur_billing_frequency'];
         $payment_billing_period->BillingPeriod = $product['recur_billing_period'];
         $payment_billing_period->Amount = new BasicAmountType($product['currency'], $product['recur_amount']);
         $schedule_details->PaymentPeriod = $payment_billing_period;
         $schedule_details->Description = sprintf("%s %s", $product['name'], __("Subscription", "wishlist-member"));
         $recur_profile_details = new RecurringPaymentsProfileDetailsType();
         $recur_profile_details->BillingStartDate = date(DATE_ATOM, strtotime(sprintf("+%s %s", $product['recur_billing_frequency'], $product['recur_billing_period'])));
         $create_recur_paypay_profile_details = new CreateRecurringPaymentsProfileRequestDetailsType();
         $create_recur_paypay_profile_details->Token = $token;
         $create_recur_paypay_profile_details->ScheduleDetails = $schedule_details;
         $create_recur_paypay_profile_details->RecurringPaymentsProfileDetails = $recur_profile_details;
         $create_recur_profile = new CreateRecurringPaymentsProfileRequestType();
         $create_recur_profile->CreateRecurringPaymentsProfileRequestDetails = $create_recur_paypay_profile_details;
         $create_recur_profile_req = new CreateRecurringPaymentsProfileReq();
         $create_recur_profile_req->CreateRecurringPaymentsProfileRequest = $create_recur_profile;
         $create_profile_resp = $paypal_service->CreateRecurringPaymentsProfile($create_recur_profile_req);
         if (!$create_profile_resp || $create_profile_resp->Ack != 'Success') {
             throw new Exception("Could not create recurring profile");
         }
     }
     $address = array();
     $address['company'] = $payer_info->PayerBusiness;
     $address['address1'] = $payer_info->Address->Street1;
     $address['address2'] = $payer_info->Address->Street2;
     $address['city'] = $payer_info->Address->CityName;
     $address['state'] = $payer_info->Address->StateOrProvince;
     $address['zip'] = $payer_info->Address->PostalCode;
     $address['country'] = $payer_info->Address->CountryName;
     $_POST['wpm_useraddress'] = $address;
     $_POST['lastname'] = $payer_info->PayerName->LastName;
     $_POST['firstname'] = $payer_info->PayerName->FirstName;
     $_POST['action'] = 'wpm_register';
     $_POST['wpm_id'] = $product['sku'];
     $_POST['username'] = $payer_info->Payer;
     $_POST['email'] = $payer_info->Payer;
     $_POST['password1'] = $_POST['password2'] = $this->wlm->PassGen();
     $_POST['sctxnid'] = $product['recurring'] ? $create_profile_resp->CreateRecurringPaymentsProfileResponseDetails->ProfileID : $payment_info->TransactionID;
     $pending_statuses = array('In-Progress', 'Pending');
     if (in_array($payment_info->PaymentStatus, $pending_statuses) || $create_profile_resp->CreateRecurringPaymentsProfileResponseDetails->ProfileStatus == 'PendingProfile') {
         $this->wlm->ShoppingCartRegistration(null, null, 'Paypal Pending');
     } else {
         $this->wlm->ShoppingCartRegistration();
     }
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:93,代码来源:integration.shoppingcart.paypalpro.php


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