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


PHP Payment::get方法代码示例

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


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

示例1: getPaymentStatus

 public function getPaymentStatus()
 {
     // Get the payment ID before session clear
     $payment_id = Session::get('paypal_payment_id');
     // clear the session payment ID
     Session::forget('paypal_payment_id');
     if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
         return Redirect::route('original.route')->with('error', 'Payment failed');
     }
     $payment = Payment::get($payment_id, $this->_api_context);
     // PaymentExecution object includes information necessary
     // to execute a PayPal account payment.
     // The payer_id is added to the request query parameters
     // when the user is redirected from paypal back to your site
     $execution = new PaymentExecution();
     $execution->setPayerId(Input::get('PayerID'));
     //Execute the payment
     $result = $payment->execute($execution, $this->_api_context);
     echo '<pre>';
     print_r($result);
     echo '</pre>';
     exit;
     // DEBUG RESULT, remove it later
     if ($result->getState() == 'approved') {
         // payment made
         return Redirect::route('original.route')->with('success', 'Payment success');
     }
     return Redirect::route('original.route')->with('error', 'Payment failed');
 }
开发者ID:RobbieBakker,项目名称:LaravelProject56,代码行数:29,代码来源:PaymentController.php

示例2: processResult

 public function processResult($data)
 {
     $paymentId = ArrayHelper::getValue($data, 'paymentId');
     if (!$paymentId) {
         throw new BadRequestHttpException('Missing payment id');
     }
     $payerId = ArrayHelper::getValue($data, 'PayerID');
     if (!$payerId) {
         throw new BadRequestHttpException('Missing payer id');
     }
     $payment = Payment::get($paymentId, $this->getContext());
     $event = new GatewayEvent(['gatewayData' => $data, 'payment' => $payment]);
     $this->trigger(GatewayEvent::EVENT_PAYMENT_REQUEST, $event);
     if (!$event->handled) {
         throw new ServerErrorHttpException('Error processing request');
     }
     $transaction = \Yii::$app->getDb()->beginTransaction();
     try {
         $paymentExecution = new PaymentExecution();
         $paymentExecution->setPayerId($payerId);
         $event->payment = $payment->execute($paymentExecution, $this->getContext());
         $this->trigger(GatewayEvent::EVENT_PAYMENT_SUCCESS, $event);
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollback();
         \Yii::error('Payment processing error: ' . $e->getMessage(), 'PayPal');
         throw new ServerErrorHttpException('Error processing request');
     }
     return true;
 }
开发者ID:yii-dream-team,项目名称:yii2-paypal,代码行数:30,代码来源:Api.php

示例3: check

 /**
  * @param PaymentInterface $payment
  * @throws InvalidPaymentException
  */
 public function check(PaymentInterface $payment)
 {
     if ($payment->getTransaction()) {
         throw new InvalidPaymentException('Payment has already been received.');
     }
     $credentials = new OAuthTokenCredential($this->options['client_id'], $this->options['secret']);
     $apiContext = new ApiContext($credentials);
     $apiContext->setConfig(['mode' => $this->options['mode']]);
     $paypalPayment = Payment::get($payment->getExtraData('paypal_payment_id'), $apiContext);
     $payer = $paypalPayment->getPayer();
     if (!$payer || 'verified' !== strtolower($payer->getStatus())) {
         throw new InvalidPaymentException('Payer not verified.');
     }
     if ('created' == $paypalPayment->getState()) {
         $execution = new PaymentExecution();
         $execution->setPayerId($paypalPayment->getPayer()->getPayerInfo()->getPayerId());
         $paypalPayment->execute($execution, $apiContext);
     }
     if ('approved' != $paypalPayment->getState()) {
         throw new InvalidPaymentException('Invalid payment state.');
     }
     $math = new NativeMath();
     $controlSum = 0;
     foreach ($paypalPayment->getTransactions() as $transaction) {
         if ($transaction->getAmount()->getCurrency() != $payment->getAccount()->getCurrency()) {
             throw new InvalidPaymentException('Invalid payment currency.');
         }
         $controlSum = $math->sum($controlSum, $transaction->getAmount()->getTotal());
     }
     if (!$math->eq($payment->getPaymentSum(), $controlSum)) {
         throw new InvalidPaymentException('Invalid payment sum.');
     }
 }
开发者ID:moriony,项目名称:payment-gateway,代码行数:37,代码来源:PayPalHandler.php

