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


PHP Transaction::getDescription方法代碼示例

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


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

示例1: testGetterSetter

 public function testGetterSetter()
 {
     $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
     $this->assertEquals(self::$description, $this->transaction->getDescription());
     $this->assertEquals(self::$invoiceNumber, $this->transaction->getInvoiceNumber());
     $this->assertEquals(self::$custom, $this->transaction->getCustom());
     $this->assertEquals(self::$softDescriptor, $this->transaction->getSoftDescriptor());
     $items = $this->transaction->getItemList()->getItems();
     $this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity());
     $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
     $resources = $this->transaction->getRelatedResources();
     $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
 }
開發者ID:johnmicahmiguel,項目名稱:yodaphp,代碼行數:13,代碼來源:TransactionTest.php

示例2: getLinkCheckOut

 public function getLinkCheckOut($params = null)
 {
     if (!$params) {
         return false;
     }
     /*Payer
     	 A resource representing a Payer that funds a payment
     	 For paypal account payments, set payment method
     	 to 'paypal'.
     	 */
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     $itemList = new ItemList();
     // Item must be a array and has one or more item.
     if (!$params['items']) {
         return false;
     }
     $arrItem = [];
     foreach ($params['items'] as $key => $item) {
         $it = new Item();
         $it->setName($item['name'])->setCurrency($params['currency'])->setQuantity($item['quantity'])->setPrice($item['price']);
         $arrItem[] = $it;
     }
     $itemList->setItems($arrItem);
     $amount = new Amount();
     $amount->setCurrency($params['currency'])->setTotal($params['total_price']);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription($params['description']);
     // ### Redirect urls
     // Set the urls that the buyer must be redirected to after
     // payment approval/ cancellation.
     $redirectUrls = new RedirectUrls();
     $baseUrl = $this->getBaseUrl();
     $redirectUrls->setReturnUrl($baseUrl . $this->successUrl)->setCancelUrl($baseUrl . $this->cancelUrl);
     // ### 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([$transaction]);
     // ### Create Payment
     // Create a payment by calling the 'create' method
     // passing it a valid apiContext.
     try {
         $payment->create($this->config);
     } catch (PayPal\Exception\PPConnectionException $ex) {
         throw new \DataErrorException($ex->getData(), $ex->getMessage());
     }
     // ### Get redirect url
     $redirectUrl = $payment->getApprovalLink();
     return ['payment_id' => $payment->getId(), 'status' => $payment->getState(), 'redirect_url' => $redirectUrl, 'description' => $transaction->getDescription()];
 }
開發者ID:betsuno,項目名稱:yii2-paypal,代碼行數:51,代碼來源:RestAPI.php


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