Это мой код на странице оформления заказа. Я разработал для него собственный плагин платежного шлюза, но когда я пытаюсь нажать кнопку размещения заказа, он не отправляет параметры запроса и не получает ответа?
публичная функция 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
Почему выдает ошибку после нажатия кнопки «Оформить заказ» на странице оформления заказа? ⇐ Php
Кемеровские программисты php общаются здесь
1728943337
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/PaymentDetails.aspx'
: 'https://www.qpayindia.com/wwws/Payment/PaymentDetails.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'] );
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/33564620/why-it-gives-an-error-after-click-on-place-order-button-on-check-out-page[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия