getShipping() public method

Amount charged for shipping. 10 characters max with support for 2 decimal places.
public getShipping ( ) : string
return string
Example #1
0
 /**
  * @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");
 }
Example #2
0
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]);