我是靠谱客的博主 畅快画笔,最近开发中收集的这篇文章主要介绍php 信用卡通道api,php – PayPal REST API为信用卡令牌返回500 Server错误,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

我正在尝试让PayPal REST API使用存储在保险库中的信用卡创建付款.但是,每当我尝试使用保险箱中的卡付款时,PayPal的API将挂起大约半分钟,然后给我以下500错误:

Exception: Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/payment.

{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"e3c779ea99f73"}

这是我正在使用的代码(如果这里有太多信息,我很抱歉,我不知道哪些信息与我的问题有关)

include("bootstrap.php"); //Sample bootstrap file configured with my clientId and Secret, creates $apiContext

use PayPalApiCreditCard;

use PayPalApiPayer;

use PayPalApiFundingInstrument;

use PayPalApiDetails;

use PayPalApiAmount;

use PayPalApiTransaction;

use PayPalApiPayment;

use PayPalApiAddress;

use PayPalApiCreditCardToken;

$useVault = true;

$addr = new Address();

$addr->setLine1('52 N Main ST');

$addr->setCity('Johnstown');

$addr->setCountry_code('US');

$addr->setPostal_code('43210');

$addr->setState('OH');

$card = new CreditCard();

//Also used PayPal Sandbox account number here

$card->setNumber('4111111111111111');

$card->setExpire_month('03');

$card->setExpire_year('2019');

$card->setCvv2('123');

$card->setFirst_name('Joe');

$card->setLast_name('Shopper');

$card->setType('visa');

$card->setBilling_address($addr);

$fi = new FundingInstrument();

//Setting $useVault to false here

// will attempt to make the payment without storing the CC in the vault

// Which works. having it use the vault will return a 500 error

if($useVault){

//use Store the CC in the vault

$response = $card->create($apiContext);

$ccToken = new CreditCartToken();

$ccToken->setCredit_card_id($response->id);

$fi->setCredit_card_token($creditCardToken);

}else{

$fi->setCredit_card($card);

}

$payer = new Payer();

$payer->setPayment_method('credit_card');

$payer->setFunding_instruments(array($fi));

$amountDetails = new Details();

$amountDetails->setSubtotal('7.41');

$amountDetails->setTax('0.03');

$amountDetails->setShipping('0.03');

$amount = new Amount();

$amount->setCurrency('USD');

$amount->setTotal('7.47');

$amount->setDetails($amountDetails);

$transaction = new Transaction();

$transaction->setAmount($amount);

$transaction->setDescription('This is the payment transaction description.');

$payment = new Payment();

$payment->setIntent('sale');

$payment->setPayer($payer);

$payment->setTransactions(array($transaction));

try {

var_dump($payment->create($apiContext));

} catch (PayPalExceptionPPConnectionException $ex) {

echo "Exception: " . $ex->getMessage() . PHP_EOL;

var_dump($ex->getData());

exit(1);

}

如果我将$useVault更改为false,那么将进行付款并且交易将显示在开发人员沙箱中.

我使用了this guide at dev-tools.paypal.com,它似乎和我有同样的问题(我到了第4步,它打印出内部服务错误已经发生

最后

以上就是畅快画笔为你收集整理的php 信用卡通道api,php – PayPal REST API为信用卡令牌返回500 Server错误的全部内容,希望文章能够帮你解决php 信用卡通道api,php – PayPal REST API为信用卡令牌返回500 Server错误所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部