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


PHP Details::setShipping方法代码示例

本文整理汇总了PHP中PayPal\Api\Details::setShipping方法的典型用法代码示例。如果您正苦于以下问题:PHP Details::setShipping方法的具体用法?PHP Details::setShipping怎么用?PHP Details::setShipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPal\Api\Details的用法示例。


在下文中一共展示了Details::setShipping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test

function test()
{
    global $apiContext;
    // IncludeConfig('paypal/bootstrap.php');
    $payer = new Payer();
    $payer->setPaymentMethod("paypal");
    $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));
    $details = new Details();
    $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
    $amount = new Amount();
    $amount->setCurrency("USD")->setTotal(20)->setDetails($details);
    $transaction = new Transaction();
    $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
    $baseUrl = getBaseUrl();
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl("{$baseUrl}/donate.php/execute_payment_test?success=true")->setCancelUrl("{$baseUrl}/donate.php/execute_payment_test?success=false");
    $payment = new Payment();
    $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
    $request = clone $payment;
    try {
        $payment->create($apiContext);
    } catch (Exception $ex) {
        ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
        exit(1);
    }
    $approvalUrl = $payment->getApprovalLink();
    ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment);
    return $payment;
}
开发者ID:kayecandy,项目名称:secudev,代码行数:34,代码来源:donate.php

示例2: startPayment

 /**
  * @return Payment
  * @throws CheckoutException
  */
 public function startPayment()
 {
     $total_amount = ($this->request->amount + $this->request->tax_amount - $this->request->discount_amount) * 100;
     $apiContext->setConfig(array('service.EndPoint' => "https://test-api.sandbox.paypal.com"));
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item1 = new Item();
     $item1->setName('Product1')->setCurrency('EUR')->setPrice(10.0)->setQuantity(2)->setTax(3.0);
     $itemList = new ItemList();
     $itemList->setItems(array($item1));
     $details = new Details();
     $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
     $amount = new Amount();
     $amount->setCurrency('EUR')->setTotal(20)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription('Payment')->setInvoiceNumber('transactionid');
     $baseUrl = getBaseUrl();
     $redir = new RedirectUrls();
     $redir->setReturnUrl($baseUrl . '/');
     $redir->setCancelUrl($baseUrl . '/');
     $payment = new Payment();
     $payment->setIntent('sale')->setPayer($payer)->setRedirectUrls($redir)->setTransactions(array($transaction));
     $request = clone $payment;
     try {
         $payment->create($apiContext);
     } catch (\Exception $e) {
         throw new CheckoutException('Paypal error', 500, $e);
     }
     $approvalUrl = $payment->getApprovalLink();
     ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment);
     return $payment;
 }
开发者ID:kiberzauras,项目名称:laravel.checkout,代码行数:36,代码来源:PayPalGateway.php

示例3: credit_card

 public function credit_card()
 {
     return "Hello?";
     $card = new CreditCard();
     $card->setType("visa")->setNumber("4148529247832259")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper");
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
     $item1 = new Item();
     $item1->setName('Ground Coffee 40 oz')->setDescription('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setTax(0.3)->setPrice(7.5);
     $item2 = new Item();
     $item2->setName('Granola bars')->setDescription('Granola Bars with Peanuts')->setCurrency('USD')->setQuantity(5)->setTax(0.2)->setPrice(2);
     $itemList = new ItemList();
     $itemList->setItems(array($item1, $item2));
     $details = new Details();
     $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
     $amount = new Amount();
     $amount->setCurrency("USD")->setTotal(20)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
     $payment = new Payment();
     $payment->setIntent("sale")->setPayer($payer)->setTransactions(array($transaction));
     $request = clone $payment;
     try {
         $payment->create($apiContext);
     } catch (Exception $ex) {
         ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
         exit(1);
     }
     ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment);
     return $payment;
 }
开发者ID:2ppaamm,项目名称:kudotsu,代码行数:33,代码来源:PaypalController.php

示例4: 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

示例5: 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

