本文整理汇总了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());
}
示例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()];
}