0

WorldPay で動作する支払いゲートウェイを作成しようとしているので、基本的には PayPal ゲートウェイをハッキングして結果を達成しています。

WorldPay テスト ページにすべて接続し、データを正しく渡すことができました。ただし、1 つのフィールド (金額) を除きます。

金額を動的に渡す必要がありますが、WorldPay はハードコードされた金額の指示しか提供しません。

ここで、WorldPay との統合について話している他のいくつかの投稿を見てきましたが、役に立ちそうなものは何もありません。

私はこれをローカルで構築しているので、残念ながらリンクはありません。

ここですでに見たページは次の とおりです。 PHP を使用した WORLDPAY の統合 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 に答える