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


PHP PayPalAPIInterfaceServiceService::DoDirectPayment方法代码示例

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


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

示例1: capture

 /**
  *
  * @param float $amount
  * @param array $address
  * 			first_name
  * 			last_name
  * 			city
  * 			state
  * 			zip
  * @param array $card
  * 			number
  * 			month
  * 			year
  * 			cvv
  * @return PayPalAPIInterfaceServiceService
  */
 public function capture($amount, $address, $card)
 {
     $orderTotal = new BasicAmountType();
     $this->Market = ClassRegistry::init('Market');
     $this->Country = ClassRegistry::init('Country');
     $market = $this->Market->find("first", array("fields" => array("currency"), "conditions" => array("id" => Configure::read("market_id"))));
     $country = $this->Country->find("first", array("fields" => array("country_code"), "conditions" => array("market_id" => Configure::read("market_id"))));
     $orderTotal->currencyID = $market['Market']['currency'];
     $orderTotal->value = $amount;
     $addr = new AddressType();
     $addr->Name = $address['name'];
     $addr->Street1 = $address['addr1'];
     $addr->CityName = $address['city'];
     $addr->StateOrProvince = $address['state'];
     $addr->PostalCode = $address['zip'];
     $addr->Country = $country["Country"]['country_code'];
     $PaymentDetails = new PaymentDetailsType();
     $PaymentDetails->ShipToAddress = $addr;
     $PaymentDetails->OrderTotal = $orderTotal;
     $person_name = new PersonNameType();
     $person_name->FirstName = $address['first_name'];
     $person_name->LastName = $address['last_name'];
     $payer = new PayerInfoType();
     $payer->PayerName = $person_name;
     $payer->Address = $addr;
     $payer->PayerCountry = $country["Country"]['country_code'];
     $cardDetails = new CreditCardDetailsType();
     $cardDetails->CreditCardNumber = $card['number'];
     if (!empty($card['month'])) {
         $cardDetails->ExpMonth = str_pad($card['month'], 2, '0', STR_PAD_LEFT);
         $cardDetails->ExpYear = $card['year'];
     }
     $cardDetails->CVV2 = $card['cvv'];
     $cardDetails->CardOwner = $payer;
     $ddReqDetails = new DoDirectPaymentRequestDetailsType();
     $ddReqDetails->CreditCard = $cardDetails;
     $ddReqDetails->PaymentDetails = $PaymentDetails;
     $ddReq = new DoDirectPaymentRequestType($ddReqDetails);
     $doDirectPaymentReq = new DoDirectPaymentReq();
     $doDirectPaymentReq->DoDirectPaymentRequest = $ddReq;
     $paypalService = new PayPalAPIInterfaceServiceService();
     $doDirectPaymentResponse = $paypalService->DoDirectPayment($doDirectPaymentReq);
     return $doDirectPaymentResponse;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:60,代码来源:PaypalComponent.php

示例2: DoDirectPaymentRequestDetailsType

$cardDetails->ExpYear = $_POST['expDateYear'];
$cardDetails->CVV2 = $_POST['cvv2Number'];
$cardDetails->CardOwner = $payer;
$ddReqDetails = new DoDirectPaymentRequestDetailsType();
$ddReqDetails->CreditCard = $cardDetails;
$ddReqDetails->PaymentDetails = $paymentDetails;
$doDirectPaymentReq = new DoDirectPaymentReq();
$doDirectPaymentReq->DoDirectPaymentRequest = new DoDirectPaymentRequestType($ddReqDetails);
/*
 * 		 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $doDirectPaymentResponse = $paypalService->DoDirectPayment($doDirectPaymentReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($doDirectPaymentResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$doDirectPaymentResponse->Ack}</div> </td></tr>";
    echo "<tr><td>TransactionID :</td><td><div id='TransactionID'>{$doDirectPaymentResponse->TransactionID}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($doDirectPaymentResponse);
    echo "</pre>";
}
require_once '../Response.php';
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:31,代码来源:DoDirectPayment.php

示例3: doDirectPay

 public function doDirectPay()
 {
     $logger = new PPLoggingManager('DoDirectPayment');
     // ## DoDirectPaymentReq
     $doDirectPaymentReq = new DoDirectPaymentReq();
     $doDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();
     // Information about the credit card to be charged.
     $creditCard = new CreditCardDetailsType();
     // Type of credit card. For UK, only Maestro, MasterCard, Discover, and
     // Visa are allowable. For Canada, only MasterCard and Visa are
     // allowable and Interac debit cards are not supported. It is one of the
     // following values:
     //
     // * Visa
     // * MasterCard
     // * Discover
     // * Amex
     // * Solo
     // * Switch
     // * Maestro: See note.
     // `Note:
     // If the credit card type is Maestro, you must set currencyId to GBP.
     // In addition, you must specify either StartMonth and StartYear or
     // IssueNumber.`
     $cardDetails->CreditCardType = "Visa";
     // Credit Card number
     $creditCard->CreditCardNumber = "4770461107194023";
     // ExpiryMonth of credit card
     $creditCard->ExpMonth = "12";
     // Expiry Year of credit card
     $creditCard->ExpYear = "2021";
     //Details about the owner of the credit card.
     $cardOwner = new PayerInfoType();
     // Email address of buyer.
     $cardOwner->Payer = "enduser_biz@gmail.com";
     $creditCard->CardOwner = $cardOwner;
     $doDirectPaymentRequestDetails->CreditCard = $creditCard;
     // Information about the payment
     $paymentDetails = 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`
     $orderTotal = new BasicAmountType("USD", "4.00");
     $paymentDetails->OrderTotal = $orderTotal;
     //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.
     $paymentDetails->NotifyURL = "http://localhost/ipn";
     $doDirectPaymentRequestDetails->PaymentDetails = $paymentDetails;
     // IP address of the buyer's browser.
     // `Note:
     // PayPal records this IP addresses as a means to detect possible fraud.`
     $doDirectPaymentRequestDetails->IPAddress = "127.0.0.1";
     $doDirectPaymentRequest = new DoDirectPaymentRequestType($doDirectPaymentRequestDetails);
     $doDirectPaymentReq->DoDirectPaymentRequest = $doDirectPaymentRequest;
     // ## 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->DoDirectPayment($doDirectPaymentReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using variables in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         // Unique identifier of the transaction
         $logger->log("Transaction ID :" . $response->TransactionID);
     } else {
         logger . severe("API Error Message : " . $response->Error[0]->LongMessage);
     }
     return $response;
 }
开发者ID:andrewwakeling,项目名称:codesamples-php,代码行数:88,代码来源:DoDirectPayment.php

示例4: purchase_direct_once

 public function purchase_direct_once($product)
 {
     $item_details = new PaymentDetailsItemType();
     $item_details->Name = $product['name'];
     $item_details->Amount = $product['amount'];
     $item_details->Quantity = 1;
     $payment_details = new PaymentDetailsType();
     $payment_details->OrderTotal = new BasicAmountType($product['currency'], $product['amount']);
     $payment_details->NotifyURL = $this->thankyou_url . '?action=ipn&id=' . $id;
     $payment_details->PaymentDetailsItem[$i] = $item_details;
     $person_name = new PersonNameType();
     $person_name->FirstName = $_POST['first_name'];
     $person_name->LastName = $_POST['last_name'];
     $payer = new PayerInfoType();
     $payer->Payer = $_POST['email'];
     $payer->PayerName = $person_name;
     $card_details = new CreditCardDetailsType();
     $card_details->CreditCardNumber = $_POST['cc_number'];
     $card_details->CreditCardType = $_POST['cc_type'];
     $card_details->ExpMonth = $_POST['cc_expmonth'];
     $card_details->ExpYear = $_POST['cc_expyear'] + 2000;
     $card_details->CVV2 = $_POST['cc_cvc'];
     $card_details->CardOwner = $payer;
     $dd_req_details = new DoDirectPaymentRequestDetailsType();
     $dd_req_details->CreditCard = $card_details;
     $dd_req_details->PaymentDetails = $payment_details;
     $do_direct_req = new DoDirectPaymentReq();
     $do_direct_req->DoDirectPaymentRequest = new DoDirectPaymentRequestType($dd_req_details);
     $paypal_service = new PayPalAPIInterfaceServiceService($this->pp_settings);
     $resp = $paypal_service->DoDirectPayment($do_direct_req);
     if ($resp->Ack == 'Success' || $resp->Ack == 'SuccessWithWarning') {
         return array('status' => 'active', 'id' => $resp->TransactionID);
     }
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:34,代码来源:integration.shoppingcart.paypalpro.php


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