示例6: postBuy

 public function postBuy(Request $request)
 {
     $data = $request->all();
     $customer = $this->customer->getByToken();
     $shopping_cart = $this->cart->getByToken();
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $paypal_items = [];
     $total = 0;
     foreach ($shopping_cart->shopping_cart_products as $shopping_cart_product) {
         $item = new Item();
         $item->setName($shopping_cart_product->product_collection_name . " // " . $shopping_cart_product->product_variant_name . " // " . $shopping_cart_product->product_color_name)->setCurrency(config('shop.default_currency'))->setQuantity($shopping_cart_product->quantity)->setPrice($shopping_cart_product->price_brut / 100);
         array_push($paypal_items, $item);
         $total += $shopping_cart_product->price_brut / 100 * $shopping_cart_product->quantity;
     }
     $subtotal = $total;
     $total += config('shop.default_shipping_cost') / 100;
     $item_list = new ItemList();
     $item_list->setItems($paypal_items);
     $details = new Details();
     $details->setShipping(config('shop.default_shipping_cost') / 100)->setSubtotal($subtotal);
     $amount = new Amount();
     $amount->setCurrency(config('shop.default_currency'))->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Einkauf bei ZWEI :: Taschen');
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl(url(config('app.locale') . '/paypal/thankyou'))->setCancelUrl(url(config('app.locale') . '/paypal/cancellation'));
     $payment = new Payment();
     $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
     try {
         $payment->create($this->_api_context);
     } catch (\PayPal\Exception\PPConnectionException $ex) {
         if (config('app.debug')) {
             echo "Exception: " . $ex->getMessage() . PHP_EOL;
             $err_data = json_decode($ex->getData(), true);
             exit;
         } else {
             die(trans('shop.some_error_occurred'));
         }
     }
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirect_url = $link->getHref();
             break;
         }
     }
     $this->cart->update(['id' => $shopping_cart->id, 'paypal_payment_id' => $payment->getId(), 'remarks' => $data['remarks'], 'customer_id' => $customer->id]);
     if (isset($redirect_url)) {
         return redirect($redirect_url);
     }
     return redirect()->route(config('app.locale') . '/feedback/paypal-error')->with('error', trans('shop.some_error_occurred'));
 }
开发者ID:manogi,项目名称:gfw-qm,代码行数:52,代码来源:PaypalController.php

示例7: create_payment

 /**
  * Cria o pagamento Paypal: passos 2/3
  *
  * @access	public
  * @param	
  * @return	error string
  */
 public function create_payment($items_array, $details_array)
 {
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     // define os items
     $i = 0;
     foreach ($items_array as $item) {
         $items[$i] = new Item();
         $items[$i]->setName($item['name'])->setCurrency(PAYPAL_CURRENCY)->setQuantity($item['quantity'])->setPrice($item['price']);
         $i++;
     }
     $itemList = new ItemList();
     $itemList->setItems($items);
     // Define os totais
     $details = new Details();
     $details->setShipping($details_array['shipping'])->setTax($details_array['tax'])->setSubtotal($details_array['subtotal']);
     // Define a quantidade
     $amount = new Amount();
     $amount->setCurrency(PAYPAL_CURRENCY)->setTotal($details_array['total'])->setDetails($details);
     // cria a transação
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription("");
     // cria o URL
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl(SITE_PATH . "success.php")->setCancelUrl(SITE_PATH . "cart.php");
     // cria o pagamento
     $payment = new Payment();
     $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
     try {
         $payment->create($this->api_context);
     } catch (PayPal\Exception\PPConnectionException $ex) {
         return $ex->getMessage();
     }
     // busca o URL de redirecionamento
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirectUrl = $link->getHref();
             break;
         }
     }
     // redireciona
     $_SESSION['payment_id'] = $payment->getId();
     if (isset($redirectUrl)) {
         header("Location: {$redirectUrl}");
         exit;
     }
 }
开发者ID:Hova10,项目名称:novosite,代码行数:54,代码来源:m_payments.php

