當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。