我正在尝试在我的应用程序中实现PayPal付款。为此,我尝试使用Payum。我到达了将我重定向到PayPal的地步,然后我使用PayPal帐户支付了款项,然后将我重定向回我的应用程序,显示了以下JSON输出:
{
"status": "pending",
"details": {
"PAYMENTREQUEST_0_CURRENCYCODE": "EUR",
"PAYMENTREQUEST_0_AMT": "12.50",
"PAYMENTREQUEST_0_PAYMENTACTION": "Sale",
"AUTHORIZE_TOKEN_USERACTION": "commit",
"RETURNURL": "http://domovakniga.local/payment/capture/qQFU9Xv6tQDadQo22mIDHwlkGrl9TMRhMOeWmwgE8ec",
"CANCELURL": "http://domovakniga.local/payment/capture/qQFU9Xv6tQDadQo22mIDHwlkGrl9TMRhMOeWmwgE8ec?cancelled=1",
"PAYMENTREQUEST_0_NOTIFYURL": "http://domovakniga.local/payment/notify/k-kZP417hQExhiKjWnzEoFkLLMMwWP-zgjX6P8nqb2k",
"TOKEN": "EC-7TH62273TE605372U",
"TIMESTAMP": "2019-07-04T16:02:14Z",
"CORRELATIONID": "3fc016ddc111f",
"ACK": "Success",
"VERSION": "65.1",
"BUILD": "53232958",
"BILLINGAGREEMENTACCEPTEDSTATUS": "0",
"CHECKOUTSTATUS": "PaymentActionCompleted",
"CURRENCYCODE": "EUR",
"AMT": "12.50",
"SHIPPINGAMT": "0.00",
"HANDLINGAMT": "0.00",
"TAXAMT": "0.00",
"NOTIFYURL": "http://domovakniga.local/payment/notify/k-kZP417hQExhiKjWnzEoFkLLMMwWP-zgjX6P8nqb2k",
"INSURANCEAMT": "0.00",
"SHIPDISCAMT": "0.00",
"PAYMENTREQUEST_0_SHIPPINGAMT": "0.00",
"PAYMENTREQUEST_0_HANDLINGAMT": "0.00",
"PAYMENTREQUEST_0_TAXAMT": "0.00",
"PAYMENTREQUEST_0_INSURANCEAMT": "0.00",
"PAYMENTREQUEST_0_SHIPDISCAMT": "0.00",
"PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED": "false",
"PAYMENTREQUESTINFO_0_ERRORCODE": "0",
"EMAIL": "peter.v.vasilev2@gmail.com",
"PAYERID": "8Q3A8F8MYPPDA",
"PAYERSTATUS": "verified",
"FIRSTNAME": "Petar",
"LASTNAME": "Vasilevv",
"COUNTRYCODE": "US",
"SHIPTONAME": "Petar Vasilevv",
"SHIPTOSTREET": "1 Main St",
"SHIPTOCITY": "San Jose",
"SHIPTOSTATE": "CA",
"SHIPTOZIP": "95131",
"SHIPTOCOUNTRYCODE": "US",
"SHIPTOCOUNTRYNAME": "United States",
"ADDRESSSTATUS": "Confirmed",
"ITEMAMT": "12.50",
"INSURANCEOPTIONOFFERED": "false",
"PAYMENTREQUEST_0_ITEMAMT": "12.50",
"PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID": "peter.v.vasilev@gmail.com",
"PAYMENTREQUEST_0_SHIPTONAME": "Petar Vasilevv",
"PAYMENTREQUEST_0_SHIPTOSTREET": "1 Main St",
"PAYMENTREQUEST_0_SHIPTOCITY": "San Jose",
"PAYMENTREQUEST_0_SHIPTOSTATE": "CA",
"PAYMENTREQUEST_0_SHIPTOZIP": "95131",
"PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE": "US",
"PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME": "United States",
"PAYMENTREQUEST_0_ADDRESSSTATUS": "Confirmed",
"SUCCESSPAGEREDIRECTREQUESTED": "false",
"INSURANCEOPTIONSELECTED": "false",
"SHIPPINGOPTIONISDEFAULT": "false",
"PAYMENTINFO_0_TRANSACTIONID": "0TP060296E276454P",
"PAYMENTINFO_0_TRANSACTIONTYPE": "expresscheckout",
"PAYMENTINFO_0_PAYMENTTYPE": "instant",
"PAYMENTINFO_0_ORDERTIME": "2019-07-04T16:02:12Z",
"PAYMENTINFO_0_AMT": "12.50",
"PAYMENTINFO_0_TAXAMT": "0.00",
"PAYMENTINFO_0_CURRENCYCODE": "EUR",
"PAYMENTINFO_0_PAYMENTSTATUS": "Pending",
"PAYMENTINFO_0_PENDINGREASON": "unilateral",
"PAYMENTINFO_0_REASONCODE": "None",
"PAYMENTINFO_0_PROTECTIONELIGIBILITY": "Ineligible",
"PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE": "None",
"PAYMENTINFO_0_SELLERPAYPALACCOUNTID": "peter.v.vasilev@gmail.com",
"PAYMENTINFO_0_ERRORCODE": "0",
"PAYMENTINFO_0_ACK": "Success",
"TRANSACTIONID": "0TP060296E276454P",
"PAYMENTREQUEST_0_TRANSACTIONID": "0TP060296E276454P",
"PAYMENTREQUESTINFO_0_TRANSACTIONID": "0TP060296E276454P",
"PAYMENTREQUEST_0_PENDINGREASON": "None",
"PAYMENTREQUEST_0_REASONCODE": "None"
}
}
我认为状态“待定”表示付款尚未完成,我必须自己做一些事情才能确定付款,但我无法在文档中的任何地方找到有关该信息。
这是我的Laravel控制器:
<?php
namespace App\Http\Controllers\PayPal;
use Payum\LaravelPackage\Controller\PayumController;
use Payum\Core\Request\GetHumanStatus;
use Symfony\Component\HttpFoundation\Request;
class PaypalController extends PayumController
{
public function prepareExpressCheckout()
{
$storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
$details = $storage->create();
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = 12.50;
$storage->update($details);
$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $details, 'payment_done');
return \Redirect::to($captureToken->getTargetUrl());
}
public function done($payum_token)
{
/** @var Request $request */
$request = \App::make('request');
$request->attributes->set('payum_token', $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())
));
}
}
我已经到了这一点,但是似乎没有关于如何从这里开始的任何信息。我想我需要做的一件事就是完成付款,以使其不再处于待处理状态。我需要做的另一件事是将发票或付款号码传递给PayPal,然后PayPal可以在“付款完成”页面上将其退还给我,这样我就知道通过了哪笔付款。我认为这些是我唯一需要做的事情。有关如何执行操作的任何想法?
我尝试搜索诸如教程或示例之类的各种内容,但找不到任何内容。