我需要一些幫助來找出paypal的API,我所要做的就是對我的沙箱帳戶運行一次cc收費,我一直在查看他們的文檔和代碼示例,但我只是可以現在找不到正確的信息,比如在哪裏添加沙箱端點。所以,當我運行了以下功能我得到以下錯誤:Paypal CC直接付款錯誤
string(213) "{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API request","information_link":" https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST ","debug_id":"6eb15180f8d92"}"
這是我打電話的功能:
public static function ccPayment($paymentInfo, $credentials)
{
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
$credentials['clientId'],
$credentials['secret']
)
);
$card = new CreditCard();
$card->setType("visa")
->setNumber("xxxxxxxxxxxxxxxx")
->setExpireMonth("11")
->setExpireYear("2019")
->setCvv2("012")
->setFirstName("Joe")
->setLastName("Shopper");
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod("credit_card")
->setFundingInstruments(array($fi));
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setDescription('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setTax(0.3)
->setPrice(7.50);
$itemList = new ItemList();
$itemList->setItems(array($item1));
$transaction = new Transaction();
$transaction->setAmount(489)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setTransactions(array($transaction));
// $request = clone $payment;
try
{
$payment->create($apiContext);
}
catch (Exception $ex)
{
dd($ex->getData());
}
dd($paymentInfo);
}
去過編碼從早晨到現在,所以我需要另一套眼睛權現在因爲我看不到我做錯了什麼。我會感謝任何幫助。
PS。道歉,如果它是愚蠢的。例如。一個缺少的逗號。
謝謝。
你可以發佈完整的響應(帶調試ID) – Vimalnath
「debug_id」:「6eb15180f8d92」 –