【发布时间】:2015-09-14 16:26:09
【问题描述】:
由于某种原因,PayPal 没有收到我为交易指定的总价格。
我正在使用 NetShell 的 PayPal 模块。
我的控制器看起来像这样:
class PayPalController extends Controller {
private $_apiContext;
public function __construct() {
$this->_apiContext = PayPal::ApiContext(
config('services.paypal.client_id'),
config('services.paypal.secret'));
$this->_apiContext->setConfig(array(
'mode' => 'sandbox',
'service.EndPoint' => 'https://api.sandbox.paypal.com',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => storage_path('logs/paypal.log'),
'log.LogLevel' => 'FINE'
));
}
public function getCheckout() {
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');
$amount = PayPal::Amount();
$amount->setCurrency('USD');
$amount->setTotal(42); // This is the simple way,
// you can alternatively describe everything in the order separately;
// Reference the PayPal PHP REST SDK for details.
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('What are you selling?');
$redirectUrls = PayPal::RedirectUrls();
$redirectUrls->setReturnUrl(action('PayPalController@getDone'));
$redirectUrls->setCancelUrl(action('PayPalController@getCancel'));
$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;
return Redirect::to( $redirectUrl );
}
// Other functions here. Removed for question.
}
getCheckout() 在路由 `/paypal/checkout' 处被调用
当我去/paypal/checkout时没有价格。
我错过了什么吗?任何帮助,将不胜感激。
谢谢!
【问题讨论】: