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


PHP Payer::setFundingInstruments方法代码示例

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


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

示例1: makePaymentUsingCC

 /**
  * Create a payment using a previously obtained
  * credit card id. The corresponding credit
  * card is used as the funding instrument.
  * 
  * @param string $creditCardId credit card id
  * @param string $total Payment amount with 2 decimal points
  * @param string $currency 3 letter ISO code for currency
  * @param string $paymentDesc
  */
 function makePaymentUsingCC($creditCardId, $total, $currency, $paymentDesc)
 {
     $ccToken = new CreditCardToken();
     $ccToken->setCreditCardId($creditCardId);
     $fi = new FundingInstrument();
     $fi->setCreditCardToken($ccToken);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array($fi));
     // Specify the payment amount.
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($total);
     // ###Transaction
     // A transaction defines the contract of a
     // payment - what is the payment for and who
     // is fulfilling it. Transaction is created with
     // a `Payee` and `Amount` types
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($paymentDesc);
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $payment->create(new Paypalinit());
     return $payment;
 }
开发者ID:shivap87,项目名称:cost,代码行数:38,代码来源:Paypal.php

示例2: createPayer

 public static function createPayer()
 {
     $payer = new Payer();
     $payer->setPaymentMethod(self::$paymentMethod);
     $payer->setPayerInfo(PayerInfoTest::createPayerInfo());
     $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
     return $payer;
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:8,代码来源:PayerTest.php

示例3: createPayer

 /**
  * Creates a Payer object for given payment method and funding instrument
  *
  * @param string                 $paymentMethod
  * @param FundingInstrument|null $fundingInstrument
  *
  * @return Payer
  */
 protected function createPayer(string $paymentMethod, FundingInstrument $fundingInstrument = null) : Payer
 {
     $payer = new Payer();
     $payer->setPaymentMethod($paymentMethod);
     if (null !== $fundingInstrument) {
         $payer->setFundingInstruments([$fundingInstrument]);
     }
     return $payer;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:17,代码来源:AbstractPayPalProcessor.php

示例4: preparePayment

 public static function preparePayment($payment, $domain)
 {
     $items = array();
     $currency = null;
     $total = 0;
     foreach ($payment->items as $item) {
         $tmpItem = new PayPalItem();
         $tmpItem->setName($item->description)->setCurrency($item->currency)->setQuantity($item->quantity)->setSku($item->sku)->setPrice($item->price);
         $items[] = $tmpItem;
         //
         $total += (double) $item->price;
         $currency = $item->currency;
     }
     $itemList = new ItemList();
     $itemList->setItems($items);
     $payer = new PayPalPayer();
     switch ($payment->payer->paymentMethod) {
         case Payer::PAYMENT_CREDIT_CARD:
             $payer->setPaymentMethod($payment->payer->paymentMethod);
             $card = new PayPalCreditCard();
             $card->setType($payment->payer->creditCard->type)->setNumber($payment->payer->creditCard->number)->setExpireMonth($payment->payer->creditCard->expireMonth)->setExpireYear($payment->payer->creditCard->expireYear)->setCvv2($payment->payer->creditCard->cvv2)->setFirstName($payment->payer->creditCard->firstName)->setLastName($payment->payer->creditCard->lastName);
             $fi = new FundingInstrument();
             $fi->setCreditCard($card);
             $payer->setFundingInstruments(array($fi));
             break;
         case Payer::PAYMENT_PAYPAL:
             $payer->setPaymentMethod($payment->payer->paymentMethod);
             break;
     }
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($total);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription($payment->description);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($payment->returnUrl);
     $redirectUrls->setCancelUrl($payment->cancelUrl);
     $paypalPayment = new PayPalPayment();
     $paypalPayment->setRedirectUrls($redirectUrls);
     $paypalPayment->setIntent($payment->intent);
     $paypalPayment->setPayer($payer);
     $paypalPayment->setTransactions(array($transaction));
     try {
         $paypalPayment->create(static::getApiContext($domain));
         return static::getPayment($paypalPayment->getId(), $domain)->then(function ($payment) use($paypalPayment) {
             $payment->approvalUrl = static::getLink($paypalPayment->getLinks(), "approval_url");
             return $payment;
         });
     } catch (PayPalConnectionException $e) {
         return When::reject($e);
     } catch (PayPalInvalidCredentialException $e) {
         return When::reject($e);
     }
 }
开发者ID:breadphp,项目名称:paypal,代码行数:54,代码来源:Driver.php

示例5: paypal

 function paypal($data)
 {
     try {
         foreach ($data as $k => $v) {
             ${$k} = $v;
         }
         include_once 'config.paypal.php';
         $apiContext = new ApiContext(new OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET));
         list($m, $y) = explode("/", $card_expiry);
         $card = new CreditCard();
         $card->setNumber($card_number);
         $card->setType(strtolower($card_type));
         $card->setExpireMonth($m);
         $card->setExpireYear($y);
         $card->setCvv2($card_cvv);
         $card->setFirstName($first_name);
         $card->setLastName($last_name);
         $fi = new FundingInstrument();
         $fi->setCreditCard($card);
         $payer = new Payer();
         $payer->setPaymentMethod('credit_card');
         $payer->setFundingInstruments(array($fi));
         $amount = new Amount();
         $amount->setCurrency($currency);
         $amount->setTotal($price);
         $transaction = new Transaction();
         $transaction->setAmount($amount);
         $transaction->setDescription('Enter your card details and proceed');
         $payment = new Payment();
         $payment->setIntent('sale');
         $payment->setPayer($payer);
         $payment->setTransactions(array($transaction));
         $res = json_decode($payment->create($apiContext));
         $this->save($data, __FUNCTION__, $res, 1);
         return json_encode(["status" => true, "msg" => sprintf("Your payment has been %s", $res->state)]);
     } catch (Exception $e) {
         if ($e instanceof PPConfigurationException) {
         } elseif ($e instanceof PPConnectionException) {
         } elseif ($e instanceof PayPal\Exception\PayPalConnectionException) {
             $res = json_decode($e->getData(), 1);
             $this->save($data, __FUNCTION__, $res, 0);
             $msg = array_shift(isset($res["details"]) ? $res["details"] : []);
             return json_encode(["status" => false, "msg" => $res["name"] == "UNKNOWN_ERROR" || empty($msg["issue"]) ? "An unknown error has occurred" : sprintf("%s %s", ["cvv2" => "CVV2", "expire_year" => "Card expiration", "credit_card" => "", "type" => "Invalid credit card number or", "number" => "Credit card number", "expire_month" => "Expiration month"][end(explode(".", $msg["field"]))], strtolower($msg["issue"]))]);
         } else {
             throw $e;
         }
     }
 }
开发者ID:aliuadepoju,项目名称:hqpay,代码行数:48,代码来源:Gateway.php

示例6: createNewPayment

 public static function createNewPayment()
 {
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
     $transaction = new Transaction();
     $transaction->setAmount(AmountTest::createAmount());
     $transaction->setDescription("This is the payment description.");
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl("http://localhost/return");
     $redirectUrls->setCancelUrl("http://localhost/cancel");
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setRedirectUrls($redirectUrls);
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:18,代码来源:PaymentTest.php

示例7: payDemo

 public function payDemo()
 {
     $this->authorize();
     $addr = new Address();
     $addr->setLine1('52 N Main ST');
     $addr->setCity('Johnstown');
     $addr->setCountryCode('US');
     $addr->setPostalCode('43210');
     $addr->setState('OH');
     $card = new CreditCard();
     $card->setNumber('4417119669820331');
     $card->setType('visa');
     $card->setExpireMonth('11');
     $card->setExpireYear('2018');
     $card->setCvv2('874');
     $card->setFirstName('Joe');
     $card->setLastName('Shopper');
     $card->setBillingAddress($addr);
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod('credit_card');
     $payer->setFundingInstruments(array($fi));
     $amountDetails = new \PayPal\Api\Details();
     $amountDetails->setSubtotal('7.41');
     $amountDetails->setTax('0.03');
     $amountDetails->setShipping('0.03');
     $amount = new Amount();
     $amount->setCurrency('USD');
     $amount->setTotal('7.47');
     $amount->setDetails($amountDetails);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('This is the payment transaction description.');
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $payment->create($this->_apiContext);
 }
开发者ID:ewwgit,项目名称:eptri,代码行数:40,代码来源:Paypal.php

示例8: create

 public static function create($items, Details $shippingDetails, $paymentIntent, $paymentMethod, $fi = null)
 {
     $payer = new Payer();
     $payer->setPaymentMethod($paymentMethod);
     if ($fi !== null) {
         $payer->setFundingInstruments(array($fi));
     }
     $fullList = array();
     foreach ($items as $item) {
         if (!$item instanceof ItemInterface) {
             throw new Exception('All the item created for the payment MUST implement the ItemInterface');
         }
         $singleItem = new Item();
         $singleItem->setName($item->getName());
         $singleItem->setSku($item->getSku());
         $singleItem->setCurrency($item->getCurrency());
         $singleItem->setPrice($item->getPrice());
         $singleItem->setQuantity($item->getQuantity());
         $fullList[] = $singleItem;
     }
     $itemList = new ItemList();
     $itemList->setItems($fullList);
     $details = $shippingDetails;
     $subtotal = 0.0;
     /** @var Item $singleItem */
     foreach ($fullList as $singleItem) {
         $subtotal += floatval($singleItem->getPrice()) * floatval($singleItem->getQuantity());
     }
     $details->setSubtotal($subtotal);
     $total = $subtotal + floatval($details->getTax()) + floatval($details->getShipping());
     $currencyMode = Validation::currencyMode($items);
     $amount = new Amount();
     $amount->setCurrency($currencyMode)->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList);
     $payment = new Payment();
     $payment->setIntent($paymentIntent)->setPayer($payer)->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:DDFranky22,项目名称:DDFPayPalBundle,代码行数:39,代码来源:PaymentService.php

示例9: authorize

 public static function authorize()
 {
     $addr = new Address();
     $addr->setLine1("3909 Witmer Road");
     $addr->setLine2("Niagara Falls");
     $addr->setCity("Niagara Falls");
     $addr->setState("NY");
     $addr->setPostalCode("14305");
     $addr->setCountryCode("US");
     $addr->setPhone("716-298-1822");
     $card = new CreditCard();
     $card->setType("visa");
     $card->setNumber("4417119669820331");
     $card->setExpireMonth("11");
     $card->setExpireYear("2019");
     $card->setCvv2("012");
     $card->setFirstName("Joe");
     $card->setLastName("Shopper");
     $card->setBillingAddress($addr);
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array($fi));
     $amount = new Amount();
     $amount->setCurrency("USD");
     $amount->setTotal("1.00");
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription("This is the payment description.");
     $payment = new Payment();
     $payment->setIntent("authorize");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $paymnt = $payment->create();
     $resArray = $paymnt->toArray();
     return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
 }
开发者ID:ewwgit,项目名称:eptri,代码行数:38,代码来源:AuthorizationTest.php

示例10: Agreement

$agreement = new Agreement();
$agreement->setName('DPRP')->setDescription('Payment with credit Card')->setStartDate('2015-06-17T9:45:04Z');
// Add Plan ID
// Please note that the plan Id should be only set in this case.
$plan = new Plan();
$plan->setId($createdPlan->getId());
$agreement->setPlan($plan);
// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('credit_card')->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));
// Add Credit Card to Funding Instruments
$creditCard = new CreditCard();
$creditCard->setType('visa')->setNumber('4491759698858890')->setExpireMonth('12')->setExpireYear('2017')->setCvv2('128');
$fundingInstrument = new FundingInstrument();
$fundingInstrument->setCreditCard($creditCard);
$payer->setFundingInstruments(array($fundingInstrument));
//Add Payer to Agreement
$agreement->setPayer($payer);
// Add Shipping Address
$shippingAddress = new ShippingAddress();
$shippingAddress->setLine1('111 First Street')->setCity('Saratoga')->setState('CA')->setPostalCode('95070')->setCountryCode('US');
$agreement->setShippingAddress($shippingAddress);
// For Sample Purposes Only.
$request = clone $agreement;
// ### Create Agreement
try {
    // Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
    $agreement = $agreement->create($apiContext);
} catch (Exception $ex) {
    ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);
    exit(1);
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:31,代码来源:CreateBillingAgreementWithCreditCard.php

示例11: createBillingAgreement

 public function createBillingAgreement($planId, $shippingAddress, $billingAddress, $productName, $cartSummary, $cardDetails, $apiContext)
 {
     $billingPlanDefaultValues = $this->getBillingPlanDefaultValues();
     $billingAgreement = new Agreement();
     $billingAgreement->setName('Billing Agreement For ' . $productName);
     $billingAgreement->setDescription($cartSummary->paymentPlanTitle);
     $startDate = new Zend_Date();
     $startDate->addDay($billingPlanDefaultValues->startDateInterval);
     $billingAgreement->setStartDate($startDate->get(Zend_Date::ISO_8601));
     $payerInfo = new PayerInfo();
     $payerInfo->setFirstName($billingAddress->firstname);
     $payerInfo->setLastName($billingAddress->lastname);
     $payerInfo->setEmail($billingAddress->emailAddress);
     /* Fields not supported yet */
     //$payerInfo->setEmail($cart->address->billing['billing_email']);
     //$payerInfo->setPhone($cart->address->billing['billing_contactNo']);
     /* Get a MALFORMED_REQUEST error when using this field */
     //$payerInfo->setCountryCode($cart->address->billing['billing_countryCode']);
     $cardName = $cardDetails->cardName;
     $cardNumber = $cardDetails->cardNumber;
     $cardType = strtolower($cardDetails->cardType);
     $cardExpiryMonth = $cardDetails->cardExpiryMonth;
     $cardExpiryYear = $cardDetails->cardExpiryYear;
     $cardSecurityCode = $cardDetails->cardSecurityCode;
     $nameParser = new Om_Model_Name();
     $name = $nameParser->parse_name($cardName);
     $card = new CreditCard();
     $card->setType($cardType);
     $card->setNumber($cardNumber);
     $card->setExpireMonth($cardExpiryMonth);
     $card->setExpireYear($cardExpiryYear);
     $card->setCvv2($cardSecurityCode);
     $card->setFirstName($name['fname']);
     $card->setLastName($name['lname']);
     $fundingInstrument = new FundingInstrument();
     $fundingInstrument->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array($fundingInstrument));
     $payer->setPayerInfo($payerInfo);
     $billingAgreement->setPayer($payer);
     $shippingAddressPayPal = new Address();
     $shippingAddressPayPal->setLine1($shippingAddress->addressLine1);
     $shippingAddressPayPal->setLine2($shippingAddress->addressLine2 . ' ' . $shippingAddress->addressLine3);
     $shippingAddressPayPal->setCity($shippingAddress->city);
     $shippingAddressPayPal->setCountryCode($shippingAddress->getCountry()->code);
     $shippingAddressPayPal->setPostalCode($shippingAddress->postcode);
     $shippingAddressPayPal->setState($shippingAddress->county);
     $shippingAddressPayPal->setPhone($shippingAddress->contactNumber);
     $billingAgreement->setShippingAddress($shippingAddressPayPal);
     $plan = new Plan();
     $plan->setId($planId);
     $billingAgreement->setPlan($plan);
     return $billingAgreement->create($apiContext);
 }
