嗨,所以我使用PHP貝寶SDK和下面的代碼工程時,輸入重定向網址。然而,我正在嘗試設置直接卡付款,這是否需要重定向網址,因爲所有示例代碼似乎都將其拒之門外?貝寶卡付款
當使用重定向URL對象但是我的應用程序只是重定向我到貝寶API沙箱和一個帳號登錄問(這不是直接卡支付)
繼承人我的代碼與返回:
Fatal error: Uncaught exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment .' in /Applications/MAMP/htdocs/tealtique/library/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php on line 176
我的代碼不包含名稱間距,因爲該文件是控制器對象,名稱間距沒有問題。
$apiContext = $this->paypal_access_token();
$payment_description = 'Payment to comapany';
$invoice_number = uniqid();
$addr = new BaseAddress();
$addr->setLine1($_POST['adr_line1']);
$addr->setCity($_POST['adr_city']);
$addr->setCountryCode($_POST['adr_country']);
$addr->setPostalCode($_POST['adr_postal_code']);
$addr->setState($_POST['adr_county']);
$card = new CreditCard();
$card->setNumber($_POST['card_number']);
$card->setType($_POST['card_type']);
$card->setExpireMonth($_POST['card_expire_mounth']);
$card->setExpireYear($_POST['card_expire_year']);
$card->setCvv2($_POST['card_cvv2']);
$card->setFirstName($_POST['card_first_name']);
$card->setLastName($_POST['card_last_name']);
$card->setBillingAddress($addr);
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item = new Item();
$item->setName('Payment Instalment')
->setCurrency(PAYPAL_CURRENCY)
->setQuantity(1)
->setPrice($_POST['payment_amount']);
$itemList = new ItemList();
$itemList->setItems(array($item));
$details = new Details();
$details->setShipping(0)
->setFee(PAYPAL_FEE)
->setTax(0)
->setSubtotal($_POST['payment_amount']);
$amount = new Amount();
$amount->setCurrency(PAYPAL_CURRENCY)
->setTotal($_POST['payment_amount'])
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription($payment_description)
->setInvoiceNumber($invoice_number);
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setTransactions(array($transaction));
try {
$payment->create($apiContext);
} catch (Exception $ex) {
echo 'exception : <pre>';print_r(json_decode($ex->getData()));
exit(1);
}
//$approvalUrl = $payment->getApprovalLink();
//header('location:' . $approvalUrl);
我還就如何捕捉使用SDK爲開發者貝寶網站上的文檔錯誤消息有些混亂只是陳述了錯誤將retrun和他們的意思,而不是如何捕獲它們。
直接信用卡付款不需要重定向網址,因爲買方永遠不會離開您的網站。 –
是啊這就是我雖然但我得到驗證錯誤沒有他們。有任何想法嗎? –