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


PHP RedirectUrls::setCancel_url方法代码示例

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


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

示例1: testValidRedirectUrls

 /**
  * @dataProvider validRedirectUrlsProvider
  */
 public function testValidRedirectUrls($return_url, $cancel_url)
 {
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturn_url($return_url);
     $redirectUrls->setCancel_url($cancel_url);
     $this->assertEquals($return_url, $redirectUrls->getReturnUrl());
     $this->assertEquals($cancel_url, $redirectUrls->getCancelUrl());
 }
开发者ID:adiktus9116,项目名称:rest-api-sdk-php,代码行数:11,代码来源:RedirectUrlsTest.php

示例2: createNewPayment

 public static function createNewPayment()
 {
     $payer = new Payer();
     $payer->setPayment_method("credit_card");
     $payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument()));
     $transaction = new Transaction();
     $transaction->setAmount(AmountTest::createAmount());
     $transaction->setDescription("This is the payment description.");
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturn_url("http://localhost/return");
     $redirectUrls->setCancel_url("http://localhost/cancel");
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setRedirect_urls($redirectUrls);
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:mayoalexander,项目名称:fl-two,代码行数:18,代码来源:PaymentTest.php

示例3: createPayment

 public function createPayment($orderid, $userid)
 {
     if ($orderid > 0) {
         $orderid = (int) $orderid;
         $paypalCredentials = $this->getPaypalCredentials();
         $apiContext = new ApiContext(new OAuthTokenCredential($paypalCredentials["clientid"], $paypalCredentials["secret"]));
         $apiContext->setConfig($this->paypalConfig);
         $payer = new Payer();
         $payer->setPayment_method("paypal");
         $order = new Orders();
         $orderdetail = $order->getOrderDetail($orderid);
         //Setting up items for the paypal order detail
         //On future version this will have multiple packages based on cart content
         //When items were added api were responding abnormal
         /*
         $item = new Item();
         $item->setName($orderdetail["title"]);
         $item->setCurrency($orderdetail["currency"]);
         $item->setQuantity($orderdetail["quantity"]);
         $item->setPrice($orderdetail["package_price"]);
         $item->setSku($orderdetail["package_guid"]);
         $itemList = new ItemList();
         $itemList->setItems(array($item));
         */
         $amount = new Amount();
         $amount->setCurrency($orderdetail["currency"]);
         $amount->setTotal($orderdetail["total"]);
         $orderDescription = "Qty: " . $orderdetail["quantity"] . " for " . $orderdetail["title"] . " - " . $orderdetail["title_summary"];
         $transaction = new Transaction();
         $transaction->setDescription($orderDescription);
         $transaction->setAmount($amount);
         //$transaction->setItemlist($itemList);
         $redirectUrls = new RedirectUrls();
         $humanorderid = $order->getHumanOrderId($orderid);
         $redirectUrls->setReturn_url($paypalCredentials["returnurl"] . "&orderid=" . $humanorderid);
         $redirectUrls->setCancel_url($paypalCredentials["cancelurl"] . "&orderid=" . $humanorderid);
         $payment = new Payment();
         $payment->setIntent("sale");
         $payment->setPayer($payer);
         $payment->setRedirect_urls($redirectUrls);
         $payment->setTransactions(array($transaction));
         try {
             $payment->create($apiContext);
             $this->setPaypalInfoOrder($orderid, $payment->getId(), $payment->getCreateTime(), $payment->getUpdateTime(), $payment->getState(), $userid);
             // Retrieve buyer approval url from the `payment` object.
             foreach ($payment->getLinks() as $link) {
                 if ($link->getRel() == 'approval_url') {
                     $approvalUrl = $link->getHref();
                 }
             }
             $result = array("status" => true, "approval_url" => $approvalUrl);
             return $result;
         } catch (PayPal\Exception\PPConnectionException $ex) {
             //Logging error
             $this->log->addError($ex->getMessage() . LOG_LINESEPARATOR . "TRACE: " . $ex->getTraceAsString() . LOG_LINESEPARATOR);
             $result = array("status" => false, "approval_url" => "");
             return $result;
         }
     } else {
         //Logging error
         $this->log->addWarning("Invalid or null order id." . LOG_LINESEPARATOR);
         $result = array("status" => false, "approval_url" => "");
         return $result;
     }
 }
开发者ID:wangshipeng,项目名称:license_manager,代码行数:65,代码来源:payments.php

示例4: Transaction

$amount->setTotal("1.00");
// ### 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("This is the payment description.");
// ### Redirect urls
// Set the urls that the buyer must be redirected to after
// payment approval/ cancellation.
$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturn_url("{$baseUrl}/ExecutePayment.php?success=true");
$redirectUrls->setCancel_url("{$baseUrl}/ExecutePayment.php?success=false");
// ### Payment
// A Payment Resource; create one using
// the above types and intent as 'sale'
$payment = new Payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setRedirect_urls($redirectUrls);
$payment->setTransactions(array($transaction));
// ### Api Context
// Pass in a `ApiContext` object to authenticate
// the call and to send a unique request id
// (that ensures idempotency). The SDK generates
// a request id if you do not pass one explicitly.
$apiContext = new ApiContext($cred, 'Request' . time());
// ### Create Payment
开发者ID:mayoalexander,项目名称:fl-two,代码行数:31,代码来源:CreatePaymentUsingPayPal.php


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