2014-03-26 1 views
6

Ich versuche, die PayPal-REST API erstellen eine Zahlung mit einer Kreditkarte im Tresor gespeichert. Aber, wenn ich versuche, und eine Zahlung mit der Karte im Tresor machen PayPal-API für etwa eine halbe Minute lang hängen, und dann geben Sie mir die folgenden 500 Fehler:PayPal REST API Rückgabe 500 Server Fehler für Kreditkarte Token

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

Dies ist der Code ich verwende (I entschuldige mich, wenn es hier zu viel Information, ich wusste nicht, was Information ist relevant für mein 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(''); 
$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); 
} 

wenn ich $useVault-false ändern, dann wird die Zahlung vorgenommen werden und die Transaktion wird sich zeigen in den Entwickler Sandkasten. benutzen ich this guide at dev-tools.paypal.com und es scheint, das gleiche Problem zu haben, wie ich (ich Schritt 3 von 4 erhalten, und er druckt, dass ein interner Dienstfehler

aufgetreten

Antwort

9

Paypal wirft manchmal 500 Fehler, wenn wie häufig verwendeten Test CC mit Den einen, den Sie verwenden, versuchen Sie einen anderen oder versuchen Sie einfach mit einer echten CC-Nummer, solange Sie im Sandbox-Modus sind, wird es Sie nicht aufladen oder ähnliches

+0

Ganz richtig Es gibt auch ein laufendes Problem, das dies betrifft API in Sandbox im Moment. Es wird gearbeitet, aber ich habe keine feste ETA. – tomwhipple

+0

Danke.Ich war mir nicht bewusst, ob dies ein Problem mit nur der PayPal Sandbox API war oder was –

+2

Danke, sehr frustrierend, dass PayPal gibt zumindest nicht eine nützliche Antwort Chaos Alter! – RogerRoger