开发者ID:sebardo,项目名称:ecommerce,代码行数:55,代码来源:PayPalApi.php

示例12: teszt


//.........这里部分代码省略.........
     $itemList = new ItemList();
     $itemList->setItems(array($item1, $item2));
     // ### Additional payment details
     // Use this optional field to set additional
     // payment information such as tax, shipping
     // charges etc.
     /* $details = new Details();
     $details->setShipping(1.2)
         ->setTax(1.3)
         ->setSubtotal(17.50); */
     // ### Amount
     // Lets you specify a payment amount.
     // You can also specify additional details
     // such as shipping, tax.
     /* $amount = new Amount();
     $amount->setCurrency("USD")
         ->setTotal(20)
         ->setDetails($details); */
     // ### Transaction
     // A transaction defines the contract of a
     // payment - what is the payment for and who
     // is fulfilling it.
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description");
     // ->setInvoiceNumber('134');
     //>setInvoiceNumber(uniqid());
     // ### Redirect urls
     // Set the urls that the buyer must be redirected to after
     // payment approval/ cancellation.
     //$baseUrl = getBaseUrl();
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/ordered")->setCancelUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/index");
     // ### Payment
     // A Payment Resource; create one using
     // the above types and intent set to 'sale'
     /* $payment = new Payment();
     $payment->setIntent("sale")
         ->setPayer($payer)
         ->setRedirectUrls($redirectUrls)
         ->setTransactions(array($transaction)); */
     $addr = new Address();
     $addr->setLine1('52 N Main ST');
     $addr->setCity('Johnstown');
     $addr->setCountryCode('US');
     $addr->setPostalCode('43210');
     $addr->setState('OH');
     $card = new CreditCard();
     $card->setNumber('5110929378020149');
     $card->setType('MASTERCARD');
     $card->setExpireMonth('08');
     $card->setExpireYear('2020');
     $card->setCvv2('874');
     $card->setFirstName('Nishanth');
     $card->setLastName('Pininti');
     $card->setBillingAddress($addr);
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod('credit_card');
     $payer->setFundingInstruments(array($fi));
     $amountDetails = new \PayPal\Api\Details();
     $amountDetails->setSubtotal('7.41');
     $amountDetails->setTax('0.03');
     $amountDetails->setShipping('0.03');
     $amount = new Amount();
     $amount->setCurrency('USD');
     $amount->setTotal('7.47');
     $amount->setDetails($amountDetails);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('This is the payment transaction description.');
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     // For Sample Purposes Only.
     $request = clone $payment;
     // ### Create Payment
     // Create a payment by calling the 'create' method
     // passing it a valid apiContext.
     // (See bootstrap.php for more on `ApiContext`)
     // The return object contains the state and the
     // url to which the buyer must be redirected to
     // for payment approval
     try {
         $payment->create($apiContext);
     } catch (Exception $ex) {
         ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
         exit(1);
     }
     // ### Get redirect url
     // The API response provides the url that you must redirect
     // the buyer to. Retrieve the url from the $payment->getApprovalLink()
     // method
     //$approvalUrl = $payment->getRedirectUrls();
     // ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment);
     var_dump($payment);
     return $payment;
     //END SAMPLE 3
 }
