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


PHP Payment::getState方法代码示例

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


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

示例1: testGetters

 /**
  * @depends testSerializationDeserialization
  * @param Payment $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getId(), "TestSample");
     $this->assertEquals($obj->getIntent(), "TestSample");
     $this->assertEquals($obj->getPayer(), PayerTest::getObject());
     $this->assertEquals($obj->getPayee(), PayeeTest::getObject());
     $this->assertEquals($obj->getCart(), "TestSample");
     $this->assertEquals($obj->getTransactions(), TransactionTest::getObject());
     $this->assertEquals($obj->getFailedTransactions(), ErrorTest::getObject());
     $this->assertEquals($obj->getPaymentInstruction(), PaymentInstructionTest::getObject());
     $this->assertEquals($obj->getState(), "TestSample");
     $this->assertEquals($obj->getExperienceProfileId(), "TestSample");
     $this->assertEquals($obj->getRedirectUrls(), RedirectUrlsTest::getObject());
     $this->assertEquals($obj->getCreateTime(), "TestSample");
     $this->assertEquals($obj->getUpdateTime(), "TestSample");
     $this->assertEquals($obj->getLinks(), LinksTest::getObject());
 }
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:21,代码来源:PaymentTest.php

示例2: testGetters

 /**
  * @depends testSerializationDeserialization
  * @param Payment $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getId(), "TestSample");
     $this->assertEquals($obj->getIntent(), "TestSample");
     $this->assertEquals($obj->getPayer(), PayerTest::getObject());
     $this->assertEquals($obj->getPotentialPayerInfo(), PotentialPayerInfoTest::getObject());
     $this->assertEquals($obj->getPayee(), PayeeTest::getObject());
     $this->assertEquals($obj->getCart(), "TestSample");
     $this->assertEquals($obj->getTransactions(), array(TransactionTest::getObject()));
     $this->assertEquals($obj->getFailedTransactions(), ErrorTest::getObject());
     $this->assertEquals($obj->getBillingAgreementTokens(), array("TestSample"));
     $this->assertEquals($obj->getCreditFinancingOffered(), CreditFinancingOfferedTest::getObject());
     $this->assertEquals($obj->getPaymentInstruction(), PaymentInstructionTest::getObject());
     $this->assertEquals($obj->getState(), "TestSample");
     $this->assertEquals($obj->getExperienceProfileId(), "TestSample");
     $this->assertEquals($obj->getNoteToPayer(), "TestSample");
     $this->assertEquals($obj->getRedirectUrls(), RedirectUrlsTest::getObject());
     $this->assertEquals($obj->getFailureReason(), "TestSample");
     $this->assertEquals($obj->getCreateTime(), "TestSample");
     $this->assertEquals($obj->getUpdateTime(), "TestSample");
     $this->assertEquals($obj->getLinks(), LinksTest::getObject());
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:26,代码来源:PaymentTest.php

示例3: processPayment

 /**
  * {@inheritdoc}
  */
 public function processPayment(PaymentInterface $payment) : PaymentInterface
 {
     $order = $payment->getOrder();
     $payer = $this->createPayer('paypal');
     $redirectUrls = $this->createRedirectUrls($payment);
     $transaction = $this->createTransaction($order);
     $payPalPayment = new Payment();
     $payPalPayment->setIntent("sale");
     $payPalPayment->setPayer($payer);
     $payPalPayment->setRedirectUrls($redirectUrls);
     $payPalPayment->setTransactions([$transaction]);
     try {
         $payPalPayment->create($apiContext);
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     $payment->setApprovalUrl($payPalPayment->getApprovalLink());
     $payment->setState($payPalPayment->getState());
     $payment->setToken($payPalPayment->getId());
     $this->paymentManager->updateResource($payment);
     return $payment;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:25,代码来源:PayPalProcessor.php

示例4: substr

 /**
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     $this->_autoload();
     $order = $this->_getOrder($data['order_number']);
     //initialise application
     $app = JFactory::getApplication();
     //get card input
     $data['cardtype'] = $app->input->getString("cardtype");
     $data['cardnum'] = $app->input->getString("cardnum");
     $month = $app->input->getString("month");
     $year = $app->input->getString("year");
     $card_exp = $month . '' . $year;
     $data['cardexp'] = $card_exp;
     $data['cardcvv'] = $app->input->getString("cardcvv");
     $data['cardnum_last4'] = substr($app->input->getString("cardnum"), -4);
     //initialise payment
     $apiContext = new ApiContext(new OAuthTokenCredential($this->api_clientId, $this->api_clientSecret));
     $apiContext->setConfig(array('mode' => $this->api_mode));
     //		echo'<pre>';print_r($apiContext);die;
     $card = new CreditCard();
     $card->setType($data['cardtype']);
     $card->setNumber($data['cardnum']);
     $card->setExpireMonth($month);
     $card->setExpireYear($year);
     $card->setFirstName($data['firstname']);
     $card->setLastName($data['lastname']);
     $card->setCvv2($data['cardcvv']);
     $fi = new FundingInstrument();
     $fi->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
     if (!empty($data['email'])) {
         $payerInfo = new PayerInfo();
         $payerInfo->setFirstName($data['firstname']);
         $payerInfo->setLastName($data['lastname']);
         $payerInfo->setEmail($data['email']);
         $payer->setPayerInfo($payerInfo);
     }
     $amount = new Amount();
     $amount->setCurrency($this->currency);
     $amount->setTotal($data['total']);
     $item1 = new Item();
     $item1->setName($data['order_number'])->setDescription($data['order_number'])->setCurrency($this->currency)->setQuantity(1)->setTax(0)->setPrice($data['total']);
     $itemList = new ItemList();
     $itemList->setItems(array($item1));
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setItemList($itemList);
     $transaction->setDescription($data['order_number']);
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $request = clone $payment;
     try {
         $payment->create($apiContext);
     } catch (PayPal\Exception\PayPalConnectionException $ex) {
         $error = json_decode($ex->getData());
         $error_html = '<h2>' . $error->name . '</h2><br>';
         foreach ($error->details as $r) {
             $error_html .= '- ' . $r->field . ' - ' . $r->issue . '<br>';
         }
         $app->enqueueMessage($error_html, 'error');
         $app->redirect('index.php?option=com_bookpro&view=formpayment&order_id=' . $order->id . '&' . JSession::getFormToken() . '=1');
         return;
     } catch (Exception $ex) {
         die($ex);
     }
     $ack = $payment->getState();
     if ($ack == 'approved' || $ack == 'completed') {
         $order->pay_status = "SUCCESS";
         $order->order_status = "CONFIRMED";
         $order->tx_id = $payment->getId();
         $order->store();
     } else {
         JLog::addLogger(array('text_file' => 'paypal.txt', 'text_file_path' => 'logs', 'text_file_no_php' => 1, 'text_entry_format' => '{DATE} {TIME} {MESSAGE}'), JLog::ALERT);
         JLog::add('Transaction: ' . json_encode($payment) . '\\nOrder: ' . $order->order_number . ' Status: ' . $ack, JLog::ALERT, 'com_bookpro');
         $order->pay_status = "PENDING";
         $order->tx_id = $transaction_id;
         $order->store();
     }
     $app = JFactory::getApplication();
     $app->redirect('index.php?option=com_bookpro&controller=payment&task=postpayment&method=' . $this->_element . '&order_number=' . $order->order_number);
     return;
 }
开发者ID:hixbotay,项目名称:executivetransport,代码行数:89,代码来源:payment_paypalpro.php

示例5: CallAPI

// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
// The return object contains the state.
try {
    $payment->create($apiContext);
} catch (Exception $ex) {
    $status = 'error';
    if ($date < $today) {
        $status = 'declined';
    }
    error_log($ex);
}
/*
possible PayPal payment states: created, approved, failed, cancelled, expired
paydunk status - must be "success", "cancelled", or "error" depending on the outcome of your transaction.
*/
if ($payment->getState() == 'approved') {
    $status = 'success';
    //the payment was approved!
    //do some stuff here - update your order database, etc.
}
if ($payment->getState() == 'failed' || $payment->getState() == 'expired') {
    $status = 'error';
    //the payment failed to process
    //do some stuff here - update your order database, etc.
}
//set data for PUT request
$bodyparams = array("client_id" => "AEGbEsLu4cWjlQ8YfCC1bzI3Axq7UZ9k5gk7Y7yj", "client_secret" => "CMHBwkFvtNTFs0E06c1JHeHjuTShauMGDL1vRYUU", "status" => $status);
//sends the PUT request to the Paydunk API
function CallAPI($method, $url, $data = false)
{
    $curl = curl_init();
开发者ID:paydunk,项目名称:paypal,代码行数:31,代码来源:test.php

示例6: getLinkCheckOut

 public function getLinkCheckOut($params = null)
 {
     if (!$params) {
         return false;
     }
     /*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");
     $itemList = new ItemList();
     // Item must be a array and has one or more item.
     if (!$params['items']) {
         return false;
     }
     $arrItem = [];
     foreach ($params['items'] as $key => $item) {
         $it = new Item();
         $it->setName($item['name'])->setCurrency($params['currency'])->setQuantity($item['quantity'])->setPrice($item['price']);
         $arrItem[] = $it;
     }
     $itemList->setItems($arrItem);
     $amount = new Amount();
     $amount->setCurrency($params['currency'])->setTotal($params['total_price']);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription($params['description']);
     // ### Redirect urls
     // Set the urls that the buyer must be redirected to after
     // payment approval/ cancellation.
     $redirectUrls = new RedirectUrls();
     $baseUrl = $this->getBaseUrl();
     $redirectUrls->setReturnUrl($baseUrl . $this->successUrl)->setCancelUrl($baseUrl . $this->cancelUrl);
     // ### 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([$transaction]);
     // ### Create Payment
     // Create a payment by calling the 'create' method
     // passing it a valid apiContext.
     try {
         $payment->create($this->config);
     } catch (PayPal\Exception\PPConnectionException $ex) {
         throw new \DataErrorException($ex->getData(), $ex->getMessage());
     }
     // ### Get redirect url
     $redirectUrl = $payment->getApprovalLink();
     return ['payment_id' => $payment->getId(), 'status' => $payment->getState(), 'redirect_url' => $redirectUrl, 'description' => $transaction->getDescription()];
 }
开发者ID:betsuno,项目名称:yii2-paypal,代码行数:51,代码来源:RestAPI.php

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

示例8: _getStatus

 private static function _getStatus(\PayPal\Api\Payment &$payment)
 {
     return $payment->getState();
 }
开发者ID:RamonBuzo,项目名称:startup,代码行数:4,代码来源:CBasePaypal.class.inc.php

示例9: initializePayment

 public function initializePayment(PaymentInterface $payment)
 {
     $order = $payment->getOrder();
     $paymentMethod = $order->getPaymentMethod();
     $configuration = $paymentMethod->getConfiguration();
     $payPalType = $configuration['paypal_type'];
     if ($payPalType === 'paypal') {
         $apiContext = $this->getApiContext($configuration);
         $payer = $this->createPayer($payPalType);
         $redirectUrls = $this->createRedirectUrls($payment);
         $transaction = $this->createTransaction($order);
         $payPalPayment = new Payment();
         $payPalPayment->setIntent("sale");
         $payPalPayment->setPayer($payer);
         $payPalPayment->setRedirectUrls($redirectUrls);
         $payPalPayment->setTransactions([$transaction]);
         try {
             $payPalPayment->create($apiContext);
         } catch (PayPalConnectionException $e) {
             throw $e;
         }
         $payment->setRedirectUrl($payPalPayment->getApprovalLink());
         $payment->setState($payPalPayment->getState());
         $payment->setExternalIdentifier($payPalPayment->getId());
     }
     return $payment;
 }
开发者ID:WellCommerce,项目名称:PaymentBundle,代码行数:27,代码来源:PayPalGateway.php


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