當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Amount::getCurrency方法代碼示例

本文整理匯總了PHP中PayPal\Api\Amount::getCurrency方法的典型用法代碼示例。如果您正苦於以下問題:PHP Amount::getCurrency方法的具體用法?PHP Amount::getCurrency怎麽用?PHP Amount::getCurrency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PayPal\Api\Amount的用法示例。


在下文中一共展示了Amount::getCurrency方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 /**
  * @param PaymentInterface $payment
  */
 public function init(PaymentInterface $payment)
 {
     $credentials = new OAuthTokenCredential($this->options['client_id'], $this->options['secret']);
     $apiContext = new ApiContext($credentials);
     $apiContext->setConfig(['mode' => $this->options['mode']]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency($this->options['currency']);
     $amount->setTotal($payment->getPaymentSum());
     $item = new Item();
     $item->setName($payment->getDescription());
     $item->setCurrency($amount->getCurrency());
     $item->setQuantity(1);
     $item->setPrice($amount->getTotal());
     $itemList = new ItemList();
     $itemList->addItem($item);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($payment->getDescription());
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($payment->getExtraData('return_url'));
     $redirectUrls->setCancelUrl($payment->getExtraData('cancel_url'));
     $paypalPayment = new Payment();
     $paypalPayment->setIntent('sale');
     $paypalPayment->setPayer($payer);
     $paypalPayment->setTransactions([$transaction]);
     $paypalPayment->setRedirectUrls($redirectUrls);
     $paypalPayment->create($apiContext);
     $payment->setExtraData('paypal_payment_id', $paypalPayment->getId());
     $payment->setExtraData('approval_link', $paypalPayment->getApprovalLink());
 }
開發者ID:moriony,項目名稱:payment-gateway,代碼行數:36,代碼來源:PayPalHandler.php

示例2: testGetters

 /**
  * @depends testSerializationDeserialization
  * @param Amount $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getCurrency(), "TestSample");
     $this->assertEquals($obj->getTotal(), "12.34");
     $this->assertEquals($obj->getDetails(), DetailsTest::getObject());
 }
開發者ID:Roc4rdho,項目名稱:app,代碼行數:10,代碼來源:AmountTest.php


注:本文中的PayPal\Api\Amount::getCurrency方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。