Skip to content

Commit

Permalink
Merge pull request #230 from woocommerce/pcp-248-3ds-select
Browse files Browse the repository at this point in the history
Add 3d secure contingency settings
  • Loading branch information
Dinamiko authored Sep 8, 2021
2 parents 93f0667 + 3580462 commit 9e8929c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ class CreditCardRenderer {
const save_card = this.defaultConfig.save_card ? true : false;
const vault = document.getElementById('ppcp-credit-card-vault') ?
document.getElementById('ppcp-credit-card-vault').checked : save_card;
hostedFields.submit({
contingencies: ['SCA_WHEN_REQUIRED'],
const contingency = this.defaultConfig.hosted_fields.contingency;
const hostedFieldsData = {
vault: vault
}).then((payload) => {
};
if (contingency !== 'NO_3D_SECURE') {
hostedFieldsData.contingencies = [contingency];
}
hostedFields.submit(hostedFieldsData).then((payload) => {
payload.orderID = payload.orderId;
this.spinner.unblock();
return contextConfig.onApprove(payload);
Expand Down
14 changes: 14 additions & 0 deletions modules/ppcp-button/src/Assets/class-smartbutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,19 @@ private function has_subscriptions(): bool {
return $this->subscription_helper->cart_contains_subscription();
}

/**
* Retrieves the 3D Secure contingency settings.
*
* @return string
*/
private function get_3ds_contingency(): string {
if ( $this->settings->has( '3d_secure_contingency' ) ) {
return $this->settings->get( '3d_secure_contingency' );
}

return 'SCA_WHEN_REQUIRED';
}

/**
* The localized data for the smart button.
*
Expand Down Expand Up @@ -677,6 +690,7 @@ private function localize_script(): array {
),
),
'valid_cards' => $this->dcc_applies->valid_cards(),
'contingency' => $this->get_3ds_contingency(),
),
'messages' => $this->message_values(),
'labels' => array(
Expand Down
56 changes: 56 additions & 0 deletions modules/ppcp-wc-gateway/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,62 @@ static function ( $container ): AuthorizeOrderActionNotice {
),
'gateway' => 'dcc',
),
'3d_secure_heading' => array(
'heading' => __( '3D Secure', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'description' => wp_kses_post(
sprintf(
// translators: %1$s and %2$s is a link tag.
__(
'3D Secure benefits cardholders and merchants by providing
an additional layer of verification using Verified by Visa,
MasterCard SecureCode and American Express SafeKey.
%1$sLearn more about 3D Secure.%2$s',
'woocommerce-paypal-payments'
),
'<a
rel="noreferrer noopener"
href="https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/"
>',
'</a>'
)
),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(
'dcc',
),
'gateway' => 'dcc',
),
'3d_secure_contingency' => array(
'title' => __( 'Contingency for 3D Secure', 'woocommerce-paypal-payments' ),
'type' => 'select',
'description' => sprintf(
// translators: %1$s and %2$s opening and closing ul tag, %3$s and %4$s opening and closing li tag.
__( '%1$s%3$sNo 3D Secure will cause transactions to be denied if 3D Secure is required by the bank of the cardholder.%4$s%3$sSCA_WHEN_REQUIRED returns a 3D Secure contingency when it is a mandate in the region where you operate.%4$s%3$sSCA_ALWAYS triggers 3D Secure for every transaction, regardless of SCA requirements.%4$s%2$s', 'woocommerce-paypal-payments' ),
'<ul>',
'</ul>',
'<li>',
'</li>'
),
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'SCA_WHEN_REQUIRED',
'desc_tip' => true,
'options' => array(
'NO_3D_SECURE' => __( 'No 3D Secure (transaction will be denied if 3D Secure is required)', 'woocommerce-paypal-payments' ),
'SCA_WHEN_REQUIRED' => __( '3D Secure when required', 'woocommerce-paypal-payments' ),
'3D_SECURE' => __( 'Always trigger 3D Secure', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(
'dcc',
),
'gateway' => 'dcc',
),
);
if ( ! defined( 'PPCP_FLAG_SUBSCRIPTION' ) || ! PPCP_FLAG_SUBSCRIPTION ) {
unset( $fields['vault_enabled'] );
Expand Down
41 changes: 0 additions & 41 deletions modules/ppcp-wc-gateway/src/Settings/class-settingsrenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,6 @@ class="woocommerce-help-tip"
if ( $this->dcc_applies->for_country_currency() ) {
if ( State::STATE_ONBOARDED > $this->state->current_state() ) {
$this->render_dcc_onboarding_info();
} elseif ( State::STATE_ONBOARDED === $this->state->current_state() && $this->dcc_product_status->dcc_is_active() ) {
$this->render_3d_secure_info();
} elseif ( ! $this->dcc_product_status->dcc_is_active() ) {
$this->render_dcc_not_active_yet();
}
Expand Down Expand Up @@ -450,45 +448,6 @@ private function render_dcc_not_active_yet() {
<?php
}

/**
* Renders the 3d secure info text.
*/
private function render_3d_secure_info() {
?>
<tr>
<th><?php esc_html_e( '3D Secure', 'woocommerce-paypal-payments' ); ?></th>
<td>
<p>
<?php
/**
* We still need to provide a docs link.
*
* @todo: Provide link to documentation.
*/
echo wp_kses_post(
sprintf(
// translators: %1$s and %2$s is a link tag.
__(
'3D Secure benefits cardholders and merchants by providing
an additional layer of verification using Verified by Visa,
MasterCard SecureCode and American Express SafeKey.
%1$sLearn more about 3D Secure.%2$s',
'woocommerce-paypal-payments'
),
'<a
rel="noreferrer noopener"
href="https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/"
>',
'</a>'
)
);
?>
</p>
</td>
</tr>
<?php
}

/**
* Renders the DCC onboarding info.
*/
Expand Down

0 comments on commit 9e8929c

Please sign in to comment.