0

我正在尝试创建一个与 WorldPay 一起使用的支付网关,所以我基本上是在破解一个 PayPal 网关来实现结果。

我已经将所有东西都连接到 WorldPay 测试页面并正确传递数据,除了一个字段 - 金额。

我需要动态传递金额,但 WorldPay 仅提供硬编码金额的说明。

我在这里看过其他几篇关于与 WorldPay 集成的帖子,但似乎没有任何帮助。

我正在本地构建它,所以不幸的是没有任何链接。

我在这里看过的页面是: WORLDPAY 使用 php 集成 使用 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);
}
4

1 回答 1

0

整理好了

不确定它是否会适用于将来的任何人,但将线路从:

'amount' => $price(),

'amount' => $EM_Booking->get_price(),

做得很好!

于 2013-08-25T22:25:07.887 回答