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


PHP Amount::setTotal方法代码示例

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


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

示例1: testOperations

 /**
  * @group integration
  */
 public function testOperations()
 {
     try {
         $authId = AuthorizationTest::authorize();
         $auth = Authorization::get($authId);
         $amount = new Amount();
         $amount->setCurrency("USD");
         $amount->setTotal("1.00");
         $captr = new Capture();
         $captr->setId($authId);
         $captr->setAmount($amount);
         $capt = $auth->capture($captr);
         $captureId = $capt->getId();
         $this->assertNotNull($captureId);
         $refund = new Refund();
         $refund->setId($captureId);
         $refund->setAmount($amount);
         $capture = Capture::get($captureId);
         $this->assertNotNull($capture->getId());
         $retund = $capture->refund($refund);
         $this->assertNotNull($retund->getId());
     } catch (PayPalConnectionException $ex) {
         $this->markTestSkipped('Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage());
     }
 }
开发者ID:johnmicahmiguel,项目名称:yodaphp,代码行数:28,代码来源:CaptureTest.php

示例2: init

 /**
  * @param PaymentInterface $payment
  */
 public function init(PaymentInterface $payment)
 {
     $credentials = new OAuthTokenCredential($this->options['client_id'], $this->options['secret']);
     $apiContext = new ApiContext($credentials);
     $apiContext->setConfig(['mode' => $this->options['mode']]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency($this->options['currency']);
     $amount->setTotal($payment->getPaymentSum());
     $item = new Item();
     $item->setName($payment->getDescription());
     $item->setCurrency($amount->getCurrency());
     $item->setQuantity(1);
     $item->setPrice($amount->getTotal());
     $itemList = new ItemList();
     $itemList->addItem($item);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($payment->getDescription());
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($payment->getExtraData('return_url'));
     $redirectUrls->setCancelUrl($payment->getExtraData('cancel_url'));
     $paypalPayment = new Payment();
     $paypalPayment->setIntent('sale');
     $paypalPayment->setPayer($payer);
     $paypalPayment->setTransactions([$transaction]);
     $paypalPayment->setRedirectUrls($redirectUrls);
     $paypalPayment->create($apiContext);
     $payment->setExtraData('paypal_payment_id', $paypalPayment->getId());
     $payment->setExtraData('approval_link', $paypalPayment->getApprovalLink());
 }
开发者ID:moriony,项目名称:payment-gateway,代码行数:36,代码来源:PayPalHandler.php

示例3: makePaymentUsingPayPal

 public function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl)
 {
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     // specify the payment ammount
     $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);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl . '&success=true');
     $redirectUrls->setCancelUrl($returnUrl . '&success=false');
     $payment = new Payment();
     $payment->setRedirectUrls($redirectUrls);
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     try {
         $payment->create($this->apiContext);
     } catch (Exception $e) {
         throw new Exception($e);
     }
     return $payment;
 }
开发者ID:alfchee,项目名称:PaypalTest,代码行数:31,代码来源:PaypalPayment.php

示例4: makePaymentUsingCC

/**
 * Create a payment using a previously obtained
 * credit card id. The corresponding credit
 * card is used as the funding instrument.
 * 
 * @param string $creditCardId credit card id
 * @param string $total Payment amount with 2 decimal points
 * @param string $currency 3 letter ISO code for currency
 * @param string $paymentDesc
 */
