本文整理汇总了PHP中PayPal\Api\Details::getTax方法的典型用法代码示例。如果您正苦于以下问题:PHP Details::getTax方法的具体用法?PHP Details::getTax怎么用?PHP Details::getTax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Details
的用法示例。
在下文中一共展示了Details::getTax方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetters
/**
* @depends testSerializationDeserialization
* @param Details $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getSubtotal(), "12.34");
$this->assertEquals($obj->getShipping(), "12.34");
$this->assertEquals($obj->getTax(), "12.34");
$this->assertEquals($obj->getHandlingFee(), "12.34");
$this->assertEquals($obj->getShippingDiscount(), "12.34");
$this->assertEquals($obj->getInsurance(), "12.34");
$this->assertEquals($obj->getGiftWrap(), "12.34");
$this->assertEquals($obj->getFee(), "12.34");
}
示例2: Payer
use PayPal\Api\Payment;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
use PayPal\Exception\PayPalConnectionException;
require '../src/start.php';
$payer = new Payer();
$amount = new Amount();
$details = new Details();
$payment = new Payment();
$transaction = new Transaction();
$redirectUrls = new RedirectUrls();
// Payer
$payer->setPaymentMethod('paypal');
// Details
$details->setShipping('2.00')->setTax('0.00')->setSubtotal('20.00');
$total = number_format($details->getSubtotal() + $details->getShipping() + $details->getTax(), 2);
// Amount
$amount->setCurrency('GBP')->setTotal($total)->setDetails($details);
// Transaction
$transaction->setAmount($amount)->setDescription('Membership');
// Payment
$payment->setIntent('sale')->setPayer($payer)->setTransactions([$transaction]);
// Redirect Urls
$redirectUrls->setReturnUrl('http://localhost/pp/paypal/pay.php?approved=true')->setCancelUrl('http://localhost/pp/paypal/pay.php?approved=false');
$payment->setRedirectUrls($redirectUrls);
try {
$payment->create($api);
$hash = md5($payment->getId());
$_SESSION['paypal_hash'] = $hash;
$store = $db->prepare("\n\t\tINSERT INTO transactions_paypal (user_id, payment_id, hash, complete)\n\t\tVALUES (:user_id, :payment_id, :hash, 0)\n\t");
$store->execute(['user_id' => $_SESSION['user_id'], 'payment_id' => $payment->getId(), 'hash' => $hash]);