Skip to content

Commit

Permalink
Merge pull request #571 from Adyen/feature/open-invoice-with-country-…
Browse files Browse the repository at this point in the history
…selection

Show a dropdown of countries if no country is passed in Open Invoices
  • Loading branch information
pabloai committed Dec 4, 2020
2 parents 9d51f9e + cd62aca commit 311d20d
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/lib/src/components/Affirm/Affirm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';

const ALLOWED_COUNTRIES = ['CA', 'US'];
import { ALLOWED_COUNTRIES } from './config';

export default class Affirm extends OpenInvoiceContainer {
public static type = 'affirm';
Expand Down
1 change: 1 addition & 0 deletions packages/lib/src/components/Affirm/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ALLOWED_COUNTRIES = ['CA', 'US'];
2 changes: 2 additions & 0 deletions packages/lib/src/components/AfterPay/AfterPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { h } from 'preact';
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import ConsentCheckboxLabel from './components/ConsentCheckboxLabel';
import { getConsentLinkUrl } from './utils';
import { ALLOWED_COUNTRIES } from './config';

export default class AfterPay extends OpenInvoiceContainer {
public static type = 'afterpay_default';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES,
consentCheckboxLabel: <ConsentCheckboxLabel url={getConsentLinkUrl(props.countryCode, props.i18n?.locale)} />
};
}
Expand Down
3 changes: 2 additions & 1 deletion packages/lib/src/components/AfterPay/AfterPayB2B.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h } from 'preact';
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import ConsentCheckboxLabel from './components/ConsentCheckboxLabel';
import { AFTERPAY_B2B_CONSENT_URL } from './config';
import { AFTERPAY_B2B_CONSENT_URL, ALLOWED_COUNTRIES } from './config';

export default class AfterPayB2B extends OpenInvoiceContainer {
public static type = 'afterpay_b2b';
Expand All @@ -20,6 +20,7 @@ export default class AfterPayB2B extends OpenInvoiceContainer {
formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES,
consentCheckboxLabel: <ConsentCheckboxLabel url={AFTERPAY_B2B_CONSENT_URL} />
};
}
Expand Down
3 changes: 2 additions & 1 deletion packages/lib/src/components/AfterPay/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ const AFTERPAY_CONSENT_URL_EN = 'https://www.afterpay.nl/en/algemeen/pay-with-af
const AFTERPAY_CONSENT_URL_BE = 'https://www.afterpay.be/be/footer/betalen-met-afterpay/betalingsvoorwaarden';
const AFTERPAY_CONSENT_URL_NL = 'https://www.afterpay.nl/nl/algemeen/betalen-met-afterpay/betalingsvoorwaarden';
const AFTERPAY_B2B_CONSENT_URL = 'https://www.afterpay.nl/nl/algemeen/zakelijke-partners/betalingsvoorwaarden-zakelijk';
const ALLOWED_COUNTRIES = ['BE', 'NL'];

export { AFTERPAY_CONSENT_URL_EN, AFTERPAY_CONSENT_URL_BE, AFTERPAY_CONSENT_URL_NL, AFTERPAY_B2B_CONSENT_URL };
export { AFTERPAY_CONSENT_URL_EN, AFTERPAY_CONSENT_URL_BE, AFTERPAY_CONSENT_URL_NL, AFTERPAY_B2B_CONSENT_URL, ALLOWED_COUNTRIES };
8 changes: 8 additions & 0 deletions packages/lib/src/components/FacilyPay/FacilyPay10x.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class FacilyPay10x extends OpenInvoiceContainer {
public static type = 'facilypay_10x';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
8 changes: 8 additions & 0 deletions packages/lib/src/components/FacilyPay/FacilyPay12x.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class FacilyPay12x extends OpenInvoiceContainer {
public static type = 'facilypay_12x';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
9 changes: 8 additions & 1 deletion packages/lib/src/components/FacilyPay/FacilyPay3x.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class FacilyPay3x extends OpenInvoiceContainer {
public static type = 'facilypay_3x';
}

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
8 changes: 8 additions & 0 deletions packages/lib/src/components/FacilyPay/FacilyPay4x.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class FacilyPay4x extends OpenInvoiceContainer {
public static type = 'facilypay_4x';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
8 changes: 8 additions & 0 deletions packages/lib/src/components/FacilyPay/FacilyPay6x.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class FacilyPay6x extends OpenInvoiceContainer {
public static type = 'facilypay_6x';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
1 change: 1 addition & 0 deletions packages/lib/src/components/FacilyPay/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ALLOWED_COUNTRIES = ['ES', 'FR'];
8 changes: 8 additions & 0 deletions packages/lib/src/components/RatePay/RatePay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
import { ALLOWED_COUNTRIES } from './config';

export default class RatePay extends OpenInvoiceContainer {
public static type = 'ratepay';

formatProps(props) {
return {
...super.formatProps(props),
allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES
};
}
}
1 change: 1 addition & 0 deletions packages/lib/src/components/RatePay/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ALLOWED_COUNTRIES = ['AT', 'CH', 'DE'];
2 changes: 1 addition & 1 deletion packages/lib/src/components/internal/OpenInvoice/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface OpenInvoiceVisibility {
export interface OpenInvoiceProps {
allowedCountries?: string[];
consentCheckboxLabel: any;
countryCode: string;
countryCode?: string;
data: {
companyDetails?: CompanyDetailsSchema;
personalDetails?: PersonalDetailsSchema;
Expand Down

0 comments on commit 311d20d

Please sign in to comment.