function makePaymentUsingCC($creditCardId, $total, $currency, $paymentDesc)
{
    $ccToken = new CreditCardToken();
    $ccToken->setCreditCardId($creditCardId);
    $fi = new FundingInstrument();
    $fi->setCreditCardToken($ccToken);
    $payer = new Payer();
    $payer->setPaymentMethod("credit_card");
    $payer->setFundingInstruments(array($fi));
    // 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);
    $payment = new Payment();
    $payment->setIntent("sale");
    $payment->setPayer($payer);
    $payment->setTransactions(array($transaction));
    $payment->create(getApiContext());
    return $payment;
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:38,代码来源:paypal.php

示例5: createAmount

 public static function createAmount()
 {
     $amount = new Amount();
     $amount->setCurrency(self::$currency);
     $amount->setTotal(self::$total);
     return $amount;
 }
开发者ID:mayoalexander,项目名称:fl-two,代码行数:7,代码来源:AmountTest.php

示例6: createAmount

 /**
  * @param string $currency
  * @param int $total
  * @param Details $details
  *
  * @return Amount
  */
 public static function createAmount(Details $details, $total, $currency)
 {
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($total);
     $amount->setDetails($details);
     return $amount;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:15,代码来源:TransactionHelper.php

示例7: createAmount

 /**
  * Creates an amount definition for given order
  *
  * @param OrderInterface $order
  *
  * @return Amount
  */
 protected function createAmount(OrderInterface $order) : Amount
 {
     $details = $this->createDetails($order);
     $amount = new Amount();
     $amount->setCurrency($order->getCurrency());
     $amount->setTotal($order->getOrderTotal()->getGrossAmount());
     $amount->setDetails($details);
     return $amount;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:16,代码来源:AbstractPayPalProcessor.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential('ATGFkB2ea6f0pM92jwBqkZ17kxsiftDvUhLHyXson-10AUs7n5TocpEc0sis7Cl_fMIxS8uQO04kPP8Q', 'ENP_JPkc3e4Yl6VeHZ_0vgvEh0SYdtzkMvw_VGBrr2nJ67sg9RuKB_YF7y_k4bj-4t2U-_23MaAGV3vD'));
     $status = '';
     if (isset($_GET['success']) && $_GET['success'] == 'true') {
         $transaction = new Transaction();
         $amount = new Amount();
         $paymentId = $_GET['paymentId'];
         $payment = Payment::get($paymentId, $apiContext);
         $amount->setCurrency($payment->transactions[0]->amount->getCurrency());
         $amount->setTotal($payment->transactions[0]->amount->getTotal());
         $amount->setDetails($payment->transactions[0]->amount->getDetails());
         $transaction->setAmount($amount);
         $execution = new PaymentExecution();
         $execution->setPayerId($_GET['PayerID']);
         $execution->addTransaction($transaction);
         $rifas = $payment->transactions[0]->description;
         $rifas = explode(',', $rifas);
         $aux = 0;
         try {
             foreach ($rifas as $rifa) {
                 $aux = Rifa::find($rifa);
                 if ($aux->user_id == NULL) {
                     $aux->user_id = Auth::user()->id;
                     $aux->save();
                 } else {
                     $status = 'Numeros de rifas ja foram escolhidos por outra pessoa, por favor escolha novamente.';
                     return view('confirmacao')->with('status', $status);
                 }
             }
             $result = $payment->execute($execution, $apiContext);
             try {
                 $payment = Payment::get($paymentId, $apiContext);
             } catch (Exception $ex) {
                 $status = 'Pagamento ainda sem confirmacao';
             }
         } catch (Exception $ex) {
             $status = 'Compra nao foi executada';
         }
         if ($result->state == "approved") {
             $status = 'Compra feita com sucesso!';
             $aux = 1;
         }
         return view('confirmacao')->with('status', $status)->with('aux', $aux);
     } else {
         $status = 'Compra cancelada pelo usuario';
         return view('confirmacao')->with('status', $status);
     }
 }
开发者ID:pedrohbraz,项目名称:rifasPando,代码行数:54,代码来源:ConfirmacaoController.php

示例9: paypal

 function paypal($data)
 {
     try {
         foreach ($data as $k => $v) {
             ${$k} = $v;
         }
         include_once 'config.paypal.php';
         $apiContext = new ApiContext(new OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET));
         list($m, $y) = explode("/", $card_expiry);
         $card = new CreditCard();
         $card->setNumber($card_number);
         $card->setType(strtolower($card_type));
         $card->setExpireMonth($m);
         $card->setExpireYear($y);
         $card->setCvv2($card_cvv);
         $card->setFirstName($first_name);
         $card->setLastName($last_name);
         $fi = new FundingInstrument();
         $fi->setCreditCard($card);
         $payer = new Payer();
         $payer->setPaymentMethod('credit_card');
         $payer->setFundingInstruments(array($fi));
         $amount = new Amount();
         $amount->setCurrency($currency);
         $amount->setTotal($price);
         $transaction = new Transaction();
         $transaction->setAmount($amount);
         $transaction->setDescription('Enter your card details and proceed');
         $payment = new Payment();
         $payment->setIntent('sale');
         $payment->setPayer($payer);
         $payment->setTransactions(array($transaction));
         $res = json_decode($payment->create($apiContext));
         $this->save($data, __FUNCTION__, $res, 1);
         return json_encode(["status" => true, "msg" => sprintf("Your payment has been %s", $res->state)]);
     } catch (Exception $e) {
         if ($e instanceof PPConfigurationException) {
         } elseif ($e instanceof PPConnectionException) {
         } elseif ($e instanceof PayPal\Exception\PayPalConnectionException) {
             $res = json_decode($e->getData(), 1);
             $this->save($data, __FUNCTION__, $res, 0);
             $msg = array_shift(isset($res["details"]) ? $res["details"] : []);
             return json_encode(["status" => false, "msg" => $res["name"] == "UNKNOWN_ERROR" || empty($msg["issue"]) ? "An unknown error has occurred" : sprintf("%s %s", ["cvv2" => "CVV2", "expire_year" => "Card expiration", "credit_card" => "", "type" => "Invalid credit card number or", "number" => "Credit card number", "expire_month" => "Expiration month"][end(explode(".", $msg["field"]))], strtolower($msg["issue"]))]);
         } else {
             throw $e;
         }
     }
 }
