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


PHP Details::getShipping方法代碼示例

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


在下文中一共展示了Details::getShipping方法的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");
 }
開發者ID:fengyeno,項目名稱:fille,代碼行數:15,代碼來源:DetailsTest.php

示例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]);
開發者ID:Nayami,項目名稱:ppal_training,代碼行數:31,代碼來源:payment.php


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