示例4: ExecutePayment

 public function ExecutePayment($paymentId = 0, $payerId = 0)
 {
     $apiContext = $this->getApiContext();
     try {
         $payment = Payment::get($paymentId, $apiContext);
     } catch (Exception $ex) {
         $this->error = $ex->getMessage();
         return false;
     }
     $dataP = json_decode($payment->toJSON());
     if ($dataP->payer->payer_info->payer_id != $payerId) {
         $this->error = 'Los datos son inválidos';
         return false;
     }
     if ($dataP->state == 'approved') {
         $this->error = 'El pedido ya fue pagado';
         return false;
     }
     if (!$dataP->state == 'created') {
         $this->error = 'El pedido no ya fue aprobado';
         return false;
     }
     try {
         $paymentExecution = new PaymentExecution();
         $paymentExecution->setPayerId($payerId);
         $payment = $payment->execute($paymentExecution, $apiContext);
     } catch (Exception $ex) {
         $this->error = $ex->getMessage();
         return false;
     }
     return $payment->toJSON();
 }
开发者ID:juanazareno,项目名称:joan-cornella,代码行数:32,代码来源:paypalmodel.php

示例5: testGet

 /**
  * @depends testCreate
  * @param $payment Payment
  * @return Payment
  */
 public function testGet($payment)
 {
     $result = Payment::get($payment->getId(), $this->apiContext, $this->mockPayPalRestCall);
     $this->assertNotNull($result);
     $this->assertEquals($payment->getId(), $result->getId());
     return $result;
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:12,代码来源:PaymentsFunctionalTest.php

示例6: execute

 /**
  * {@inheritDoc}
  */
 public function execute($request)
 {
     /** @var $request Sync */
     RequestNotSupportedException::assertSupports($this, $request);
     /** @var Payment $model */
     $model = $request->getModel();
     $payment = Payment::get($model->id);
     $model->fromArray($payment->toArray());
 }
开发者ID:eamador,项目名称:Payum,代码行数:12,代码来源:SyncAction.php

示例7: testOperations

 public function testOperations()
 {
     $p1 = $this->payments['new'];
     $p1->create();
     $this->assertNotNull($p1->getId());
     $p2 = Payment::get($p1->getId());
     $this->assertNotNull($p2);
     $paymentHistory = Payment::all(array('count' => '10'));
     $this->assertNotNull($paymentHistory);
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:10,代码来源:PaymentTest.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 public function execute($request)
 {
     /** @var $request \Payum\Core\Request\Sync */
     if (false == $this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     /** @var Payment $model */
     $model = $request->getModel();
     $payment = Payment::get($model->id);
     $model->fromArray($payment->toArray());
 }
开发者ID:Studio-40,项目名称:Payum,代码行数:14,代码来源:SyncAction.php

示例9: execute

 /**
  * {@inheritDoc}
  */
 public function execute($request)
 {
     /** @var $request Sync */
     RequestNotSupportedException::assertSupports($this, $request);
     $model = ArrayObject::ensureArrayObject($request->getModel());
     if (true == isset($model['response']) && true == isset($model['response']['state']) && true == isset($model['response']['id'])) {
         $paymentResponse = Payment::get($model['response']['id'], $this->api);
         $model['response'] = $paymentResponse->toArray();
     }
     //        $model->fromArray($payment->toArray());
 }
开发者ID:sio-ag,项目名称:PaypalRest,代码行数:14,代码来源:SyncAction.php

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

示例11: confirmPayment

 /**
  * @param array $params
  * @return bool
  */
 public function confirmPayment($params = [])
 {
     $payment = Payment::get($params['paymentId'], $this->apiContext);
     $execution = new PaymentExecution();
     $execution->setPayerId($params['PayerID']);
     $transaction = $this->buildTransaction();
     try {
         $execution->addTransaction($transaction);
         $payment->execute($execution, $this->apiContext);
     } catch (PayPalConnectionException $e) {
         throw new Exception(trans('vendirun::checkout.paypalUnavailable'));
     }
     $vendirunPayment = new VendirunPayment($this->order->getTotalPrice(), date("Y-m-d"), 'paypal', json_encode($payment));
     $this->order->addPayment($vendirunPayment);
     return $this->orderRepository->save($this->order);
 }
开发者ID:alistairshaw,项目名称:vendirun-plugin,代码行数:20,代码来源:PaypalPaymentGateway.php

示例12: paymentStatus

 public function paymentStatus()
 {
     $payment_id = Session::get('paypal_payment_id');
     Session::forget('paypal_payment_id');
     if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
         return "Operation failed";
     }
     $payment = Payment::get($payment_id, $this->_api_context);
     $execution = new PaymentExecution();
     $execution->setPayerId(Input::get('PayerID'));
     $result = $payment->execute($execution, $this->_api_context);
     if ($result->getState() == 'approved') {
         return 'Payment was successfull , we Thank you for that';
     } else {
         return "Operation failed";
     }
 }
开发者ID:Pixelsltd,项目名称:e-commerce-1,代码行数:17,代码来源:PaypalController.php

示例13: callExecute

 public function callExecute($clientId, $clientSecret, $paymentId, $payerId, $amount, $currency)
 {
     $oauthCredential = new OAuthTokenCredential($clientId, $clientSecret);
     $apiContext = new ApiContext($oauthCredential);
     $apiContext->setConfig(['mode' => $this->mode]);
     $payment = Payment::get($paymentId, $apiContext);
     $execution = new PaymentExecution();
     $execution->setPayerId($payerId);
     $result = $payment->execute($execution, $apiContext);
     try {
         $payment = Payment::get($paymentId, $apiContext);
     } catch (\Exception $e) {
         throw new PaymentException('unable to find payment: ' . $e->getMessage());
     }
     if ($payment->state == 'approved') {
         return true;
     }
     return false;
 }
开发者ID:luyadev,项目名称:luya-module-payment,代码行数:19,代码来源:PayPalProvider.php

示例14: checkPaymentSession

 public function checkPaymentSession($paymentId, $task)
 {
     $paymentInfo = Session::get('paypal.payment');
     if ($paymentId == $paymentInfo['id']) {
         throw new \Exception('Payment id mismatch');
     }
     $payment = Payment::get($paymentId, $this->apiContext);
     $transactions = $payment->getTransactions();
     $transaction = $transactions[0];
     list($taskId, $date) = explode('_', $transaction->invoice_number);
     if ($transaction->amount->total != $task->total || $transaction->amount->currency != $this->currency) {
         throw new \Exception('Payment amount mismatch');
     }
     if ($taskId != $task->id) {
         throw new \Exception('Task Id mismatch');
     }
     // @todo: Maybe check date here
     Session::remove('paypal.payment');
     return true;
 }
开发者ID:blozixdextr,项目名称:tuasist2,代码行数:20,代码来源:PaypalPaymentService.php

示例15: successPay

 public function successPay(Request $request)
 {
     // send emails.
     if (Auth::check()) {
         // Get the payment ID before session clear
         $paypal_data = Session::get("paypal_data");
         Session::forget("paypal_data");
         $payment_id = $paypal_data['paypal_payment_id'];
         $order_data = ["msg" => "Error: Payment Failed", "result" => "error"];
         if (empty($request->get("PayerID")) || empty($request->get("token"))) {
             return redirect('/fabrics')->with('order_data', $order_data);
         }
         $payment = Payment::get($payment_id, $paypal_data["paypal_context"]);
         $execution = new PaymentExecution();
         $execution->setPayerId($request->get("PayerID"));
         //Execute the payment
         $result = $payment->execute($execution, $paypal_data["paypal_context"]);
         if ($result->getState() == 'approved') {
             // payment made
             $user = Auth::user();
             $dataMail = $paypal_data["data_mail"];
             Mail::send("email.email-sample", ["data" => $dataMail], function ($mail) use($user) {
                 //$mail->to("jj@dnim-inc.com","JJ")->cc("jsanchez@dnim-inc.com" , "Javier")->cc("oreyes@dnim-inc.com" ,"Oswaldo")->subject("New Sample Request");
                 $mail->to("dnimincemail@gmail.com", "DNIM")->subject("New Order");
             });
             Mail::send("email.email-sample", ["data" => $dataMail], function ($mail) use($user) {
                 $mail->to($user->email, $user->name)->subject("New Order Created");
                 //$mail->to("dnimincemail@gmail.com","DNIM")->subject("New Order");
             });
             $paypal_data["fabric"]->save();
             $paypal_data["order"]->save();
             $order_data = ["msg" => "Success: Order created successfully", "result" => "success"];
             return redirect("/fabrics")->with("order_data", $order_data);
         } else {
             $order_data = ["msg" => "Error: Payment not approved", "result" => "error"];
             return redirect("/fabrics")->with("order_data", $order_data);
         }
     } else {
         return redirect("/");
     }
 }
开发者ID:xoscar,项目名称:dnim-inc,代码行数:41,代码来源:OrderController.php


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