Skip to content

Commit

Permalink
Merge pull request #205 from pay-now/release/release-2-4-20
Browse files Browse the repository at this point in the history
Release/release 2 4 20
  • Loading branch information
DeveloperMovecloser authored Mar 31, 2023
2 parents 0b5bf84 + 004bb42 commit b9d9ff9
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pay-now/paynow-woocommerce",
"description": "paynow.pl plugin for WooCommerce",
"license": "GPLv3",
"version": "2.4.19",
"version": "2.4.20",
"authors": [
{
"name": "mElements S.A.",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Tags: payment, payment gateway, paynow, woocommerce, płatności
Requires at least: 4.4
Tested up to: 6.1.1
Requires PHP: 7.1
Stable tag: 2.4.19
Stable tag: 2.4.20
License: GPLv3

**pay**now is a secure online payment by bank transfers, BLIK and card.
Expand Down
9 changes: 7 additions & 2 deletions src/includes/abstract/class-wc-gateway-pay-by-paynow-pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,12 @@ public function process_notification( $payment_id, $status, $external_id, $modif
*/
private function retry_processing_n_times( WC_Order $order, $message, $context = array(), $counter = 3 ) {

$history = $order->get_meta( self::ORDER_META_NOTIFICATION_HISTORY );
$history = $order->get_meta( self::ORDER_META_NOTIFICATION_HISTORY );

if ( ! is_array( $history ) ) {
$history = array();
}

$history_key = sprintf( '%s:%s', $context[ WC_Pay_By_Paynow_PL_Helper::NOTIFICATION_PAYMENT_ID_FIELD_NAME ], $context[ WC_Pay_By_Paynow_PL_Helper::NOTIFICATION_STATUS_FIELD_NAME ] );
if ( ! isset( $history[ $history_key ] ) ) {
$history[ $history_key ] = 0;
Expand Down Expand Up @@ -618,7 +623,7 @@ public function redirect_order_received_page() {
WC_Pay_By_Paynow_PL_Logger::info( 'Received payment status from API. ', $logger_context );
try {
$this->process_notification( $order, $payment_id, $status, gmdate( 'Y-m-d\TH:i:s' ), true );
} catch ( Exception $e ) {
} catch ( Error | Exception $e ) {
WC_Pay_By_Paynow_PL_Logger::error( $e->getMessage(), $logger_context );
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/includes/class-paynow-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function payment_request( WC_Order $order, $return_url, $payment_method_i
return;
}

$return_url = rtrim( $return_url, '?' );

$currency = WC_Pay_By_Paynow_PL_Helper::is_old_wc_version() ? $order->get_order_currency() : $order->get_currency();
$order_id = WC_Pay_By_Paynow_PL_Helper::get_order_id( $order );
$billing_data = $order->get_address();
Expand Down Expand Up @@ -129,18 +131,16 @@ function ( $item ) {
try {
$api_response_object = $payment->authorize( $payment_data, $idempotency_key );

$redirect_url = $api_response_object->getRedirectUrl();
if ( is_null( $redirect_url ) ) {
$redirect_url = $return_url;
if ( $is_blik ) {
$redirect_url .= strpos( $redirect_url, '?' ) !== null ? '&' : '?'
. http_build_query(
array(
'paymentId' => $api_response_object->getPaymentId(),
'confirmBlik' => 1,
)
);
}
$redirect_url = $api_response_object->getRedirectUrl() ?? $return_url;
$redirect_url = rtrim( $redirect_url, '?' );
if ( $is_blik ) {
$redirect_url .= ( strpos( $redirect_url, '?' ) !== false ? '&' : '?' )
. http_build_query(
array(
'paymentId' => $api_response_object->getPaymentId(),
'confirmBlik' => 1,
)
);
}

$payment_data = array(
Expand Down Expand Up @@ -173,7 +173,7 @@ function ( $item ) {
WC_Pay_By_Paynow_PL_Helper::NOTIFICATION_STATUS_FIELD_NAME => PaymentStatus::STATUS_NEW,
WC_Pay_By_Paynow_PL_Helper::NOTIFICATION_PAYMENT_ID_FIELD_NAME => $order_id . '_UNKNOWN',
WC_Pay_By_Paynow_PL_Helper::NOTIFICATION_REDIRECT_URL_FIELD_NAME => $return_url
. strpos( $return_url, '?' ) !== null ? '&' : '?'
. ( strpos( $return_url, '?' ) !== false ? '&' : '?' )
. http_build_query(
array(
'paymentId' => $order_id . '_UNKNOWN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct() {
public function handle_notification() {

if ( ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) || ( ! in_array( filter_input( INPUT_GET, 'wc-api' ), self::ALLOWED_WC_API_PARAM_VALUES, true ) ) ) {
$this->bad_request_response( 'Wrong request' );
$this->prepare_request_response( 'Wrong request' );
exit;
}
$payload = trim( file_get_contents( 'php://input' ) );
Expand Down Expand Up @@ -65,7 +65,7 @@ public function handle_notification() {
$exception->log_context
);
$this->prepare_request_response( $exception->getMessage(), $response_code );
} catch ( Exception $exception ) {
} catch ( Error | Exception $exception ) {
WC_Pay_By_Paynow_PL_Logger::error(
'Payment status notification processor -> unknown error' . $exception->getMessage(),
$notification_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,22 @@ public function get_rest_status( string $order_id, string $token ): WP_REST_Resp

$order = wc_get_order( $order_id );
$response = array();
$return_url = $this->get_return_url( $order );
$return_url = rtrim( $this->get_return_url( $order ), '?' );

$return_url .= strpos( $return_url, '?' ) !== false ? '&' : '?';

if ( $order->get_transaction_id() === $order_id . '_UNKNOWN' ) {
$response = array(
'order_status' => $order->get_status(),
'payment_status' => \Paynow\Model\Payment\Status::STATUS_PENDING,
'redirect_url' => $return_url
. strpos( $return_url, '?' ) !== null ? '&' : '?'
. http_build_query( array( 'paymentId' => $order->get_transaction_id() ) ),
'redirect_url' => $return_url . http_build_query( array( 'paymentId' => $order->get_transaction_id() ) ),
);
} elseif ( self::get_token_hash( $this->gateway->get_signature_key(), array( 'orderId' => (int) $order_id ) ) === $token ) {
$status = $this->gateway->payment_status( $order_id, $order->get_transaction_id() );
$response = array(
'order_status' => $order->get_status(),
'payment_status' => $status,
'redirect_url' => $return_url
. strpos( $return_url, '?' ) !== null ? '&' : '?'
. http_build_query( array( 'paymentId' => $order->get_transaction_id() ) ),
'redirect_url' => $return_url . http_build_query( array( 'paymentId' => $order->get_transaction_id() ) ),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/includes/pay-by-paynow-pl-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function wc_pay_by_paynow_pl_gateway_content_thankyou( $order_id ) {
$paynow_blik = new WC_Gateway_Pay_By_Paynow_PL_Blik_Payment();
if ( ! $order->has_status( wc_get_is_paid_statuses() ) && (int) filter_input( INPUT_GET, 'confirmBlik' ) === 1 ) {
$rest_api_status_url = WC_Gateway_Pay_By_Paynow_PL_Status_Handler::get_rest_api_status_url();
$rest_api_status_url .= strpos( $rest_api_status_url, '?' ) !== null ? '&' : '?'
$rest_api_status_url .= ( strpos( $rest_api_status_url, '?' ) !== false ? '&' : '?' )
. http_build_query(
array(
'orderId' => $order_id,
Expand Down
2 changes: 1 addition & 1 deletion src/pay-by-paynow-pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Pay by paynow.pl
* Plugin URI: https://github.com/pay-now/paynow-woocommerce
* Description: Accepts secure BLIK, credit cards payments and fast online transfers by paynow.pl
* Version: 2.4.19
* Version: 2.4.20
* Requires PHP: 7.1
* Author: mElements S.A.
* Author URI: https://www.paynow.pl
Expand Down

0 comments on commit b9d9ff9

Please sign in to comment.