开发者ID:nishanthpininti,项目名称:nishanth-work-nudostilo,代码行数:101,代码来源:paypal.php

示例13: payCard

 /**
  * Runs a card payment with PayPal
  *
  * @link https://devtools-paypal.com/guide/pay_creditcard/php?interactive=ON&env=sandbox
  * @return PayPal\Api\Payment 
  */
 public function payCard($cardInfo = [], $sum = 0, $message = '')
 {
     $card = new CreditCard();
     $card->setType($cardInfo['cardType']);
     $card->setNumber($cardInfo['cardNumber']);
     $card->setExpireMonth($cardInfo['expMonth']);
     $card->setExpireYear($cardInfo['expYear']);
     $card->setFirstName($cardInfo['firstName']);
     $card->setLastName($cardInfo['lastName']);
     $fundingInstrument = new FundingInstrument();
     $fundingInstrument->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod('credit_card');
     $payer->setFundingInstruments(array($fundingInstrument));
     $amount = new Amount();
     $amount->setCurrency($this->currency);
     $amount->setTotal($sum);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     if ($message) {
         $transaction->setDescription($message);
     }
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     return $payment->create($this->_apiContext);
     // get state from this json
 }
开发者ID:shinomontaz,项目名称:yii2-paypal,代码行数:35,代码来源:Paypal.php


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