From 8d35966a3f1c55944b551afcf9e71aaf91c7071b Mon Sep 17 00:00:00 2001 From: SanketChodavadiya Date: Thu, 20 Apr 2023 14:44:48 +0530 Subject: [PATCH 1/2] Updated giropay source property and description --- includes/api/class-wc-checkoutcom-api-request.php | 9 ++++++++- includes/api/class-wc-checkoutcom-apm-method.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/api/class-wc-checkoutcom-api-request.php b/includes/api/class-wc-checkoutcom-api-request.php index 3b43bd9c..06fdc3e3 100644 --- a/includes/api/class-wc-checkoutcom-api-request.php +++ b/includes/api/class-wc-checkoutcom-api-request.php @@ -252,13 +252,20 @@ private static function get_request_param( WC_Order $order, $arg, $subscription $checkout = new Checkout_SDK(); $payment = $checkout->get_payment_request(); - $payment->source = $method; $payment->capture = $auto_capture; $payment->amount = $amount_cents; $payment->currency = $order->get_currency(); $payment->reference = $order->get_order_number(); $payment->payment_type = PaymentType::$regular; + if ( 'giropay' === $method->type && cko_is_nas_account() ) { + $payment->description = $method->purpose; + + unset( $method->purpose ); + } + + $payment->source = $method; + $email = $post_data['billing_email']; $name = $post_data['billing_first_name'] . ' ' . $post_data['billing_last_name']; diff --git a/includes/api/class-wc-checkoutcom-apm-method.php b/includes/api/class-wc-checkoutcom-apm-method.php index dcbca2e2..0629cdc5 100644 --- a/includes/api/class-wc-checkoutcom-apm-method.php +++ b/includes/api/class-wc-checkoutcom-apm-method.php @@ -118,7 +118,7 @@ public function qpay() { public function giropay() { $method = new RequestGiropaySource(); - $method->purpose = self::$order_info->get_order_number() . '-' . $_SERVER['HTTP_HOST']; + $method->purpose = 'Giropay by Checkout.com'; return $method; } From 754a268823b3856a7c8893936d96b42705c49069 Mon Sep 17 00:00:00 2001 From: SanketChodavadiya Date: Thu, 20 Apr 2023 14:48:17 +0530 Subject: [PATCH 2/2] Fix PHPCS issue --- includes/api/class-wc-checkoutcom-api-request.php | 5 ++++- includes/class-wc-gateway-checkout-com-cards.php | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/api/class-wc-checkoutcom-api-request.php b/includes/api/class-wc-checkoutcom-api-request.php index 06fdc3e3..d135a426 100644 --- a/includes/api/class-wc-checkoutcom-api-request.php +++ b/includes/api/class-wc-checkoutcom-api-request.php @@ -44,6 +44,7 @@ class WC_Checkoutcom_Api_Request { * @param WC_Order $order Order object. * @param array $arg Arguments. * @param string $subscription Subscription renewal flag. + * @param bool $retry_idempotency_key Retry idempotency. * * @return array */ @@ -68,7 +69,7 @@ public static function create_payment( WC_Order $order, $arg, $subscription = nu // Append time. if ( true === $retry_idempotency_key ) { - $cko_idempotency_key .= '-' . date( 'Y-m-d h:i:s' ); + $cko_idempotency_key .= '-' . gmdate( 'Y-m-d h:i:s' ); } // Call to create charge. @@ -1449,6 +1450,8 @@ public static function is_using_saved_payment_method() { /** * Checks if URL is giving 200 OK response by pinging. * + * @param string $url URL. + * * @return bool */ public static function is_url_response_ok( $url ) { diff --git a/includes/class-wc-gateway-checkout-com-cards.php b/includes/class-wc-gateway-checkout-com-cards.php index 7016b08a..2dfba12a 100644 --- a/includes/class-wc-gateway-checkout-com-cards.php +++ b/includes/class-wc-gateway-checkout-com-cards.php @@ -479,10 +479,10 @@ public function process_payment( $order_id ) { // Create payment with card token. $result = (array) WC_Checkoutcom_Api_Request::create_payment( $order, $arg ); - if ( isset( $result['3d_redirection_error'] ) && true === $result['3d_redirection_error'] ) { - // Retry Create payment with card token. - $result = (array) WC_Checkoutcom_Api_Request::create_payment( $order, $arg, null, true ); - } + if ( isset( $result['3d_redirection_error'] ) && true === $result['3d_redirection_error'] ) { + // Retry Create payment with card token. + $result = (array) WC_Checkoutcom_Api_Request::create_payment( $order, $arg, null, true ); + } // check if result has error and return error message. if ( isset( $result['error'] ) && ! empty( $result['error'] ) ) {