Skip to content

Commit

Permalink
Fix issue with saved card before sources were introduced not working c…
Browse files Browse the repository at this point in the history
…loses #555
  • Loading branch information
roykho committed Feb 23, 2018
1 parent 0f97be2 commit 93e6ca6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion includes/abstracts/abstract-wc-stripe-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public function prepare_source( $user_id, $force_save_source = false ) {
$source_id = '';
$wc_token_id = false;
$payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
$is_token = false;

// New CC info was entered and we have a new source to process.
if ( ! empty( $_POST['stripe_source'] ) ) {
Expand Down Expand Up @@ -528,6 +529,7 @@ public function prepare_source( $user_id, $force_save_source = false ) {
}

$source_id = $wc_token->get_token();
$is_token = true;
} elseif ( isset( $_POST['stripe_token'] ) && 'new' !== $_POST['stripe_token'] ) {
$stripe_token = wc_clean( $_POST['stripe_token'] );
$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
Expand All @@ -542,6 +544,7 @@ public function prepare_source( $user_id, $force_save_source = false ) {
} else {
$set_customer = false;
$source_id = $stripe_token;
$is_token = true;
}
}

Expand All @@ -551,7 +554,7 @@ public function prepare_source( $user_id, $force_save_source = false ) {
$customer_id = $customer->get_id() ? $customer->get_id() : false;
}

if ( empty( $source_object ) ) {
if ( empty( $source_object ) && ! $is_token ) {
$source_object = self::get_source_object( $source_id );
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ We will completely remove the older form by version 4.1.0.

= 4.0.7 - 2018-xx-xx =
* Fix - Potential conflict issue when adding payment method from another payment gateway.
* Fix - Issue when using saved card before sources were introduced.
* Add - Description field/setting for Stripe Checkout Modal/popup.

= 4.0.6 - 2018-02-20 =
Expand Down

0 comments on commit 93e6ca6

Please sign in to comment.