开发者ID:aliuadepoju,项目名称:hqpay,代码行数:48,代码来源:Gateway.php

示例10: getTransactions

 /**
  * @return array array of PayPal\Api\Transaction
  */
 protected function getTransactions()
 {
     $payPalItems = array();
     $currency = $this->currency ? $this->currency : $this->context->getCurrency();
     $payPalItem = new Item();
     $payPalItem->setName($this->name);
     $payPalItem->setCurrency($currency);
     $payPalItem->setQuantity($this->quantity);
     $payPalItem->setPrice($this->price);
     $payPalItems[] = $payPalItem;
     $totalPrice = $this->quantity * $this->price;
     $itemLists = new ItemList();
     $itemLists->setItems($payPalItems);
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($totalPrice);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setItemList($itemLists);
     return array($transaction);
 }
开发者ID:metisfw,项目名称:paypal,代码行数:24,代码来源:SimplePaymentOperation.php

示例11: testOperations

 public function testOperations()
 {
     $authId = AuthorizationTest::authorize();
     $auth = Authorization::get($authId);
     $amount = new Amount();
     $amount->setCurrency("USD");
     $amount->setTotal("1.00");
     $captr = new Capture();
     $captr->setId($authId);
     $captr->setAmount($amount);
     $capt = $auth->capture($captr);
     $captureId = $capt->getId();
     $this->assertNotNull($captureId);
     $refund = new Refund();
     $refund->setId($captureId);
     $refund->setAmount($amount);
     $capture = Capture::get($captureId);
     $this->assertNotNull($capture->getId());
     $retund = $capture->refund($refund);
     $this->assertNotNull($retund->getId());
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:21,代码来源:CaptureTest.php

示例12: get_payment_url

 /**
  * When you have configured the payment properly this will give you a URL that you can redirect your visitor to,
  * so that he can pay the desired amount.
  *
  * @param string $url_format
  * @return string
  */
 public function get_payment_url($url_format)
 {
     if (!is_array($this->payment_provider_auth_config[self::PROVIDER_NAME]) || !isset($this->payment_provider_auth_config[self::PROVIDER_NAME]['clientid']) || !isset($this->payment_provider_auth_config[self::PROVIDER_NAME]['secret'])) {
         throw new \Exception('Auth Config for Provider ' . self::PROVIDER_NAME . ' is not set.', 1394795187);
     }
     $total_price = $this->order->get_total_price();
     if ($total_price == 0) {
         throw new \Exception('Total price is 0. Provider ' . self::PROVIDER_NAME . ' does not support free payments.', 1394795478);
     }
     $api_context = new ApiContext(new OAuthTokenCredential($this->payment_provider_auth_config[self::PROVIDER_NAME]['clientid'], $this->payment_provider_auth_config[self::PROVIDER_NAME]['secret']));
     $api_context->setConfig(array('mode' => 'sandbox', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => false));
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     $amount = new Amount();
     $amount->setCurrency("EUR");
     $amount->setTotal($this->order->get_total_price());
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($this->order->get_reason());
     $transaction->setItemList($this->getItemList());
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($this->get_success_url($url_format));
     $redirectUrls->setCancelUrl($this->get_abort_url($url_format));
     $payment = new \PayPal\Api\Payment();
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     $payment->create($api_context);
     $payment_url = '';
     foreach ($payment->getLinks() as $link) {
         /** @var \PayPal\Api\Links $link */
         if ($link->getRel() == 'approval_url') {
             $payment_url = $link->getHref();
         }
     }
     return $payment_url;
 }
开发者ID:app-zap,项目名称:payment,代码行数:45,代码来源:Paypal.php

示例13: createAuthorization

function createAuthorization($apiContext)
{
    $addr = new Address();
    $addr->setLine1("3909 Witmer Road");
    $addr->setLine2("Niagara Falls");
    $addr->setCity("Niagara Falls");
    $addr->setState("NY");
    $addr->setPostal_code("14305");
    $addr->setCountry_code("US");
    $addr->setPhone("716-298-1822");
    $card = new CreditCard();
    $card->setType("visa");
    $card->setNumber("4417119669820331");
    $card->setExpire_month("11");
    $card->setExpire_year("2019");
    $card->setCvv2("012");
    $card->setFirst_name("Joe");
    $card->setLast_name("Shopper");
    $card->setBilling_address($addr);
    $fi = new FundingInstrument();
    $fi->setCredit_card($card);
    $payer = new Payer();
    $payer->setPayment_method("credit_card");
    $payer->setFunding_instruments(array($fi));
    $amount = new Amount();
    $amount->setCurrency("USD");
    $amount->setTotal("1.00");
    $transaction = new Transaction();
    $transaction->setAmount($amount);
    $transaction->setDescription("This is the payment description.");
    $payment = new Payment();
    $payment->setIntent("authorize");
    $payment->setPayer($payer);
    $payment->setTransactions(array($transaction));
    $paymnt = $payment->create($apiContext);
    $resArray = $paymnt->toArray();
    return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
}
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:38,代码来源:VoidAuthorization.php

示例14: callCreate

 public function callCreate($clientId, $clientSecret, $orderId, $amount, $currency, $description, $returnUrl, $cancelUrl)
 {
     $oauthCredential = new OAuthTokenCredential($clientId, $clientSecret);
     $apiContext = new ApiContext($oauthCredential);
     $apiContext->setConfig(['mode' => $this->mode]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item = new Item();
     $item->setName($description);
     $item->setCurrency($currency);
     $item->setPrice($amount);
     $item->setQuantity(1);
     $itemList = new ItemList();
     $itemList->setItems(array($item));
     $amountObject = new Amount();
     $amountObject->setCurrency($currency);
     $amountObject->setTotal($amount);
     $transaction = new Transaction();
     $transaction->setItemList($itemList);
     $transaction->setAmount($amountObject);
     $transaction->setDescription($description);
     $transaction->setInvoiceNumber($orderId);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl);
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     try {
         $payment->create($apiContext);
     } catch (\Exception $e) {
         throw new PaymentException('PayPal Exception: ' . $e->getMessage());
     }
     $approvalUrl = $payment->getApprovalLink();
     return $approvalUrl;
 }
开发者ID:luyadev,项目名称:luya-module-payment,代码行数:37,代码来源:PayPalProvider.php

示例15: payPaypal

 /**
  * Runs a payment with PayPal
  *
  * @link https://devtools-paypal.com/guide/pay_paypal/php?interactive=ON&env=sandbox
  * @return PayPal\Api\Payment 
  */
 public function payPaypal($urls = [], $sum = 0, $message = '')
 {
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency($this->currency);
     $amount->setTotal($sum);
     $transaction = new Transaction();
     if ($message) {
         $transaction->setDescription($message);
     }
     $transaction->setAmount($amount);
     $redirectUrls = new RedirectUrls();
     $return_url = isset($urls['return_url']) ? $urls['return_url'] : 'https://devtools-paypal.com/guide/pay_paypal/php?success=true';
     $cancel_url = isset($urls['cancel_url']) ? $urls['cancel_url'] : 'https://devtools-paypal.com/guide/pay_paypal/php?success=true';
     $redirectUrls->setReturnUrl($return_url);
     $redirectUrls->setCancelUrl($cancel_url);
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions([$transaction]);
     return $payment->create($this->_apiContext);
     // get approval url from this json
 }
开发者ID:shinomontaz,项目名称:yii2-paypal,代码行数:31,代码来源:Paypal.php


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