[英]Why paypal sandbox account amount does not updating?
My code is successfully processing payments to paypal and then return to success page, buy business account amount does not updating. 我的代码成功处理付款到paypal然后返回成功页面,购买商业帐户金额不更新。
I am trying paypal sdk in laravel and below is my script which I am using it, but on front side it is successfully going to paypal page where I login using buyer account then pay and then paypal return to success page. 我在laravel尝试paypal sdk,下面是我正在使用它的脚本,但在正面它成功进入paypal页面,我使用买家帐户登录然后支付然后paypal返回成功页面。 But in seller account the amount does not showing and nor deducting from buyer account.
但在卖家帐户中,金额不会显示,也不会从买方帐户中扣除。
public function createpayment(){
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'Ac.................asd', // ClientID
'Ac.................sdf' // ClientSecret
)
);
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123") // Similar to `item_number` in Classic API
->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(5)
->setSku("321321") // Similar to `item_number` in Classic API
->setPrice(2);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50);
$amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
/* $baseUrl = getBaseUrl(); */
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(route('success'))
->setCancelUrl(route('cancel'));
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
/* $payment->create($apiContext);
return redirect($payment->getApprovalLink()); */
try {
$payment->create($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
exit(1);
}
$approvalUrl = $payment->getApprovalLink();
echo $payment, $approvalUrl;
}
public function success(){
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'Ac.................asd', // ClientID
'Ac.................sdf' // ClientSecret // ClientSecret
)
);
return request();
}
I want this code to be transfer money from buyer to seller account and then return success page with response. 我希望此代码可以从买家转移到卖家帐户,然后返回成功页面并附上回复。 Can someone kindly guide me about I would like to appreciate.
有人可以指导我,我想欣赏。
On the success page you need to execute the payment in order to actually finish the transaction. 在成功页面上,您需要执行付款才能实际完成交易。
https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/ExecutePayment.php https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/ExecutePayment.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.