Почему выдает ошибку после нажатия кнопки «Оформить заказ» на странице оформления заказа?Php

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Почему выдает ошибку после нажатия кнопки «Оформить заказ» на странице оформления заказа?

Сообщение Anonymous »

Это мой код на странице оформления заказа. Я разработал для него собственный плагин платежного шлюза, но когда я пытаюсь нажать кнопку размещения заказа, он не отправляет параметры запроса и не получает ответа?

публичная функция process_pay($order_id) {
глобальный $woocommerce;

// Get this Order's information so that we know
// who to charge and how much
$customer_order = new WC_Order( $order_id );

// Are we testing right now or is it a real transaction
$Mode = ( $this->Mode == "yes" ) ? 'TRUE' : 'FALSE';

// Decide which URL to post to
$environment_url = ( "FALSE" == $Mode )
? 'https://www.qpayindia.com/wwws/Payment/ ... tails.aspx'
: 'https://www.qpayindia.com/wwws/Payment/ ... tails.aspx';

// This is where the fun stuff begins
$payload = array(
// Authorize.net Credentials and API Info
"QPayID" => $this->QPayID,
"QPayPWD" => $this->QPayPWD,
"CaseNumber" => $this->CaseNumber,

"Mode" => $this->Mode,
"Currency" => $this->Currency,
"Amount" => $customer_order->order_total,

"ResponseURL" => $customer_order->get_checkout_payment_url(),
"OrderID" => str_replace( "#", "", $customer_order->get_order_number() ),

// Some Customer Information
"x_cust_id" => $customer_order->user_id,
"x_customer_ip" => $_SERVER['REMOTE_ADDR'],*/

);

// Send this payload to Authorize.net for processing
$response = wp_remote_post( $environment_url, array(
'method' => 'POST',
'body' => http_build_query( $payload ),
'timeout' => 90,
'sslverify' => false,
) );

if ( is_wp_error( $response ) )
throw new Exception( __( 'We are currently experiencing problems trying to connect to this payment gateway. Sorry for the inconvenience.', 'spyr-authorizenet-aim' ) );

if ( empty( $response['body'] ) )
throw new Exception( __( 'Authorize.net\'s Response was empty.', 'spyr-authorizenet-aim' ) );

// Retrieve the body's resopnse if no errors found
$response_body = wp_remote_retrieve_body( $response );

// Parse the response into something we can read
foreach ( preg_split( "/\r?\n/", $response_body ) as $line ) {
$resp = explode( "|", $line );
}

// Get the values we need
$r['ResponseCode'] = $resp[0];
$r['response_sub_code'] = $resp[1];
$r['response_reason_code'] = $resp[2];
$r['Message'] = $resp[3];

// Test the code to know if the transaction went through or not.
// 1 or 4 means the transaction was a success
if ( ( $r['ResponseCode'] == 100 ) || ( $r['ResponseCode'] == 200 ) ) {
// Payment has been successful
$customer_order->add_order_note( __( 'Qpay payment completed.', 'spyr-authorizenet-aim' ) );

// Mark order as Paid
$customer_order->payment_complete();

// Empty the cart (Very important step)
$woocommerce->cart->empty_cart();

// Redirect to thank you page
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $customer_order ),
);
} else {
// Transaction was not succesful
// Add notice to the cart
wc_add_notice( $r['Message'], 'error' );
// Add note to the order for your reference
$customer_order->add_order_note( 'Error: '. $r['Message'] );
}

}


Подробнее здесь: https://stackoverflow.com/questions/335 ... k-out-page
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»