我正在尝试创建一个与WorldPay一起使用的支付网关,所以我基本上是在攻击PayPal网关以实现结果。
我已经将所有内容连接到WorldPay测试页并正确传递数据,除了一个字段 - 金额。
我需要动态传递的金额,但WorldPay仅提供硬编码金额的说明。
我在这里看了几篇关于与WorldPay集成的其他帖子,但似乎没有任何帮助。
我正在本地构建这个,所以不幸的是没有任何链接。
我在这里看到的页面是: WORLDPAY Integration using php Validating payment amounts with WorldPay
我认为这是我需要修改以获得所需结果的代码:
如果有人可以告诉我我做错了什么,或者指出我正确的方向,我真的很感激。
提前感谢您的时间和帮助。
/**
* Retreive the paypal vars needed to send to the gatway to proceed with payment
* @param EM_Booking $EM_Booking
*/
function get_paypal_vars($EM_Booking){
global $wp_rewrite, $EM_Notices;
$notify_url = $this->get_payment_return_url();
$paypal_vars = array(
'instId' => '211616',
'testMode' => '100',
'business' => get_option('em_'. $this->gateway . "_email" ),
'authMode' => 'A',
'upload' => 1,
'amount' => $price(),
'currency' => get_option('dbem_bookings_currency', 'GBP'),
'desc' => 'Description Goes Here',
'accId1' => '211616',
'cartId' => 'temp123',
'notify_url' =>$notify_url,
'charset' => 'UTF-8'
);
if( get_option('em_'. $this->gateway . "_lc" ) ){
$paypal_vars['lc'] = get_option('em_'. $this->gateway . "_lc" );
}
//tax is added regardless of whether included in ticket price, otherwise we can't calculate post/pre tax discounts
if( $EM_Booking->get_price_taxes() > 0 ){
$paypal_vars['tax_cart'] = round($EM_Booking->get_price_taxes(), 2);
}
if( get_option('em_'. $this->gateway . "_return" ) != "" ){
$paypal_vars['return'] = get_option('em_'. $this->gateway . "_return" );
}
if( get_option('em_'. $this->gateway . "_cancel_return" ) != "" ){
$paypal_vars['cancel_return'] = get_option('em_'. $this->gateway . "_cancel_return" );
}
if( get_option('em_'. $this->gateway . "_format_logo" ) !== false ){
$paypal_vars['cpp_logo_image'] = get_option('em_'. $this->gateway . "_format_logo" );
}
if( get_option('em_'. $this->gateway . "_border_color" ) !== false ){
$paypal_vars['cpp_cart_border_color'] = get_option('em_'. $this->gateway . "_format_border" );
}
$count = 1;
foreach( $EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking ){ /* @var $EM_Ticket_Booking EM_Ticket_Booking */
//divide price by spaces for per-ticket price
//we divide this way rather than by $EM_Ticket because that can be changed by user in future, yet $EM_Ticket_Booking will change if booking itself is saved.
$price = $EM_Ticket_Booking->get_price() / $EM_Ticket_Booking->get_spaces();
if( $price > 0 ){
$paypal_vars['item_name_'.$count] = wp_kses_data($EM_Ticket_Booking->get_ticket()->name);
$paypal_vars['quantity_'.$count] = $EM_Ticket_Booking->get_spaces();
$paypal_vars['amount_'.$count] = round($price,2);
$count++;
}
}
//calculate discounts, if any:
$discount = $EM_Booking->get_price_discounts_amount('pre') + $EM_Booking->get_price_discounts_amount('post');
if( $discount > 0 ){
$paypal_vars['discount_amount_cart'] = $discount;
}
return apply_filters('em_gateway_paypal_get_paypal_vars', $paypal_vars, $EM_Booking, $this);
}
答案 0 :(得分:0)
分类了。
不确定它是否适用于将来的任何人,但更改以下行:
'amount' => $price(),
到
'amount' => $EM_Booking->get_price(),
做得很好!