示例8: onCharge

 /**
  * Called by shop to charge order's amount.
  *
  * @param Cart $cart Cart.
  *
  * @return bool
  */
 public function onCharge($order)
 {
     $this->statusCode = 'pending';
     // Begin paypal
     try {
         if ($order->total <= 0) {
             $this->statusCode = 'completed';
             $this->detail = 'Order total is 0; no PayPal transaction required.';
             $this->transactionId = uniqid();
             return true;
         }
         $this->setContext();
         $payer = new Payer();
         $payer->setPaymentMethod('paypal');
         $list = new ItemList();
         $list->setItems($this->toPayPalItems($order));
         $details = new Details();
         $details->setShipping($order->totalShipping)->setTax($order->totalTax)->setSubtotal($order->totalPrice);
         $amount = new Amount();
         $amount->setCurrency(Config::get('shop.currency'))->setTotal($order->total)->setDetails($details);
         $transaction = new Transaction();
         $transaction->setAmount($amount)->setItemList($list)->setDescription(sprintf('%s payment, Order #%d', Config::get('shop.name'), $order->id))->setInvoiceNumber($order->id);
         $redirectUrls = new RedirectUrls();
         $redirectUrls->setReturnUrl($this->callbackSuccess)->setCancelUrl($this->callbackFail);
         $payment = new Payment();
         $payment->setIntent('sale')->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions([$transaction]);
         //$request = clone $payment;
         $payment->create($this->apiContext);
         $this->approvalUrl = $payment->getApprovalLink();
         $this->detail = sprintf('Pending approval: %s', $this->approvalUrl);
         return true;
     } catch (PayPalConnectionException $e) {
         $response = json_decode($e->getData());
         throw new GatewayException(sprintf('%s: %s', $response->name, isset($response->message) ? $response->message : 'Paypal payment Failed.'), 1001, $e);
     } catch (\Exception $e) {
         throw new GatewayException($e->getMessage(), 1000, $e);
     }
     return false;
 }
开发者ID:webfactorybulgaria,项目名称:laravel-shop-gateway-paypal,代码行数:46,代码来源:GatewayPayPalExpress.php

