Skip to content
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

Merged
merged 25 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
761ad35
proof of concept
rafaelzaleski Jan 16, 2025
cb681c0
Fix icon reference in payment methods map
rafaelzaleski Jan 22, 2025
167cec8
Load ACH conditionally in the payment methods map
rafaelzaleski Jan 22, 2025
5961260
Load Stripe ID from WC_Stripe_Payment_Methods
rafaelzaleski Jan 22, 2025
007f3e3
Add feature flag check when registering PMs
rafaelzaleski Jan 22, 2025
89eead6
Add placeholder icon
rafaelzaleski Jan 22, 2025
a80133d
Update unit tests
rafaelzaleski Jan 24, 2025
918613f
Add test for ACH availability in the US
rafaelzaleski Jan 24, 2025
cb2ea5d
Merge branch 'develop' into add/3747-ach-payment-processing
rafaelzaleski Jan 28, 2025
d56bb5b
Fix lint errors
rafaelzaleski Jan 28, 2025
fa6d818
Remove unused vars in unit tests
rafaelzaleski Jan 28, 2025
9cbc3b8
Remove unused var
rafaelzaleski Jan 28, 2025
973e13d
Revert "Remove unused vars in unit tests"
rafaelzaleski Jan 28, 2025
c4899c2
Remove unused vars in tests
rafaelzaleski Jan 28, 2025
c5d5796
Fix error in blocks checkout
rafaelzaleski Jan 28, 2025
1856210
Use Generic Bank Icon
rafaelzaleski Jan 28, 2025
a5617d3
Remove css from bank debit icon
rafaelzaleski Jan 28, 2025
a85682e
Remove unused svg
rafaelzaleski Jan 28, 2025
850cc46
Merge branch 'develop' into add/3747-ach-payment-processing
bborman22 Jan 30, 2025
ee74a0c
Add icon for shortcode checkout
rafaelzaleski Jan 30, 2025
697182f
Refactor how the payment method class is loaded.
rafaelzaleski Jan 30, 2025
e3d34c8
Remove additional space
rafaelzaleski Jan 30, 2025
58598fc
Revert "Refactor how the payment method class is loaded."
rafaelzaleski Jan 30, 2025
0d7ab32
fix indentation
rafaelzaleski Jan 30, 2025
ee4a5ad
Merge branch 'develop' into add/3747-ach-payment-processing
rafaelzaleski Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update unit tests
rafaelzaleski committed Jan 24, 2025
commit a80133d762e9625338a03e9413118e53546cde0b
104 changes: 67 additions & 37 deletions tests/phpunit/test-class-wc-stripe-upe-payment-method.php
Original file line number Diff line number Diff line change
@@ -27,6 +27,23 @@ class WC_Stripe_UPE_Payment_Method_Test extends WP_UnitTestCase {
],
];

/**
* Base template for ACH Direct Debit payment method.
*/
const MOCK_ACH_PAYMENT_METHOD_TEMPLATE = [
'id' => 'pm_mock_payment_method_ach',
'type' => WC_Stripe_Payment_Methods::ACH,
WC_Stripe_Payment_Methods::ACH => [
'account_holder_type' => 'individual',
'account_type' => 'checking',
'bank_name' => 'TEST BANK',
'fingerprint' => 'Ih3foEnRvLXShyfB',
'last4' => '1000',
'payment_reference' => '091000015001234',
'routing_number' => '110000000',
],
];

