mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Map the "Order intent"
This commit is contained in:
parent
7a03bda2ac
commit
3e5f151bbb
1 changed files with 22 additions and 1 deletions
|
@ -37,7 +37,8 @@ class SettingsTabMapHelper {
|
|||
'subtotal_mismatch_behavior' => 'subtotal_adjustment',
|
||||
'landing_page' => 'landing_page',
|
||||
'smart_button_language' => 'button_language',
|
||||
'prefix' => 'invoice_prefix',
|
||||
'prefix' => 'invoice_prefix',
|
||||
'intent' => '',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,6 +59,9 @@ class SettingsTabMapHelper {
|
|||
case 'landing_page':
|
||||
return $this->mapped_landing_page_value( $settings_model );
|
||||
|
||||
case 'intent':
|
||||
return $this->mapped_intent_value( $settings_model );
|
||||
|
||||
default:
|
||||
return $settings_model[ $new_key ] ?? null;
|
||||
}
|
||||
|
@ -99,4 +103,21 @@ class SettingsTabMapHelper {
|
|||
: ApplicationContext::LANDING_PAGE_NO_PREFERENCE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the mapped value for the order intent from the new settings.
|
||||
*
|
||||
* @param array<string, scalar|array> $settings_model The new settings model data as an array.
|
||||
* @return 'AUTHORIZE'|'CAPTURE'|null The mapped 'intent' setting value.
|
||||
*/
|
||||
protected function mapped_intent_value( array $settings_model ): ?string {
|
||||
$authorize_only = $settings_model['authorize_only'] ?? null;
|
||||
$capture_virtual_orders = $settings_model['capture_virtual_orders'] ?? null;
|
||||
|
||||
if ( is_null( $authorize_only ) && is_null( $capture_virtual_orders ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $authorize_only ? 'AUTHORIZE' : 'CAPTURE';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue