【问题标题】:Worldpay Payment Gateway - Passing Data DynamicallyWorldpay 支付网关 - 动态传递数据
【发布时间】:2013-08-28 00:46:23
【问题描述】:

我正在尝试创建一个与 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);
}

【问题讨论】:

  • 这是一个无耻的颠簸,虽然我认为需要修改的主线是:'amount' => $price(),如果有人能看到我'我做错了,我将不胜感激!再次感谢!

标签: php arrays payment-gateway worldpay


【解决方案1】:

整理好了

不确定它是否会在未来适用于任何人,但将线路更改为:

'amount' => $price(),

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

做得很好!

【讨论】:

    猜你喜欢
    • 2018-11-07
    • 2017-12-29
    • 2020-03-10
    • 2021-07-24
    • 2012-01-29
    • 1970-01-01
    • 2013-05-22
    • 2022-01-11
    • 1970-01-01
    相关资源
    最近更新 更多