Add new eligibility flags to Redux store

This commit is contained in:
Philipp Stracker 2024-10-25 13:01:01 +02:00
parent cc3e52046b
commit 3c577c8b2d
No known key found for this signature in database
3 changed files with 77 additions and 5 deletions

View file

@ -8,6 +8,9 @@ const defaultState = {
useManualConnection: false,
clientId: '',
clientSecret: '',
canUseCasualSelling: false,
canUseVaulting: false,
canUseCardPayments: false,
},
};

View file

@ -37,6 +37,9 @@ class OnboardingProfile extends AbstractDataModel {
'use_manual_connection' => false,
'client_id' => '',
'client_secret' => '',
'can_use_casual_selling' => false,
'can_use_vaulting' => false,
'can_use_card_payments' => false,
);
}
@ -131,4 +134,58 @@ class OnboardingProfile extends AbstractDataModel {
public function set_client_secret( string $client_secret ) : void {
$this->data['client_secret'] = sanitize_text_field( $client_secret );
}
/**
* Gets whether casual selling can be used.
*
* @return bool
*/
public function get_can_use_casual_selling() : bool {
return (bool) $this->data['can_use_casual_selling'];
}
/**
* Sets whether casual selling can be used.
*
* @param bool $can_use_casual_selling Whether casual selling can be used.
*/
public function set_can_use_casual_selling( bool $can_use_casual_selling ) : void {
$this->data['can_use_casual_selling'] = $can_use_casual_selling;
}
/**
* Gets whether vaulting can be used.
*
* @return bool
*/
public function get_can_use_vaulting() : bool {
return (bool) $this->data['can_use_vaulting'];
}
/**
* Sets whether vaulting can be used.
*
* @param bool $can_use_vaulting Whether vaulting can be used.
*/
public function set_can_use_vaulting( bool $can_use_vaulting ) : void {
$this->data['can_use_vaulting'] = $can_use_vaulting;
}
/**
* Gets whether Credit Card payments can be used.
*
* @return bool
*/
public function get_can_use_card_payments() : bool {
return (bool) $this->data['can_use_card_payments'];
}
/**
* Sets whether Credit Card payments can be used.
*
* @param bool $can_use_card_payments Whether Credit Card payments can be used.
*/
public function set_can_use_card_payments( bool $can_use_card_payments ) : void {
$this->data['can_use_card_payments'] = $can_use_card_payments;
}
}

View file

@ -41,26 +41,38 @@ class OnboardingRestEndpoint extends RestEndpoint {
* @var array
*/
private array $field_map = array(
'step' => array(
'step' => array(
'js_name' => 'step',
'sanitize' => 'to_number',
),
'use_sandbox' => array(
'use_sandbox' => array(
'js_name' => 'useSandbox',
'sanitize' => 'to_boolean',
),
'use_manual_connection' => array(
'use_manual_connection' => array(
'js_name' => 'useManualConnection',
'sanitize' => 'to_boolean',
),
'client_id' => array(
'client_id' => array(
'js_name' => 'clientId',
'sanitize' => 'sanitize_text_field',
),
'client_secret' => array(
'client_secret' => array(
'js_name' => 'clientSecret',
'sanitize' => 'sanitize_text_field',
),
'can_use_casual_selling' => array(
'js_name' => 'canUseCasualSelling',
'sanitize' => 'to_boolean',
),
'can_use_vaulting' => array(
'js_name' => 'canUseVaulting',
'sanitize' => 'to_boolean',
),
'can_use_card_payments' => array(
'js_name' => 'canUseCardPayments',
'sanitize' => 'to_boolean',
),
);
/**