Skip to content

Commit

Permalink
feat(projects.new): implement the checkbox fof legal agreement
Browse files Browse the repository at this point in the history
ref: TAPC-150
Signed-off-by: Rafik Adiche <[email protected]>
  • Loading branch information
Rafik Adiche authored and brofik committed Aug 23, 2023
1 parent 48fdaca commit ee1670d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ export default class PciProjectNewPaymentMethodAddCtrl {
});
}

resetLegalAgreements() {
this.model.legalAgreements = {
credit: false,
payPal: false,
bankAccount: false,
};
return null;
}

onCreditCardAgreementCheckboxChange(modelValue) {
this.resetLegalAgreements();
this.model.legalAgreements.credit = modelValue;
}

onBankAccountAgreementCheckboxChange(modelValue) {
this.resetLegalAgreements();
this.model.legalAgreements.bankAccount = modelValue;
}

onPaypalAgreementCheckboxChange(modelValue) {
this.resetLegalAgreements();
this.model.legalAgreements.paypal = modelValue;
}

showSpecificCrossBorderSentenceForCardPayment() {
return (
this.hasSpecificCrossBorderSentenceForCardPayment &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
<p
data-translate="pci_project_new_payment_method_add_credit_card_selected_explain_generic_2"
></p>
<oui-checkbox class="mt-4">
<oui-checkbox
class="mt-4"
data-on-change="$ctrl.onCreditCardAgreementCheckboxChange(modelValue)"
>
<oui-checkbox-label>
<span
data-translate="pci_project_new_payment_method_add_credit_card_default_validation"
Expand Down Expand Up @@ -71,7 +74,10 @@
data-translate="pci_project_new_payment_method_add_info_paypal"
data-translate-values="{ paymentMethodSection: $ctrl.paymentSectionHref }"
></p>
<oui-checkbox class="mt-4">
<oui-checkbox
class="mt-4"
data-on-change="$ctrl.onPaypalAgreementCheckboxChange(modelValue)"
>
<oui-checkbox-label>
<span
data-translate="pci_project_new_payment_method_add_credit_card_default_validation"
Expand Down Expand Up @@ -117,7 +123,10 @@
></p>
</oui-message>

<oui-checkbox class="mt-4">
<oui-checkbox
class="mt-4"
data-on-change="$ctrl.onBankAccountAgreementCheckboxChange(modelValue)"
>
<oui-checkbox-label>
<span
data-translate="pci_project_new_payment_method_add_credit_card_default_validation"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const PAYMENT_MEANS = {
CREDIT: 'CREDIT',
SEPA_DIRECT_DEBIT: 'SEPA_DIRECT_DEBIT',
PAYPAL: 'PAYPAL',
};

export default {
PAYMENT_MEANS,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ORDER_FOLLOW_UP_STATUS_ENUM,
ORDER_FOLLOW_UP_STEP_ENUM,
} from '../../projects.constant';
import { PAYMENT_MEANS } from './constants';

const getPaymentMethodTimeoutLimit = 30000;
const ANTI_FRAUD = {
Expand Down Expand Up @@ -216,7 +217,7 @@ export default class PciProjectNewPaymentCtrl {

if (
this.model.paymentMethod &&
this.model.paymentMethod.paymentType === 'CREDIT' &&
this.model.paymentMethod.paymentType === PAYMENT_MEANS.CREDIT &&
this.model.credit &&
!this.cart.creditOption
) {
Expand Down Expand Up @@ -358,7 +359,7 @@ export default class PciProjectNewPaymentCtrl {
// call integration submit function if some
if (
this.eligibility.isAddPaymentMethodRequired() &&
this.model.paymentMethod.paymentType !== 'CREDIT' &&
this.model.paymentMethod.paymentType !== PAYMENT_MEANS.CREDIT &&
this.integrationSubmitFn
) {
return this.integrationSubmitFn();
Expand Down Expand Up @@ -510,6 +511,36 @@ export default class PciProjectNewPaymentCtrl {
},
);

this.resetLegalAgreements();

return null;
}

resetLegalAgreements() {
this.model.legalAgreements = {
credit: false,
payPal: false,
bankAccount: false,
};
return null;
}

displayCreateProjectButton() {
if (this.model.paymentMethod.type.isCreditCard()) {
return this.model.legalAgreements.credit;
}
if (
(this.model.legalAgreements.bankAccount &&
this.model.paymentMethod.type.paymentType ===
PAYMENT_MEANS.SEPA_DIRECT_DEBIT) ||
(this.model.legalAgreements.paypal &&
this.model.paymentMethod.type.paymentType === PAYMENT_MEANS.PAYPAL)
) {
return [
this.OVH_PAYMENT_METHOD_INTEGRATION_TYPE.REDIRECT,
this.OVH_PAYMENT_METHOD_INTEGRATION_TYPE.IN_CONTEXT,
].includes(this.model.paymentMethod.integration);
}
return null;
}

Expand Down
10 changes: 4 additions & 6 deletions packages/manager/modules/pci/src/projects/new/payment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1 data-translate="pci_project_new_payment_title"></h1>

<!-- footer -->
<div
class="actions-container d-md-flex flex-row-reverse justify-content-between align-items-center my-3"
class="footer actions-container d-md-flex flex-row-reverse justify-content-between align-items-end"
>
<form
novalidate
Expand All @@ -70,10 +70,7 @@ <h1 data-translate="pci_project_new_payment_title"></h1>
data-on-submit="$ctrl.onIntegrationSubmit.bind($ctrl)"
data-on-submit-error="$ctrl.onIntegrationSubmitError.bind($ctrl)"
data-on-submit-success="$ctrl.onIntegrationSubmitSuccess.bind($ctrl)"
data-ng-if="[
$ctrl.OVH_PAYMENT_METHOD_INTEGRATION_TYPE.REDIRECT,
$ctrl.OVH_PAYMENT_METHOD_INTEGRATION_TYPE.IN_CONTEXT
].includes($ctrl.model.paymentMethod.integration)"
data-ng-if="$ctrl.displayCreateProjectButton()"
>
<!--Create project btn-->
<div class="d-flex">
Expand Down Expand Up @@ -174,7 +171,7 @@ <h1 data-translate="pci_project_new_payment_title"></h1>
variant="primary"
type="button"
on-click="$ctrl.initComponentInitialParams()"
data-ng-if="$ctrl.model.paymentMethod.isHandleByComponent() && !$ctrl.componentInitialParams && !$ctrl.isCheckingPaymentMethod"
data-ng-if="$ctrl.model.paymentMethod.isHandleByComponent() && !$ctrl.componentInitialParams && !$ctrl.isCheckingPaymentMethod && $ctrl.model.legalAgreements.credit"
disabled="$ctrl.globalLoading.finalize"
>
<span
Expand Down Expand Up @@ -234,6 +231,7 @@ <h1 data-translate="pci_project_new_payment_title"></h1>
</form>

<a
class="mt-3"
data-ng-if="!$ctrl.model.paymentMethod.isHandleByComponent() || !$ctrl.componentInitialParams"
data-ng-href="{{ $ctrl.step1Link() }}"
data-ng-click="$ctrl.sendTrack('new_project_payment_cancel')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import credit from './credit';
import routing from './routing';
import component from './component';
import paymentService from './service';
import './index.scss';

const moduleName = 'pciProjectNewPayment';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pci-project-new-payment {
.footer {
height: 3rem;
}
}

0 comments on commit ee1670d

Please sign in to comment.