<i id='CckD7'><tr id='CckD7'><dt id='CckD7'><q id='CckD7'><span id='CckD7'><b id='CckD7'><form id='CckD7'><ins id='CckD7'></ins><ul id='CckD7'></ul><sub id='CckD7'></sub></form><legend id='CckD7'></legend><bdo id='CckD7'><pre id='CckD7'><center id='CckD7'></center></pre></bdo></b><th id='CckD7'></th></span></q></dt></tr></i><div id='CckD7'><tfoot id='CckD7'></tfoot><dl id='CckD7'><fieldset id='CckD7'></fieldset></dl></div>
  • <tfoot id='CckD7'></tfoot>

      1. <legend id='CckD7'><style id='CckD7'><dir id='CckD7'><q id='CckD7'></q></dir></style></legend>

          <bdo id='CckD7'></bdo><ul id='CckD7'></ul>

        <small id='CckD7'></small><noframes id='CckD7'>

        实现 Payum/Laravel 循环支付

        Implement Payum/Laravel recurring payment(实现 Payum/Laravel 循环支付)

              <legend id='uUAn2'><style id='uUAn2'><dir id='uUAn2'><q id='uUAn2'></q></dir></style></legend>

                  <tbody id='uUAn2'></tbody>
                <tfoot id='uUAn2'></tfoot>

                <small id='uUAn2'></small><noframes id='uUAn2'>

                  <bdo id='uUAn2'></bdo><ul id='uUAn2'></ul>
                  <i id='uUAn2'><tr id='uUAn2'><dt id='uUAn2'><q id='uUAn2'><span id='uUAn2'><b id='uUAn2'><form id='uUAn2'><ins id='uUAn2'></ins><ul id='uUAn2'></ul><sub id='uUAn2'></sub></form><legend id='uUAn2'></legend><bdo id='uUAn2'><pre id='uUAn2'><center id='uUAn2'></center></pre></bdo></b><th id='uUAn2'></th></span></q></dt></tr></i><div id='uUAn2'><tfoot id='uUAn2'></tfoot><dl id='uUAn2'><fieldset id='uUAn2'></fieldset></dl></div>
                  本文介绍了实现 Payum/Laravel 循环支付的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在尝试让它工作时遇到了一些问题,我已经成功地实现了快速结账(或似乎是),但我的系统也需要订阅选项,按照这个 示例.

                  现在,我的问题是在 Laravel 中你不能简单地放置一些随机文件,所以我试图以正确的方式来做到这一点,遗憾的是,没有包括库中的类和方法的文档.

                  我在控制器中创建了一些函数(我不知道这是否正确)我现在面临的问题是尝试 createRecurringPayment() 来应用所需的定期付款金额,这是最后一步我猜.

                  感谢您的帮助.

                  • app/controllers/PaypalController.php

                    公共函数prepareExpressCheckout(){$storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');$details = $storage->createModel();$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';$details['PAYMENTREQUEST_0_AMT'] = 1.23;$storage->updateModel($details);$captureToken = $this->getTokenFactory()->createCaptureToken('paypal_es', $details, 'payment_done');$details['RETURNURL'] = $captureToken->getTargetUrl();$details['CANCELURL'] = $captureToken->getTargetUrl();$storage->updateModel($details);返回 Redirect::to($captureToken->getTargetUrl());}公共函数准备订阅(){$storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');$details = $storage->createModel();$details['PAYMENTREQUEST_0_AMT'] = 0;$details['L_BILLINGTYPE0'] = Api::BILLINGTYPE_RECURRING_PAYMENTS;$details['L_BILLINGAGREEMENTDESCRIPTION0'] = "Suscripción por X meses";$details['NOSHIPPING'] = 1;$storage->updateModel($details);$captureToken = $this->getTokenFactory()->createCaptureToken('paypal_es', $details, 'payment_done');$storage->updateModel($details);返回 Redirect::to($captureToken->getTargetUrl());}公共函数 createRecurringPayment(){$payum_token = Input::get('payum_token');$request = App::make('request');$request->attributes->set('payum_token', $payum_token);$token = ($request);//$this->invalidate($token);$agreementStatus = new GetHumanStatus($token);$payment->execute($agreementStatus);如果 (!$agreementStatus->isSuccess()) {header('HTTP/1.1 400 Bad Request', true, 400);出口;}$agreementDetails = $agreementStatus->getModel();$storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');$recurringPaymentDetails = $storage->createModel();$recurringPaymentDetails['TOKEN'] = $agreementDetails['TOKEN'];$recurringPaymentDetails['DESC'] = '订阅一周的天气预报.每天 0.05 美元.';$recurringPaymentDetails['EMAIL'] = $agreementDetails['EMAIL'];$recurringPaymentDetails['AMT'] = 0.05;$recurringPaymentDetails['CURRENCYCODE'] = 'USD';$recurringPaymentDetails['BILLINGFREQUENCY'] = 7;$recurringPaymentDetails['PROFILESTARTDATE'] = date(DATE_ATOM);$recurringPaymentDetails['BILLINGPERIOD'] = Api::BILLINGPERIOD_DAY;$payment->execute(new CreateRecurringPaymentProfile($recurringPaymentDetails));$payment->execute(new Sync($recurringPaymentDetails));$doneToken = $this->createToken('paypal_es', $recurringPaymentDetails, 'payment_done');返回 Redirect::to($doneToken->getTargetUrl());}

                  • app/routes.php

                     Route::get('/payment', array('as' => 'payment', 'uses' => 'PaymentController@payment'));Route::get('/payment/done', array('as' => 'payment_done', 'uses' => 'PaymentController@done'));Route::get('/payment/paypal/express-checkout/prepare', array('as' => 'paypal_es_prepare', 'uses' => 'PaypalController@prepareExpressCheckout'));Route::get('/payment/paypal/subscribe/prepare', array('as' => 'paypal_re_prepare', 'uses' => 'PaypalController@prepareSubscribe'));Route::get('/payment/paypal/subscribe/create', array('as' => 'payment_create', 'uses' => 'PaypalController@createRecurringPayment'));

                  解决方案

                  我发现了问题.它与我们传递给创建定期付款功能的参数一起使用.以下是协议和付款创建功能.它应该可以正常工作.

                  getPayum()->getStorage('PayumCoreModelArrayObject');$details = $storage->create();$details['PAYMENTREQUEST_0_AMT'] = 0;$details['L_BILLINGTYPE0'] = Api::BILLINGTYPE_RECURRING_PAYMENTS;$details['L_BILLINGAGREEMENTDESCRIPTION0'] = "天气订阅";//$details['NOSHIPPING'] = 1;$storage->update($details);$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $details, 'paypal_subscribe');返回 Redirect::to($captureToken->getTargetUrl());}公共函数 createSubscribePayment(Request $request) {$request->attributes->set('payum_token', $request->input('payum_token'));$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);$gateway = $this->getPayum()->getGateway($token->getGatewayName());$agreementStatus = new GetHumanStatus($token);$gateway->execute($agreementStatus);如果 (!$agreementStatus->isCaptured()) {header('HTTP/1.1 400 Bad Request', true, 400);出口;}$agreement = $agreementStatus->getModel();$storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');$recurringPayment = $storage->create();$recurringPayment['TOKEN'] = $agreement['TOKEN'];$recurringPayment['PAYERID'] = $agreement['PAYERID'];$recurringPayment['PROFILESTARTDATE'] = date(DATE_ATOM);$recurringPayment['DESC'] = $agreement['L_BILLINGAGREEMENTDESCRIPTION0'];$recurringPayment['BILLINGPERIOD'] = Api::BILLINGPERIOD_DAY;$recurringPayment['BILLINGFREQUENCY'] = 7;$recurringPayment['AMT'] = 0.05;$recurringPayment['CURRENCYCODE'] = 'USD';$recurringPayment['COUNTRYCODE'] = '美国';$recurringPayment['MAXFAILEDPAYMENTS'] = 3;$gateway->execute(new CreateRecurringPaymentProfile($recurringPayment));$gateway->execute(new Sync($recurringPayment));$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $recurringPayment, 'payment_done');返回 Redirect::to($captureToken->getTargetUrl());}公共功能完成(请求 $request){/** @var 请求 $request *///$request = App::make('request');$request->attributes->set('payum_token', $request->input('payum_token'));$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);$gateway = $this->getPayum()->getGateway($token->getGatewayName());$gateway->execute($status = new GetHumanStatus($token));返回 Response::json(数组('状态' =>$status->getValue(),'详细信息' =>iterator_to_array($status->getFirstModel())));}}

                  路线:

                  Route::get('paypal/agreement', 'PayPalController@prepareSubscribeAgreement');Route::get('paypal/订阅', ['作为' =>'paypal_subscribe','使用' =>'PayPalController@createSubscribePayment']);Route::get('paydone', ['作为' =>'付款完成','使用' =>'PayPalController@done']);

                  只需打开 www.example.com/paypal/agreement,它就会将您带到 PayPal

                  I have some issues trying to get this working, I've implemented the checkout express (or seems to be) successfully, but also my system needs subscription option, following this example.

                  Now, my problem is that in Laravel you cannot simply put some random files, so I'm trying to do it in the correct way, sadly, there is no documentation of the classes and methods including on the library.

                  I've created some functions within controllers (I don't know if this the right way) the problem I'm facing now is trying to createRecurringPayment() to apply the desired amount of the recurring payment, is the final step I guess.

                  Thanks for yout help.

                  • app/controllers/PaypalController.php

                    public function prepareExpressCheckout(){
                        $storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');
                        $details = $storage->createModel();
                        $details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';
                        $details['PAYMENTREQUEST_0_AMT'] = 1.23;
                        $storage->updateModel($details);
                        $captureToken = $this->getTokenFactory()->createCaptureToken('paypal_es', $details, 'payment_done');
                        $details['RETURNURL'] = $captureToken->getTargetUrl();
                        $details['CANCELURL'] = $captureToken->getTargetUrl();
                        $storage->updateModel($details);
                        return Redirect::to($captureToken->getTargetUrl());
                    }
                    
                    public function prepareSubscribe(){
                        $storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');
                        $details = $storage->createModel();
                    
                        $details['PAYMENTREQUEST_0_AMT'] = 0;
                        $details['L_BILLINGTYPE0'] = Api::BILLINGTYPE_RECURRING_PAYMENTS;
                        $details['L_BILLINGAGREEMENTDESCRIPTION0'] = "Suscripción por X meses";
                        $details['NOSHIPPING'] = 1;
                    
                        $storage->updateModel($details);
                        $captureToken = $this->getTokenFactory()->createCaptureToken('paypal_es', $details, 'payment_done');
                        $storage->updateModel($details);
                    
                        return Redirect::to($captureToken->getTargetUrl());
                    }
                    
                    public function createRecurringPayment(){
                        $payum_token = Input::get('payum_token');
                        $request = App::make('request');
                        $request->attributes->set('payum_token', $payum_token);
                        $token = ($request);
                        //$this->invalidate($token);
                    
                        $agreementStatus = new GetHumanStatus($token);
                        $payment->execute($agreementStatus);
                    
                        if (!$agreementStatus->isSuccess()) {
                            header('HTTP/1.1 400 Bad Request', true, 400);
                            exit;
                        }
                    
                        $agreementDetails = $agreementStatus->getModel();
                    
                        $storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');
                    
                        $recurringPaymentDetails = $storage->createModel();
                        $recurringPaymentDetails['TOKEN'] = $agreementDetails['TOKEN'];
                        $recurringPaymentDetails['DESC'] = 'Subscribe to weather forecast for a week. It is 0.05$ per day.';
                        $recurringPaymentDetails['EMAIL'] = $agreementDetails['EMAIL'];
                        $recurringPaymentDetails['AMT'] = 0.05;
                        $recurringPaymentDetails['CURRENCYCODE'] = 'USD';
                        $recurringPaymentDetails['BILLINGFREQUENCY'] = 7;
                        $recurringPaymentDetails['PROFILESTARTDATE'] = date(DATE_ATOM);
                        $recurringPaymentDetails['BILLINGPERIOD'] = Api::BILLINGPERIOD_DAY;
                    
                        $payment->execute(new CreateRecurringPaymentProfile($recurringPaymentDetails));
                        $payment->execute(new Sync($recurringPaymentDetails));
                    
                        $doneToken = $this->createToken('paypal_es', $recurringPaymentDetails, 'payment_done');
                    
                        return Redirect::to($doneToken->getTargetUrl());
                    }
                    

                  • app/routes.php

                        Route::get('/payment', array('as' => 'payment', 'uses' => 'PaymentController@payment'));
                        Route::get('/payment/done', array('as' => 'payment_done', 'uses' => 'PaymentController@done'));
                        Route::get('/payment/paypal/express-checkout/prepare', array('as' => 'paypal_es_prepare', 'uses' => 'PaypalController@prepareExpressCheckout'));
                        Route::get('/payment/paypal/subscribe/prepare', array('as' => 'paypal_re_prepare', 'uses' => 'PaypalController@prepareSubscribe'));
                        Route::get('/payment/paypal/subscribe/create', array('as' => 'payment_create', 'uses' => 'PaypalController@createRecurringPayment'));
                    

                  解决方案

                  I have found the problem. It is with the parameters we pass to the create recurring payment function. Here are functions for agreement and payment creation. It should work fine.

                  <?php
                  
                  namespace AppHttpControllers;
                  
                  use PayumCoreRequestGetHumanStatus;
                  use PayumLaravelPackageControllerPayumController;
                  use PayumPaypalExpressCheckoutNvpApi;
                  use PayumCoreRequestSync;
                  use PayumPaypalExpressCheckoutNvpRequestApiCreateRecurringPaymentProfile;
                  use IlluminateHttpRequest;
                  use AppHttpRequests;
                  use AppHttpControllersController;
                  
                  class PayPalController extends PayumController {
                  
                      public function prepareSubscribeAgreement() {
                  
                          $storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');
                  
                          $details = $storage->create();
                          $details['PAYMENTREQUEST_0_AMT'] = 0;
                          $details['L_BILLINGTYPE0'] = Api::BILLINGTYPE_RECURRING_PAYMENTS;
                          $details['L_BILLINGAGREEMENTDESCRIPTION0'] = "Weather subscription";
                          //$details['NOSHIPPING'] = 1;
                          $storage->update($details);
                  
                          $captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $details, 'paypal_subscribe');
                  
                          return Redirect::to($captureToken->getTargetUrl());
                      }
                  
                      public function createSubscribePayment(Request $request) {
                          $request->attributes->set('payum_token', $request->input('payum_token'));
                  
                          $token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
                          $gateway = $this->getPayum()->getGateway($token->getGatewayName());
                  
                          $agreementStatus = new GetHumanStatus($token);
                          $gateway->execute($agreementStatus);
                  
                          if (!$agreementStatus->isCaptured()) {
                              header('HTTP/1.1 400 Bad Request', true, 400);
                              exit;
                          }
                  
                          $agreement = $agreementStatus->getModel();
                  
                          $storage = $this->getPayum()->getStorage('PayumCoreModelArrayObject');
                  
                          $recurringPayment = $storage->create();
                          $recurringPayment['TOKEN'] = $agreement['TOKEN'];
                          $recurringPayment['PAYERID'] = $agreement['PAYERID'];
                          $recurringPayment['PROFILESTARTDATE'] = date(DATE_ATOM);
                          $recurringPayment['DESC'] = $agreement['L_BILLINGAGREEMENTDESCRIPTION0'];
                          $recurringPayment['BILLINGPERIOD'] = Api::BILLINGPERIOD_DAY;
                          $recurringPayment['BILLINGFREQUENCY'] = 7;
                          $recurringPayment['AMT'] = 0.05;
                          $recurringPayment['CURRENCYCODE'] = 'USD';
                          $recurringPayment['COUNTRYCODE'] = 'US';
                          $recurringPayment['MAXFAILEDPAYMENTS'] = 3;
                  
                          $gateway->execute(new CreateRecurringPaymentProfile($recurringPayment));
                          $gateway->execute(new Sync($recurringPayment));
                  
                          $captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $recurringPayment, 'payment_done');
                  
                          return Redirect::to($captureToken->getTargetUrl());
                      }
                  
                      public function done(Request $request) {
                          /** @var Request $request */
                          //$request = App::make('request');
                          $request->attributes->set('payum_token', $request->input('payum_token'));
                  
                          $token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
                          $gateway = $this->getPayum()->getGateway($token->getGatewayName());
                  
                          $gateway->execute($status = new GetHumanStatus($token));
                  
                          return Response::json(array(
                                      'status' => $status->getValue(),
                                      'details' => iterator_to_array($status->getFirstModel())
                          ));
                      }
                  
                  }
                  

                  The routes:

                  Route::get('paypal/agreement', 'PayPalController@prepareSubscribeAgreement');
                      Route::get('paypal/subscribe', [
                          'as' => 'paypal_subscribe',
                          'uses' => 'PayPalController@createSubscribePayment'
                      ]);
                      Route::get('paydone', [
                          'as' => 'payment_done',
                          'uses' => 'PayPalController@done'
                      ]);
                  

                  Simply open www.example.com/paypal/agreement and it should take you to PayPal

                  这篇关于实现 Payum/Laravel 循环支付的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <legend id='FDzCX'><style id='FDzCX'><dir id='FDzCX'><q id='FDzCX'></q></dir></style></legend>

                      <tbody id='FDzCX'></tbody>
                    1. <i id='FDzCX'><tr id='FDzCX'><dt id='FDzCX'><q id='FDzCX'><span id='FDzCX'><b id='FDzCX'><form id='FDzCX'><ins id='FDzCX'></ins><ul id='FDzCX'></ul><sub id='FDzCX'></sub></form><legend id='FDzCX'></legend><bdo id='FDzCX'><pre id='FDzCX'><center id='FDzCX'></center></pre></bdo></b><th id='FDzCX'></th></span></q></dt></tr></i><div id='FDzCX'><tfoot id='FDzCX'></tfoot><dl id='FDzCX'><fieldset id='FDzCX'></fieldset></dl></div>

                      <small id='FDzCX'></small><noframes id='FDzCX'>

                      <tfoot id='FDzCX'></tfoot>

                      • <bdo id='FDzCX'></bdo><ul id='FDzCX'></ul>