Skip to content

Commit

Permalink
Merge pull request #349 from checkout/fix/giropay-source-property
Browse files Browse the repository at this point in the history
Giropay source property update
  • Loading branch information
SanketChodavadiya authored Apr 20, 2023
2 parents a28d929 + 754a268 commit 2e51d51
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 12 additions & 2 deletions includes/api/class-wc-checkoutcom-api-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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.
Expand Down Expand Up @@ -252,13 +253,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'];

Expand Down Expand Up @@ -1442,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 ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/api/class-wc-checkoutcom-apm-method.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions includes/class-wc-gateway-checkout-com-cards.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down

0 comments on commit 2e51d51

Please sign in to comment.