-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ACH Direct Debit payment processing for non-saved bank accounts #3761
Changes from all commits
761ad35
cb681c0
167cec8
5961260
007f3e3
89eead6
a80133d
918613f
cb2ea5d
d56bb5b
fa6d818
9cbc3b8
973e13d
c4899c2
c5d5796
1856210
a5617d3
a85682e
850cc46
ee74a0c
697182f
e3d34c8
58598fc
0d7ab32
ee4a5ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
import IconWithShell from '../styles/icon-with-shell'; | ||
import icon from './icon.svg'; | ||
|
||
const BankDebitIcon = ( props ) => <IconWithShell { ...props } src={ icon } />; | ||
|
||
export default BankDebitIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Class that handles ACH Direct Debit as a UPE Payment Method. | ||
* | ||
* @extends WC_Stripe_UPE_Payment_Method | ||
*/ | ||
class WC_Stripe_UPE_Payment_Method_ACH extends WC_Stripe_UPE_Payment_Method { | ||
|
||
/** | ||
* Stripe's internal identifier for ACH Direct Debit. | ||
*/ | ||
const STRIPE_ID = WC_Stripe_Payment_Methods::ACH; | ||
|
||
/** | ||
* Constructor for ACH Direct Debit payment method. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
|
||
$this->stripe_id = self::STRIPE_ID; | ||
$this->title = __( 'ACH Direct Debit', 'woocommerce-gateway-stripe' ); | ||
$this->is_reusable = false; // Usually ACH requires verification per transaction. | ||
$this->supported_currencies = [ 'USD' ]; | ||
$this->supported_countries = [ 'US' ]; | ||
$this->label = __( 'ACH Direct Debit', 'woocommerce-gateway-stripe' ); | ||
$this->description = __( 'Pay directly from your US bank account via ACH.', 'woocommerce-gateway-stripe' ); | ||
} | ||
|
||
/** | ||
* Checks if ACH is available for the Stripe account's country. | ||
* | ||
* @return bool True if US-based account; false otherwise. | ||
*/ | ||
public function is_available_for_account_country() { | ||
return in_array( WC_Stripe::get_instance()->account->get_account_country(), $this->supported_countries, true ); | ||
} | ||
|
||
/** | ||
* Returns string representing payment method type | ||
* to query to retrieve saved payment methods from Stripe. | ||
*/ | ||
public function get_retrievable_type() { | ||
return $this->get_id(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,8 @@ class WC_Stripe_UPE_Payment_Gateway_Test extends WP_UnitTestCase { | |
public function set_up() { | ||
parent::set_up(); | ||
|
||
update_option( WC_Stripe_Feature_Flags::LPM_ACH_FEATURE_FLAG_NAME, 'yes' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you double-check that this is working? For Bacs, I had to place it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to do that in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seemed to work for me. All the unit tests passed and when I remove this line the |
||
|
||
$mock_account = $this->getMockBuilder( 'WC_Stripe_Account' ) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
@@ -181,6 +183,11 @@ public function set_up() { | |
); | ||
} | ||
|
||
public function tear_down() { | ||
parent::tear_down(); | ||
delete_option( WC_Stripe_Feature_Flags::LPM_ACH_FEATURE_FLAG_NAME ); | ||
} | ||
|
||
/** | ||
* Helper function to set $_POST vars for saved payment method. | ||
*/ | ||
|
@@ -258,6 +265,7 @@ public function get_upe_available_payment_methods_provider() { | |
'US', | ||
[ | ||
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID, | ||
WC_Stripe_UPE_Payment_Method_ACH::STRIPE_ID, | ||
WC_Stripe_UPE_Payment_Method_Alipay::STRIPE_ID, | ||
WC_Stripe_UPE_Payment_Method_Klarna::STRIPE_ID, | ||
WC_Stripe_UPE_Payment_Method_Affirm::STRIPE_ID, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that Bacs above uses a different approach to checking if the method should be enabled / added to the list. I'd like if we could keep the approach standardized (as much as possible). I'd prefer the approach in this PR just because it matches what's been used for Sofort and Giropay, but I'd be curious which is the preferred approach between @asumaran and @rafaelzaleski. Depending on which is preferred, this PR may not need changes and instead a change for Bacs would be required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, I was wondering if it's possible / preferrable to add an "enabled" property to the payment method class that would check against the feature flag? This could eliminate the need to check which class we're working on in the loop and abstract things a bit. I don't think it's necessary for this PR, but wondering if this would be desirable as a future enhancement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the same approach https://github.com/woocommerce/woocommerce-gateway-stripe/pull/3775/files#diff-9356f87eb3d1b3fbc63a5201e8ccc38668d392af16d66e94656a3ee8e101820e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I just discussed with @asumaran and the first comment is already addressed here. We can disregard the first comment then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could override the method
is_enabled_at_checkout
(link) and add a check for the feature flag. However, I’d prefer not to load the payment method class at all while it's behind feature flags.