Skip to content

Commit 0bf91e9

Browse files
james-allana-danae
andcommitted
Capture off-session payments immediately so we can fetch charge information (#3281)
* Capture off-session payments immediately so we can fetch charge information * Update unit tests * Remove capture_method from the expected missing keys * Add changelog entry --------- Co-authored-by: Danae Millan <[email protected]>
1 parent 9c71d6b commit 0bf91e9

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
= 8.5.2 - xxxx-xx-xx =
44
* Fix - Fixed errors when using Link to purchase subscription products that could lead to duplicate payment attempts.
55
* Fix - Prevent failures creating SetupIntents when using a non-saved payment method on the Legacy checkout experience.
6+
* Fix - Ensure immediate balance transaction assignment for subscription renewals by specifying capture_method => automatic in Stripe payment intents.
67
* Dev - Bump L-2 versions for PHP tests.
78
* Dev - Bump WordPress "tested up to" version to 6.6.
89

includes/abstracts/abstract-wc-stripe-payment-gateway.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ public function create_and_confirm_intent_for_off_session( $order, $prepared_sou
17541754
'off_session' => 'true',
17551755
'confirm' => 'true',
17561756
'confirmation_method' => 'automatic',
1757+
'capture_method' => 'automatic',
17571758
];
17581759

17591760
if ( isset( $full_request['statement_descriptor'] ) ) {

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
131131
= 8.5.2 - xxxx-xx-xx =
132132
* Fix - Fixed errors when using Link to purchase subscription products that could lead to duplicate payment attempts.
133133
* Fix - Prevent failures creating SetupIntents when using a non-saved payment method on the Legacy checkout experience.
134+
* Fix - Ensure immediate balance transaction assignment for subscription renewals by specifying capture_method => automatic in Stripe payment intents.
134135
* Dev - Bump L-2 versions for PHP tests.
135136
* Dev - Bump WordPress "tested up to" version to 6.6.
136137

tests/phpunit/test-wc-stripe-sub-renewal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function test_renewal_successful() {
145145
'off_session' => 'true',
146146
'confirm' => 'true',
147147
'confirmation_method' => 'automatic',
148+
'capture_method' => 'automatic',
148149
];
149150
foreach ( $expected_request_body_values as $key => $value ) {
150151
$this->assertArrayHasKey( $key, $request_args['body'] );
@@ -184,7 +185,6 @@ public function test_renewal_successful() {
184185
// Assert: the request body does not contains these keys.
185186
$expected_missing_request_body_keys = [
186187
'capture', // No need to capture with a payment intent.
187-
'capture_method', // The default ('automatic') is what we want in this case, so we leave it off.
188188
'expand[]',
189189
];
190190
foreach ( $expected_missing_request_body_keys as $key ) {

0 commit comments

Comments
 (0)