当前位置: 首页>>代码示例>>PHP>>正文


PHP Details::setTax方法代码示例

本文整理汇总了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;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:15,代码来源:TransactionHelper.php

示例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;
 }
开发者ID:johnmicahmiguel,项目名称:yodaphp,代码行数:9,代码来源:DetailsTest.php

示例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());
     }
 }
开发者ID:spirit1977,项目名称:paypal-woocommerce,代码行数:58,代码来源:wc-gateway-paypal-plus-angelleye.php

示例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;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:15,代码来源:AbstractPayPalProcessor.php

示例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;
 }
开发者ID:juanazareno,项目名称:ananagulo,代码行数:81,代码来源:paypalmodel.php

示例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);
     }
 }
开发者ID:schtr4jh,项目名称:payment,代码行数:35,代码来源:PaypalRest.php

示例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();
开发者ID:nishanthpininti,项目名称:nishanth-work-nudostilo,代码行数:67,代码来源:paypal.php

示例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);
 }
开发者ID:kongoon,项目名称:yii2-paypal,代码行数:39,代码来源:Paypal.php

示例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;
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:75,代码来源:paypal.php

示例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;
 }
开发者ID:cmsgears,项目名称:module-paypal-rest,代码行数:49,代码来源:PaypalRestService.php

示例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;
 }
开发者ID:WellCommerce,项目名称:PaymentBundle,代码行数:9,代码来源:PayPalGateway.php

示例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;
 }
开发者ID:cinghie,项目名称:yii2-paypal,代码行数:11,代码来源:Helper.php


注:本文中的PayPal\Api\Details::setTax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。