PayPal REST API返回500服务器错误的信用卡令牌 [英] PayPal REST API returning 500 Server error for credit Card Token

查看:110
本文介绍了PayPal REST API返回500服务器错误的信用卡令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让PayPal REST API使用存储在金库中的信用卡来创建付款.但是,每当我尝试用金库中的卡付款时,PayPal的API都会挂约半分钟,然后出现以下500错误:

I am trying to have the PayPal REST api create a payment with a credit card stored in the vault. But, whenever I try and make a payment with the card in the vault PayPal's API will hang for around half a minute, and then give me the following 500 error:

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"}

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

This is the code I am using (I apologize if there is too much information here, I didn't know what information was pertinent to my problem)

<?php
include("bootstrap.php"); //Sample bootstrap file configured with my clientId and Secret, creates $apiContext
use PayPal\Api\CreditCard;
use PayPal\Api\Payer;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\Payment;
use PayPal\Api\Address;
use PayPal\Api\CreditCardToken;

$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 (PayPal\Exception\PPConnectionException $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
}

如果我将$useVault更改为false,则将进行付款,并且交易将显示在开发人员沙箱中. 我在dev-tools.paypal.com 此指南,并且似乎和我有同样的问题(进入第3步,共4步,它打印出发生了内部服务错误

If I change $useVault to false then the payment will be made and the transaction will show up in the developer sandbox. I used this guide at dev-tools.paypal.com and it seems to be having the same problem as me ( I get to step 3 of 4, and it prints that an internal service error has occured

推荐答案

在使用常用的测试CC(例如您所使用的CC)时,Paypal有时会抛出错误500,因此只要尝试使用一个真实的CC编号,只要您处于沙盒模式,它将不会向您或类似的东西收费.

Paypal sometimes throws error 500 when using frequently used test CC like the one you are using, so try another one or just try with a real CC number as long as you are in sandbox mode it won't charge you or anything like that.

这篇关于PayPal REST API返回500服务器错误的信用卡令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