示例9: process

 public function process($orderData, $cartProducts = [])
 {
     $this->setApiContext();
     $this->_apiContext->setConfig(['mode' => Configuration::getConfiguration('paypal_payment_mode'), 'service.EndPoint' => Configuration::getConfiguration('paypal_payment_url'), 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => Configuration::getConfiguration('paypal_payment_log'), 'log.FileName' => storage_path('logs/paypal.log'), 'log.LogLevel' => 'FINE']);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $itemList = new ItemList();
     $subTotal = 0;
     $taxTotal = 0;
     foreach ($cartProducts as $product) {
         $item = new Item();
         $model = $product['model'];
         $item->setName($model->title)->setCurrency('USD')->setQuantity($product['qty'])->setSku($model->sku)->setPrice($product['price']);
         $itemList->addItem($item);
         $subTotal += $product['price'] * $product['qty'];
         $taxTotal += $product['tax_amount'] * $product['qty'];
     }
     $total = $subTotal + $taxTotal;
     $shippingOption = $orderData['shipping_method'];
     $shipping = Shipping::get($shippingOption);
     $details = new Details();
     $details->setShipping($shipping->getAmount())->setTax($taxTotal)->setSubtotal($subTotal);
     $amount = new Amount();
     $amount->setCurrency('USD')->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription('Payment description')->setInvoiceNumber(uniqid());
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl(route('paypal.store'));
     $redirectUrls->setCancelUrl(route('paypal.cancel'));
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions([$transaction]);
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     return $redirectUrl;
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:38,代码来源:Paypal.php

示例10: sendRequest

 public function sendRequest()
 {
     $details = new Details();
     $details->setShipping(0)->setTax(0)->setSubtotal($this->totalAmount);
     $amount = new Amount();
     $amount->setCurrency($this->currencyCode)->setTotal($this->totalAmount)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($this->itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
     $baseUrl = 'http://localhost/';
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl("{$baseUrl}/ExecutePayment.php?success=true")->setCancelUrl("{$baseUrl}/ExecutePayment.php?success=false");
     $payment = new Payment();
     $payment->setIntent("sale")->setPayer($this->payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
     try {
         $payment->create($this->apiContext);
     } catch (Exception $ex) {
         // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
         var_dump($ex);
         exit(1);
     }
     $approvalUrl = $payment->getApprovalLink();
     header('Location: ' . $approvalUrl);
     quit();
 }
开发者ID:bontiv,项目名称:intrateb,代码行数:24,代码来源:caddie_paie.php

示例11: Payer

use PayPal\Api\Payer;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setSku("123123")->setPrice(100);
$item2 = new Item();
$item2->setName('Granola bars')->setCurrency('USD')->setQuantity(1)->setSku("321321")->setPrice(100);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$details = new Details();
$details->setShipping(1.2)->setTax(1.3)->setSubtotal(200);
$fakeTotal = 200 + 1.2 + 1.3;
$amount = new Amount();
$amount->setCurrency("USD")->setTotal($fakeTotal)->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl('http://localhost:9090/member/executePayment.php?success=true')->setCancelUrl('http://localhost:9090/member/executePayment.php?success=false');
$payment = new Payment();
$payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
$request = clone $payment;
try {
    $payment->create($api);
    echo 'payment';
} catch (Exception $ex) {
    echo 'error';
开发者ID:vistajess,项目名称:playgroundz,代码行数:31,代码来源:payment2.php

示例12: postPayment

 public function postPayment()
 {
     $paypal_conf = Config::get('paypal');
     $apiContext = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
     $apiContext->setConfig($paypal_conf['settings']);
     $card = new CreditCard();
     $card->setType("visa")->setNumber("4148529247832259")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper");
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
     $item1 = new Item();
     $item1->setName('Ground Coffee 40 oz')->setDescription('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setTax(0.3)->setPrice(7.5);
     $item2 = new Item();
     $item2->setName('Granola bars')->setDescription('Granola Bars with Peanuts')->setCurrency('USD')->setQuantity(5)->setTax(0.2)->setPrice(2);
     $itemList = new ItemList();
     $itemList->setItems(array($item1, $item2));
     $details = new Details();
     $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
     $amount = new Amount();
     $amount->setCurrency("USD")->setTotal(20)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
     $payment = new Payment();
     $payment->setIntent("sale")->setPayer($payer)->setTransactions(array($transaction));
     try {
         $payment->create($apiContext);
     } catch (Exception $ex) {
         ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
         exit(1);
     }
     //ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment);
     var_dump($payment);
     echo "string";
     /*exit;
             $payer = new Payer();
             $payer->setPaymentMethod('paypal');
     
             $item_1 = new Item();
             $item_1->setName('Item 1') // item name
                 ->setCurrency('USD')
                 ->setQuantity(2)
                 ->setPrice('15'); // unit price
     
             $item_2 = new Item();
             $item_2->setName('Item 2')
                 ->setCurrency('USD')
                 ->setQuantity(4)
                 ->setPrice('7');
     
             $item_3 = new Item();
             $item_3->setName('Item 3')
                 ->setCurrency('USD')
                 ->setQuantity(1)
                 ->setPrice('20');
     
             // add item to list
             $item_list = new ItemList();
             $item_list->setItems(array($item_1, $item_2, $item_3));
     
             $amount = new Amount();
             $amount->setCurrency('USD')
                 ->setTotal(78);
     
             $transaction = new Transaction();
             $transaction->setAmount($amount)
                 ->setItemList($item_list)
                 ->setDescription('Your transaction description');
     
             $redirect_urls = new RedirectUrls();
             $redirect_urls->setReturnUrl(URL::route('payment.status'))
                 ->setCancelUrl(URL::route('payment.status'));
     
             $payment = new Payment();
             $payment->setIntent('Sale')
                 ->setPayer($payer)
                 ->setRedirectUrls($redirect_urls)
                 ->setTransactions(array($transaction));
     
             try {
                 $payment->create($this->_api_context);
             } catch (\PayPal\Exception\PPConnectionException $ex) {
                 if (\Config::get('app.debug')) {
                     echo "Exception: " . $ex->getMessage() . PHP_EOL;
                     $err_data = json_decode($ex->getData(), true);
                     exit;
                 } else {
                     die('Some error occur, sorry for inconvenient');
                 }
             }
     
             foreach($payment->getLinks() as $link) {
                 if($link->getRel() == 'approval_url') {
                     $redirect_url = $link->getHref();
                     break;
                 }
             }
     
             // add payment ID to session
             Session::put('paypal_payment_id', $payment->getId());
//.........这里部分代码省略.........
开发者ID:jmvarguez-web,项目名称:Proyecto_laravel,代码行数:101,代码来源:PaypalController.php

示例13: Payer

use PayPal\Api\Payer;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Exception\PPConnectionException;
require '../src/start.php';
$payer = new Payer();
$details = new Details();
$amount = new Amount();
$transaction = new Transaction();
$payment = new Payment();
$redirectUrls = new RedirectUrls();
$payer->setPaymentMethod('paypal');
$details->setShipping('2.00')->setTax('0.00')->setSubtotal('20.00');
$amount->setCurrency('GBP')->setTotal('22.00')->setDetails($details);
$transaction->setAmount($amount)->setDescription('Membership');
$payment->setIntent('sale')->setPayer($payer)->setTransactions([$transaction]);
$redirectUrls->setReturnUrl('http://localhost/paypal/paypal/pay.php?approved=true')->setCancelUrl('http://localhost/paypal/paypal/pay.php?approved=false');
$payment->setRedirectUrls($redirectUrls);
try {
    $payment->create($api);
    $hash = md5($payment->getId());
    // var_dump($hash); die();
    $_SESSION['paypal_hash'] = $hash;
    $store = $db->prepare("INSERT INTO transaction_paypal VALUES('',?,?,?,?)");
    $store->bindValue(1, $_SESSION['user_id'], PDO::PARAM_INT);
    $store->bindValue(2, $payment->getId(), PDO::PARAM_INT);
    $store->bindValue(3, $hash, PDO::PARAM_INT);
    $store->bindValue(4, 0, PDO::PARAM_INT);
开发者ID:alaaelgndy,项目名称:paypal,代码行数:31,代码来源:payment.php

示例14: onCharge

 /**
  * Called by shop to charge order's amount.
  *
  * @param Cart $cart Cart.
  *
  * @return bool
  */
 public function onCharge($order)
 {
     if (!isset($this->creditCard)) {
         throw new GatewayException('Credit Card is not set.', 0);
     }
     try {
         if ($order->total <= 0) {
             $this->detail = 'Order total is 0; no PayPal transaction required.';
             $this->transactionId = uniqid();
             return true;
         }
         $this->setContext();
         $instrument = new FundingInstrument();
         $instrument->setCreditCard($this->creditCard);
         $payer = new Payer();
         $payer->setPaymentMethod('credit_card')->setFundingInstruments([$instrument]);
         $list = new ItemList();
         $list->setItems($this->toPayPalItems($order));
         $details = new Details();
         $details->setShipping($order->totalShipping)->setTax($order->totalTax)->setSubtotal($order->totalPrice);
         $amount = new Amount();
         $amount->setCurrency(Config::get('shop.currency'))->setTotal($order->total)->setDetails($details);
         $transaction = new Transaction();
         $transaction->setAmount($amount)->setItemList($list)->setDescription(sprintf('%s payment, Order #%d', Config::get('shop.name'), $order->id))->setInvoiceNumber($order->id);
         $payment = new Payment();
         $payment->setIntent('sale')->setPayer($payer)->setTransactions([$transaction]);
         //$request = clone $payment;
         $payment->create($this->apiContext);
         $this->transactionId = $payment->id;
         $this->detail = 'Success';
         return true;
     } catch (PayPalConnectionException $e) {
         $response = json_decode($e->getData());
         throw new GatewayException(sprintf('%s: %s', $response->name, isset($response->message) ? $response->message : 'Paypal payment Failed.'), 1001, $e);
     } catch (\Exception $e) {
         throw new ShopException($e->getMessage(), 1000, $e);
     }
     return false;
 }
开发者ID:bengitiger,项目名称:laravel-shop-gateway-paypal,代码行数:46,代码来源:GatewayPayPal.php

示例15: 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


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