本文整理汇总了PHP中PayPal\Api\Details::setTax方法的典型用法代码示例。如果您正苦于以下问题:PHP Details::setTax方法的具体用法?PHP Details::setTax怎么用?PHP Details::setTax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Details
的用法示例。
在下文中一共展示了Details::setTax方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDetails
/**
* @param float $shippingPrice
* @param float $taxPrice
* @param float $subtotal
*
* @return Details
*/
public static function createDetails($shippingPrice, $taxPrice, $subtotal)
{
$details = new Details();
$details->setShipping($shippingPrice);
$details->setTax($taxPrice);
$details->setSubtotal($subtotal);
return $details;
}
示例2: createAmountDetails
public static function createAmountDetails()
{
$amountDetails = new Details();
$amountDetails->setSubtotal(self::$subtotal);
$amountDetails->setTax(self::$tax);
$amountDetails->setShipping(self::$shipping);
$amountDetails->setFee(self::$fee);
return $amountDetails;
}
示例3: array
function get_approvalurl()
{
try {
// try a payment request
$PaymentData = AngellEYE_Gateway_Paypal::calculate(null, $this->send_items);
$OrderItems = array();
if ($this->send_items) {
foreach ($PaymentData['order_items'] as $item) {
$_item = new Item();
$_item->setName($item['name'])->setCurrency(get_woocommerce_currency())->setQuantity($item['qty'])->setPrice($item['amt']);
array_push($OrderItems, $_item);
}
}
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(add_query_arg(array('pp_action' => 'executepay'), home_url()));
$redirectUrls->setCancelUrl($this->cancel_url);
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$details = new Details();
if (isset($PaymentData['shippingamt'])) {
$details->setShipping($PaymentData['shippingamt']);
}
if (isset($PaymentData['taxamt'])) {
$details->setTax($PaymentData['taxamt']);
}
$details->setSubtotal($PaymentData['itemamt']);
$amount = new Amount();
$amount->setCurrency(PP_CURRENCY);
$amount->setTotal(WC()->cart->total);
$amount->setDetails($details);
$items = new ItemList();
$items->setItems($OrderItems);
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('');
$transaction->setItemList($items);
//$transaction->setInvoiceNumber($this->invoice_prefix.$order_id);
$payment = new Payment();
$payment->setRedirectUrls($redirectUrls);
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->create($this->getAuth());
$this->add_log(print_r($payment, true));
//if payment method was PayPal, we need to redirect user to PayPal approval URL
if ($payment->state == "created" && $payment->payer->payment_method == "paypal") {
WC()->session->paymentId = $payment->id;
//set payment id for later use, we need this to execute payment
return $payment->links[1]->href;
}
} catch (PayPal\Exception\PayPalConnectionException $ex) {
wc_add_notice(__("Error processing checkout. Please try again. ", 'woocommerce'), 'error');
$this->add_log($ex->getData());
} catch (Exception $ex) {
wc_add_notice(__('Error processing checkout. Please try again. ', 'woocommerce'), 'error');
$this->add_log($ex->getMessage());
}
}
示例4: createDetails
/**
* Creates PayPal payment details from given order
*
* @param OrderInterface $order
*
* @return Details
*/
protected function createDetails(OrderInterface $order) : Details
{
$details = new Details();
$details->setShipping($order->getShippingTotal()->getNetAmount());
$details->setTax($order->getOrderTotal()->getTaxAmount());
$details->setSubtotal($order->getProductTotal()->getNetAmount());
return $details;
}
示例5: CreatePayment
public function CreatePayment($items = false, $data = false)
{
$apiContext = $this->getApiContext();
#die(print_r($data));
// ### 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");
// ### Itemized information
// (Optional) Lets you specify item wise
// information
$cart = array();
$total = 0;
/*foreach($items as $item)
{
$itemC = new Item();
$itemC->setName($item->name)
->setCurrency('EUR')
->setQuantity($item->items)
->setSku($item->code ? $item->code : $item->id)
->setPrice(round($item->cost,2));
$cart[] = $itemC;
$total += $item->items * $item->cost;
}
$itemList = new ItemList();
$itemList->setItems($cart);*/
// ### Additional payment details
// Use this optional field to set additional
// payment information such as tax, shipping
// charges etc.
$details = new Details();
$details->setTax(round($data->tax, 2))->setSubtotal(round($data->subtotal, 2));
// ### Amount
// Lets you specify a payment amount.
// You can also specify additional details
// such as shipping, tax.
$amount = new Amount();
$amount->setCurrency("EUR")->setTotal(round($data->total, 2))->setDetails($details);
// ### Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it.
$transaction = new Transaction();
$transaction->setAmount($amount)->setDescription("Compra actual - " . round($data->total, 2) . " EUR")->setInvoiceNumber(uniqid());
// ### Redirect urls
// Set the urls that the buyer must be redirected to after
// payment approval/ cancellation.
$baseUrl = base_url();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("{$baseUrl}cart/paypal?success=true")->setCancelUrl("{$baseUrl}cart/paypal-ko");
// ### 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(array($transaction));
// ### Create Payment
// Create a payment by calling the 'create' method
// passing it a valid apiContext.
// (See bootstrap.php for more on `ApiContext`)
// The return object contains the state and the
// url to which the buyer must be redirected to
// for payment approval
try {
$payment->create($apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
die(print_r($ex->getData()));
exit(1);
}
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $payment->getApprovalLink()
// method
$approvalUrl = $payment->getApprovalLink();
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
redirect($approvalUrl);
return $payment;
}
示例6: success
public function success()
{
$paymentId = request('paymentId');
$payment = Payment::get($paymentId, $this->paypal);
$execution = new PaymentExecution();
$execution->setPayerId(request('PayerID'));
$transaction = new Transaction();
$amount = new Amount();
$details = new Details();
$productsSum = 0.0;
foreach ($this->order->getProducts() as $product) {
$productsSum += $product->getTotal();
}
$details->setSubtotal($productsSum);
$total = $productsSum;
if ($delivery = $this->order->getDelivery()) {
$details->setShipping($delivery);
$total += $delivery;
}
if ($vat = $this->order->getVat()) {
$details->setTax($vat);
$total += $vat;
}
$amount->setCurrency($this->order->getCurrency())->setTotal($total)->setDetails($details);
$transaction->setAmount($amount);
$execution->addTransaction($transaction);
try {
$payment->execute($execution, $this->paypal);
} catch (\Exception $e) {
$this->log($e);
throw $e;
} finally {
Payment::get($paymentId, $this->paypal);
}
}
示例7: teszt
//.........这里部分代码省略.........
// ->setNumber("4417119669820331")
// ->setExpireMonth("11")
// ->setExpireYear("2019")
// ->setCvv2("012")
// ->setFirstName("Joe")
// ->setLastName("Shopper");
// try {
// $creditCard->create($apiContext);
// echo '<pre>';
// print_r($creditCard);
// }
// catch (\PayPal\Exception\PayPalConnectionException $ex) {
// echo $ex;
// }
//END SAMPLE 2
//SAMPLE 3
$payer = new Payer();
$payer->setPaymentMethod("paypal");
// ### Itemized information
// (Optional) Lets you specify item wise
// information
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
// ### Additional payment details
// Use this optional field to set additional
// payment information such as tax, shipping
// charges etc.
/* $details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50); */
// ### Amount
// Lets you specify a payment amount.
// You can also specify additional details
// such as shipping, tax.
/* $amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20)
->setDetails($details); */
// ### Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it.
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description");
// ->setInvoiceNumber('134');
//>setInvoiceNumber(uniqid());
// ### Redirect urls
// Set the urls that the buyer must be redirected to after
// payment approval/ cancellation.
//$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/ordered")->setCancelUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/index");
// ### 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(array($transaction)); */
$addr = new Address();
示例8: payDemo
public function payDemo()
{
$addr = new Address();
$addr->setLine1('52 N Main ST');
$addr->setCity('Johnstown');
$addr->setCountryCode('US');
$addr->setPostalCode('43210');
$addr->setState('OH');
$card = new CreditCard();
$card->setNumber('4417119669820331');
$card->setType('visa');
$card->setExpireMonth('11');
$card->setExpireYear('2018');
$card->setCvv2('874');
$card->setFirstName('Joe');
$card->setLastName('Shopper');
$card->setBillingAddress($addr);
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod('credit_card');
$payer->setFundingInstruments(array($fi));
$amountDetails = new Details();
$amountDetails->setSubtotal('15.99');
$amountDetails->setTax('0.03');
$amountDetails->setShipping('0.03');
$amount = new Amount();
$amount->setCurrency('USD');
$amount->setTotal('7.47');
$amount->setDetails($amountDetails);
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('This is the payment transaction description.');
$payment = new Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
return $payment->create($this->_apiContext);
}
示例9: makePaymentUsingPayPal
/**
* Create a payment using the buyer's paypal
* account as the funding instrument. Your app
* will have to redirect the buyer to the paypal
* website, obtain their consent to the payment
* and subsequently execute the payment using
* the execute API call.
*
* @param string $total payment amount in DDD.DD format
* @param string $currency 3 letter ISO currency code such as 'USD'
* @param string $paymentDesc A description about the payment
* @param string $returnUrl The url to which the buyer must be redirected
* to on successful completion of payment
* @param string $cancelUrl The url to which the buyer must be redirected
* to if the payment is cancelled
* @return \PayPal\Api\Payment
*/
function makePaymentUsingPayPal($sku, $returnUrl, $cancelUrl)
{
/*
$payer = new Payer();
$payer->setPaymentMethod("paypal");
// Specify the payment amount.
$amount = new Amount();
$amount->setCurrency($currency);
$amount->setTotal($total);
// ###Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it. Transaction is created with
// a `Payee` and `Amount` types
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription($paymentDesc);
*/
$payer = new Payer();
$payer->setPaymentMethod("paypal");
// ### Itemized information
// (Optional) Lets you specify item wise
// information
$item1 = new Item();
$item1->setName($GLOBALS['PAY_NAME'])->setCurrency(PAYPAL_CURRENCY_EUR)->setQuantity(1)->setPrice($GLOBALS['PAY_PRICE'])->setSku(llenaEspaciosPaypal($sku, 11, '0'));
$itemList = new ItemList();
$itemList->setItems(array($item1));
// ### Additional payment details
// Use this optional field to set additional
// payment information such as tax, shipping
// charges etc.
$details = new Details();
$details->setTax($GLOBALS['PAY_TAX'])->setSubtotal($GLOBALS['PAY_TOTAL_AMOUNT']);
// ### Amount
// Lets you specify a payment amount.
// You can also specify additional details
// such as shipping, tax.
$amount = new Amount();
$amount->setCurrency(PAYPAL_CURRENCY_EUR)->setTotal($GLOBALS['PAY_PRICE'])->setDetails($details);
// ### Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it.
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription($GLOBALS['PAY_DESCRIPTION']);
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($returnUrl);
$redirectUrls->setCancelUrl($cancelUrl);
$payment = new Payment();
$payment->setRedirectUrls($redirectUrls);
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->create(getApiContext());
return $payment;
}
示例10: createPayment
public function createPayment($addressee, $order)
{
// Order Totals
$subTotal = $order->total;
$shippingCharges = $order->shipping;
$tax = $order->tax;
$grandTotal = $order->grandTotal;
// Get Context
$context = $this->getApiContext();
// Payer
$payer = new Payer();
$payer->setPaymentMethod('paypal');
// Cart Items
$itemList = $this->generateItemsList($order);
// Shipping Address
if ($this->properties->isSendAddress()) {
$shippingAddress = $this->generateShippingAddress($addressee, $cart);
$itemList->setShippingAddress($shippingAddress);
}
// Details
$details = new Details();
$details->setSubtotal($subTotal);
$details->setShipping($shippingCharges);
$details->setTax($tax);
// Amount
$amount = new Amount();
$amount->setCurrency($this->properties->getCurrency());
$amount->setTotal($grandTotal);
$amount->setDetails($details);
// Transaction
$transaction = new Transaction();
$transaction->setAmount($amount);
if (isset($order->description)) {
$transaction->setDescription($order->description);
}
$transaction->setItemList($itemList);
// Status URLs
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($this->successUrl);
$redirectUrls->setCancelUrl($this->failureUrl);
// Payment
$payment = new Payment();
$payment->setRedirectUrls($redirectUrls);
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions([$transaction]);
$payment->create($context);
return $payment;
}
示例11: createDetails
private function createDetails(OrderInterface $order) : Details
{
$shippingCosts = $order->getModifier('shipping_cost');
$details = new Details();
$details->setShipping($shippingCosts->getNetAmount());
$details->setTax($order->getSummary()->getTaxAmount());
$details->setSubtotal($order->getProductTotal()->getNetPrice());
return $details;
}
示例12: setPaypalDetails
public function setPaypalDetails($shipping, $tax, $subtotal)
{
$subtotal = number_format($subtotal, 2);
$shipping = number_format($shipping, 2);
$tax = number_format($tax, 2);
$details = new Details();
$details->setSubtotal($subtotal);
$details->setShipping($shipping);
$details->setTax($tax);
return $details;
}