我已经设置了一个带Ominpay和Paypal express的结账系统,它在测试模式下工作正常,所以我只是“活着”了。不幸的是,我没有检查结账后是否所有信息都发送到了paypal。似乎只发送金额和货币而不是产品的描述/名称。这意味着卖家不知道卖了什么!
N.B:所有内容都被发送到Paypal结帐页面。但付款后,产品名称不会显示在卖家的PayPal页面上 - 只有数量和价格。
如何让产品名称显示在卖家的paypal帐户上?这将是一个阵列,因为将出售多种产品。
如果这对网站有帮助:http://threemarchhares.sukeates.com/
我正在使用Laravel 4.我的支付控制器:
public function postPayment() {
$cart = Session::get('cart');
$allProducts = [];
foreach($cart->aContents as $productID=>$quantity){
$product = Product::find($productID);
$allProducts[] = array('name' => $product->name, 'quantity' => $quantity, 'price'=> $product->price);
}
$params = array(
'cancelUrl' => \URL::to('cancel_order'),
'returnUrl' => \URL::to('payment_success'),
'amount' => Input::get('price'),
'currency' => Input::get('currency'),
'description' => Input::get('name'), //I assume this is wrong as it doesn't work.
);
Session::put('params', $params);
Session::save();
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('*****');
$gateway->setPassword('****');
$gateway->setSignature('***');
$gateway->setTestMode(false);
$response = $gateway->purchase($params)->setItems($allProducts)->send();
$data = $response->getData();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
}
public function getSuccessPayment()
{
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('****');
$gateway->setPassword('****');
$gateway->setSignature('*****');
$gateway->setTestMode(false);
$params = Session::get('params');
$response = $gateway->completePurchase($params)->send();
$paypalResponse = $response->getData(); // this is the raw response object
if(isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
等
答案 0 :(得分:1)
你的假设是正确的。一般来说,从输入中填写付款数据是个坏主意。相反,您应该使用产品中的数据:
'amount' => $product->price,
'currency' => 'USD',
'description' => $product->description,
否则用户可以在html中修改价格并享受便宜的结账;)
答案 1 :(得分:0)
当您发送' completePurchase'时,您需要再次发送项目信息 。请求。
$response = $gateway->completePurchase($params)->setItems($allProducts)->send();