/**
* Base template for Stripe link payment method.
*/
@@ -73,49 +90,51 @@ class WC_Stripe_UPE_Payment_Method_Test extends WP_UnitTestCase {
* Mock capabilities object from Stripe response--all inactive.
*/
const MOCK_INACTIVE_CAPABILITIES_RESPONSE = [
'alipay_payments' => 'inactive',
'bancontact_payments' => 'inactive',
'card_payments' => 'inactive',
'eps_payments' => 'inactive',
'giropay_payments' => 'inactive',
'klarna_payments' => 'inactive',
'affirm_payments' => 'inactive',
'clearpay_afterpay_payments' => 'inactive',
'ideal_payments' => 'inactive',
'p24_payments' => 'inactive',
'sepa_debit_payments' => 'inactive',
'sofort_payments' => 'inactive',
'transfers' => 'inactive',
'multibanco_payments' => 'inactive',
'boleto_payments' => 'inactive',
'oxxo_payments' => 'inactive',
'link_payments' => 'inactive',
'wechat_pay_payments' => 'inactive',
'alipay_payments' => 'inactive',
'bancontact_payments' => 'inactive',
'card_payments' => 'inactive',
'eps_payments' => 'inactive',
'giropay_payments' => 'inactive',
'klarna_payments' => 'inactive',
'affirm_payments' => 'inactive',
'clearpay_afterpay_payments' => 'inactive',
'ideal_payments' => 'inactive',
'p24_payments' => 'inactive',
'sepa_debit_payments' => 'inactive',
'sofort_payments' => 'inactive',
'transfers' => 'inactive',
'multibanco_payments' => 'inactive',
'boleto_payments' => 'inactive',
'oxxo_payments' => 'inactive',
'link_payments' => 'inactive',
'wechat_pay_payments' => 'inactive',
'us_bank_account_ach_payments' => 'inactive',
];

/**
* Mock capabilities object from Stripe response--all active.
*/
const MOCK_ACTIVE_CAPABILITIES_RESPONSE = [
'alipay_payments' => 'active',
'bancontact_payments' => 'active',
'card_payments' => 'active',
'eps_payments' => 'active',
'giropay_payments' => 'active',
'klarna_payments' => 'active',
'affirm_payments' => 'active',
'clearpay_afterpay_payments' => 'active',
'ideal_payments' => 'active',
'p24_payments' => 'active',
'sepa_debit_payments' => 'active',
'sofort_payments' => 'active',
'transfers' => 'active',
'multibanco_payments' => 'active',
'boleto_payments' => 'active',
'oxxo_payments' => 'active',
'link_payments' => 'active',
'cashapp_payments' => 'active',
'wechat_pay_payments' => 'active',
'alipay_payments' => 'active',
'bancontact_payments' => 'active',
'card_payments' => 'active',
'eps_payments' => 'active',
'giropay_payments' => 'active',
'klarna_payments' => 'active',
'affirm_payments' => 'active',
'clearpay_afterpay_payments' => 'active',
'ideal_payments' => 'active',
'p24_payments' => 'active',
'sepa_debit_payments' => 'active',
'sofort_payments' => 'active',
'transfers' => 'active',
'multibanco_payments' => 'active',
'boleto_payments' => 'active',
'oxxo_payments' => 'active',
'link_payments' => 'active',
'cashapp_payments' => 'active',
'wechat_pay_payments' => 'active',
'us_bank_account_ach_payments' => 'active',
];

/**
@@ -245,6 +264,7 @@ public function test_payment_methods_show_correct_default_outputs() {
$boleto_method = $this->mock_payment_methods['boleto'];
$oxxo_method = $this->mock_payment_methods['oxxo'];
$wechat_pay_method = $this->mock_payment_methods['wechat_pay'];
$ach_method = $this->mock_payment_methods['us_bank_account'];

$this->assertEquals( WC_Stripe_Payment_Methods::CARD, $card_method->get_id() );
$this->assertEquals( 'Credit / Debit Card', $card_method->get_label() );
@@ -345,6 +365,13 @@ public function test_payment_methods_show_correct_default_outputs() {
$this->assertFalse( $wechat_pay_method->is_reusable() );
$this->assertEquals( WC_Stripe_Payment_Methods::WECHAT_PAY, $wechat_pay_method->get_retrievable_type() );
$this->assertEquals( '', $wechat_pay_method->get_testing_instructions() );

$this->assertEquals( WC_Stripe_Payment_Methods::ACH, $ach_method->get_id() );
$this->assertEquals( 'ACH Direct Debit', $ach_method->get_label() );
$this->assertEquals( 'ACH Direct Debit', $ach_method->get_title() );
$this->assertFalse( $ach_method->is_reusable() ); // Currently non-reusable; future improvement may change this.
$this->assertEquals( WC_Stripe_Payment_Methods::ACH, $ach_method->get_retrievable_type() );
$this->assertEquals( '', $ach_method->get_testing_instructions() );
}

/**
@@ -375,6 +402,7 @@ public function test_card_payment_method_capability_is_always_enabled() {
$multibanco_method = $this->mock_payment_methods['multibanco'];
$oxxo_method = $this->mock_payment_methods['oxxo'];
$wechat_pay_method = $this->mock_payment_methods['wechat_pay'];
$ach_method = $this->mock_payment_methods['us_bank_account'];

$this->assertTrue( $card_method->is_enabled_at_checkout() );
$this->assertFalse( $klarna_method->is_enabled_at_checkout() );
@@ -390,6 +418,7 @@ public function test_card_payment_method_capability_is_always_enabled() {
$this->assertFalse( $multibanco_method->is_enabled_at_checkout() );
$this->assertFalse( $oxxo_method->is_enabled_at_checkout() );
$this->assertFalse( $wechat_pay_method->is_enabled_at_checkout() );
$this->assertFalse( $ach_method->is_enabled_at_checkout() );
}

/**
@@ -605,6 +634,7 @@ public function test_payment_methods_are_reusable_if_cart_contains_subscription(

public function test_payment_methods_support_custom_name_and_description() {
$payment_method_ids = [
WC_Stripe_Payment_Methods::ACH,
WC_Stripe_Payment_Methods::CARD,
WC_Stripe_Payment_Methods::KLARNA,
WC_Stripe_Payment_Methods::AFTERPAY_CLEARPAY,
Loading