嗨,所以我使用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和他们的意思,而不是如何捕获它们。
直接信用卡付款不需要重定向网址,因为买方永远不会离开您的网站。 –
是啊这就是我虽然但我得到验证错误没有他们。有任何想法吗? –