@@ -1039,6 +1039,17 @@ private function process_payment_with_confirmation_token( int $order_id ) {
1039
1039
}
1040
1040
}
1041
1041
1042
+ if ( $ payment_information ['has_subscription ' ] ) {
1043
+ $ this ->maybe_update_source_on_subscription_order (
1044
+ $ order ,
1045
+ (object ) [
1046
+ 'payment_method ' => $ payment_method_id ,
1047
+ 'customer ' => $ payment_information ['customer ' ],
1048
+ ],
1049
+ 'stripe ' // TODO: get the correct payment gateway ID
1050
+ );
1051
+ }
1052
+
1042
1053
$ return_url = $ this ->get_return_url ( $ order );
1043
1054
1044
1055
return [
@@ -2213,6 +2224,7 @@ protected function prepare_payment_information_from_request( WC_Order $order ) {
2213
2224
'payment_method_details ' => [],
2214
2225
'payment_type ' => 'single ' , // single | recurring.
2215
2226
'capture_method ' => $ capture_method ,
2227
+ 'save_payment_method_to_store ' => $ save_payment_method_to_store ,
2216
2228
];
2217
2229
2218
2230
if ( 'us_bank_account ' === $ selected_payment_type ) {
@@ -2224,22 +2236,22 @@ protected function prepare_payment_information_from_request( WC_Order $order ) {
2224
2236
unset( $ payment_information ['payment_method_details ' ] );
2225
2237
unset( $ payment_information ['capture_method ' ] );
2226
2238
2227
- $ confirmation_token_id = sanitize_text_field ( wp_unslash ( $ _POST ['wc-stripe-confirmation-token ' ] ?? '' ) );
2228
- $ payment_information ['confirmation_token ' ] = $ confirmation_token_id ;
2229
- $ payment_information ['save_payment_method_to_store ' ] = false ; // TODO Is this needed for subscriptions?
2230
- $ payment_information ['payment_method_options ' ] = $ this ->get_payment_method_options_for_confirmation_tokens (
2239
+ $ confirmation_token_id = sanitize_text_field ( wp_unslash ( $ _POST ['wc-stripe-confirmation-token ' ] ?? '' ) );
2240
+ $ payment_information ['confirmation_token ' ] = $ confirmation_token_id ;
2241
+ $ payment_information ['payment_method_options ' ] = $ this ->get_payment_method_options_for_confirmation_tokens (
2231
2242
$ selected_payment_type ,
2232
2243
[
2233
2244
'capture_method ' => $ capture_method ,
2234
2245
'has_subscription ' => $ payment_information ['has_subscription ' ],
2235
2246
]
2236
2247
);
2248
+ // TODO: remove this once Amazon Pay supports saved payment methods
2249
+ $ payment_information ['save_payment_method_to_store ' ] = false ;
2237
2250
} else {
2238
- $ payment_method_details = WC_Stripe_API::get_payment_method ( $ payment_method_id );
2239
- $ payment_information ['payment_method ' ] = $ payment_method_id ;
2240
- $ payment_information ['payment_method_details ' ] = $ payment_method_details ;
2241
- $ payment_information ['save_payment_method_to_store ' ] = $ save_payment_method_to_store ;
2242
- $ payment_information ['payment_method_options ' ] = $ this ->get_payment_method_options (
2251
+ $ payment_method_details = WC_Stripe_API::get_payment_method ( $ payment_method_id );
2252
+ $ payment_information ['payment_method ' ] = $ payment_method_id ;
2253
+ $ payment_information ['payment_method_details ' ] = $ payment_method_details ;
2254
+ $ payment_information ['payment_method_options ' ] = $ this ->get_payment_method_options (
2243
2255
$ selected_payment_type ,
2244
2256
$ order ,
2245
2257
$ payment_method_details
0 commit comments