Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v6 - Passing AdyenCheckout as first parameter #2535

Merged
merged 12 commits into from
Feb 7, 2024
2 changes: 1 addition & 1 deletion packages/e2e-playwright/app/src/pages/ANCV/ANCV.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const initCheckout = async () => {
onError: handleError
});

window.paymentMethod = new ANCV({ core: checkout }).mount('.ancv-field');
window.paymentMethod = new ANCV(checkout).mount('.ancv-field');
};

initCheckout();
3 changes: 1 addition & 2 deletions packages/e2e-playwright/app/src/pages/Cards/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const initCheckout = async () => {
});

// Credit card with installments
window.card = new Card({
core: checkout,
window.card = new Card(checkout, {
brands: ['mc', 'visa', 'amex', 'maestro', 'bcmc'],
onChange: state => {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.customCard = new CustomCard({
core: checkout,
window.customCard = new CustomCard(checkout, {
type: 'card',
brands: ['mc', 'visa', 'synchrony_plcc'],
onConfigSuccess,
Expand All @@ -34,8 +33,7 @@ const initCheckout = async () => {

createPayButton('.secured-fields', window.customCard, 'customCardRegular');

window.customCardSeparate = new CustomCard({
core: checkout,
window.customCardSeparate = new CustomCard(checkout, {
type: 'card',
brands: ['mc', 'visa', 'synchrony_plcc'],
onConfigSuccess,
Expand Down
4 changes: 1 addition & 3 deletions packages/e2e-playwright/app/src/pages/Dropin/Dropin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import '../../style.scss';
const initCheckout = async () => {
const paymentMethodsResponse = await getPaymentMethods({ amount, shopperLocale });

console.log(window.mainConfiguration);

window.checkout = await AdyenCheckout({
amount,
countryCode,
Expand All @@ -24,7 +22,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.dropin = new Dropin({ core: window.checkout, ...window.dropinConfig }).mount('#dropin-container');
window.dropin = new Dropin(window.checkout, { ...window.dropinConfig }).mount('#dropin-container');
};

initCheckout();
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const initCheckout = async () => {
// ...window.mainConfiguration
});

window.ideal = new Ideal({ core: checkout, highlightedIssuers: ['1121', '1154', '1153'] }).mount('.ideal-field');
window.ideal = new Ideal(checkout, { highlightedIssuers: ['1121', '1154', '1153'] }).mount('.ideal-field');
};

initCheckout();
2 changes: 1 addition & 1 deletion packages/e2e/app/src/pages/Address/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../../style.scss';

const initCheckout = async () => {
window.checkout = await AdyenCheckout();
window.address = new Address({core: checkout}).mount('.address-field');
window.address = new Address(checkout).mount('.address-field');
};

initCheckout();
3 changes: 1 addition & 2 deletions packages/e2e/app/src/pages/Cards/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const initCheckout = async () => {
});

// Credit card with installments
window.card = new Card({
core: checkout,
window.card = new Card(checkout, {
brands: ['mc', 'visa', 'amex', 'maestro', 'bcmc'],
onChange: state => {
/**
Expand Down
26 changes: 12 additions & 14 deletions packages/e2e/app/src/pages/CustomCards/CustomCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../../style.scss';
import './customcards.style.scss';
import { setFocus, onBrand, onConfigSuccess, onBinLookup, onChange } from './customCards.config';
import { makePayment } from '@adyen/adyen-web-playwright/app/src/services';
import { showAuthorised } from '@adyen/adyen-web-playwright/app/src/handlers';

const initCheckout = async () => {
// window.TextEncoder = null; // Comment in to force use of "compat" version
Expand All @@ -22,8 +21,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.securedFields = new CustomCard({
core: checkout,
window.securedFields = new CustomCard(checkout, {
type: 'card',
brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro', 'cartebancaire'],
onConfigSuccess,
Expand All @@ -36,17 +34,17 @@ const initCheckout = async () => {

createPayButton('.secured-fields', window.securedFields, 'securedfields');

window.securedFields2 = new CustomCard({
core: checkout,
// type: 'card',// Deliberately exclude to ensure a default value is set
brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro', 'cartebancaire'],
onConfigSuccess,
onBrand,
onFocus: setFocus,
onBinLookup,
onChange,
...window.cardConfig
}).mount('.secured-fields-2');
window.securedFields2 = new CustomCard(checkout, {
// type: 'card',// Deliberately exclude to ensure a default value is set
brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro', 'cartebancaire'],
onConfigSuccess,
onBrand,
onFocus: setFocus,
onBinLookup,
onChange,
...window.cardConfig
})
.mount('.secured-fields-2');

createPayButton('.secured-fields-2', window.securedFields2, 'securedfields2');

Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/app/src/pages/Dropin/Dropin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.dropin = new Dropin({ core: checkout, ...window.dropinConfig }).mount('#dropin-container');
window.dropin = new Dropin(checkout, { ...window.dropinConfig }).mount('#dropin-container');
};

initCheckout();
4 changes: 1 addition & 3 deletions packages/e2e/app/src/pages/DropinSessions/DropinSessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.dropin = new Dropin({ core: checkout, paymentMethodComponents: [Card, Giftcard], ...window.dropinConfig }).mount(
'#dropin-sessions-container'
);
window.dropin = new Dropin(checkout, { paymentMethodComponents: [Card, Giftcard], ...window.dropinConfig }).mount('#dropin-sessions-container');
};

initCheckout();
3 changes: 1 addition & 2 deletions packages/e2e/app/src/pages/GiftCards/GiftCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.giftcard = new Giftcard({
core: window.checkout,
window.giftcard = new Giftcard(window.checkout, {
type: 'giftcard',
brand: 'valuelink',
onBalanceCheck: async (resolve, reject, data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const initCheckout = async () => {
}
});

window.giftcard = new Giftcard({
core: window.sessionCheckout,
window.giftcard = new Giftcard(window.sessionCheckout, {
type: 'giftcard',
brand: 'valuelink',
onOrderUpdated: data => {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/app/src/pages/IssuerLists/IssuerLists.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const initCheckout = async () => {
// ...window.mainConfiguration
});

window.ideal = new Ideal({ core: checkout, highlightedIssuers: ['1121', '1154', '1153'] }).mount('.ideal-field');
window.ideal = new Ideal(checkout, { highlightedIssuers: ['1121', '1154', '1153'] }).mount('.ideal-field');
};

initCheckout();
2 changes: 1 addition & 1 deletion packages/e2e/app/src/pages/OpenInvoices/OpenInvoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const initCheckout = async () => {
// ...window.mainConfiguration
});

window.afterpay = new AfterPay({ core: checkout }).mount('.afterpay-field');
window.afterpay = new AfterPay(checkout).mount('.afterpay-field');
};

initCheckout();
2 changes: 1 addition & 1 deletion packages/e2e/app/src/pages/StoredCards/StoredCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const initCheckout = async () => {
};

// Credit card with installments
window.storedCard = new Card({ core: checkout, ...storedCardData }).mount('.stored-card-field');
window.storedCard = new Card(checkout, { ...storedCardData }).mount('.stored-card-field');
};

initCheckout();
8 changes: 3 additions & 5 deletions packages/e2e/app/src/pages/Vouchers/Vouchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ const initCheckout = async () => {
});

// Boleto Input
window.boletoInput = new Boleto({
core: window.checkout,
window.boletoInput = new Boleto(window.checkout, {
type: 'boletobancario',
...window.boletoConfig
})
.mount('#boleto-input-container');
...window.boletoConfig
}).mount('#boleto-input-container');
};

initCheckout();
4 changes: 2 additions & 2 deletions packages/lib/src/components/Affirm/Affirm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Affirm from './Affirm';

describe('Affirm', () => {
test('returns false if there is no state', () => {
const affirm = new Affirm({ core: global.core });
const affirm = new Affirm(global.core);
expect(affirm.isValid).toBe(false);
});

test('returns a type', () => {
const affirm = new Affirm({ core: global.core });
const affirm = new Affirm(global.core);
expect(affirm.data.paymentMethod.type).toBe('affirm');
});
});
4 changes: 2 additions & 2 deletions packages/lib/src/components/AfterPay/AfterPay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import AfterPay from './AfterPay';

describe('AfterPay', () => {
test('returns false if there is no state', () => {
const afterPay = new AfterPay({ core: global.core });
const afterPay = new AfterPay(global.core);
expect(afterPay.isValid).toBe(false);
});

test('returns a type', () => {
const afterPay = new AfterPay({ core: global.core });
const afterPay = new AfterPay(global.core);
expect(afterPay.data.paymentMethod.type).toBe('afterpay_default');
});
});
6 changes: 3 additions & 3 deletions packages/lib/src/components/AfterPay/AfterPayB2B.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import AfterPayB2B from './AfterPayB2B';

describe('AfterPay B2B', () => {
test('returns false if there is no state', () => {
const afterPay = new AfterPayB2B({ core: global.core });
const afterPay = new AfterPayB2B(global.core);
expect(afterPay.isValid).toBe(false);
});

test('returns a type', () => {
const afterPay = new AfterPayB2B({ core: global.core });
const afterPay = new AfterPayB2B(global.core);
expect(afterPay.data.paymentMethod.type).toBe('afterpay_b2b');
});

test('should show the company details as editable by default', () => {
const afterPay = new AfterPayB2B({ core: global.core });
const afterPay = new AfterPayB2B(global.core);
expect(afterPay.props.visibility.companyDetails).toBe('editable');
});
});
5 changes: 2 additions & 3 deletions packages/lib/src/components/AmazonPay/AmazonPay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ const spyFetch = (httpPost as jest.Mock).mockImplementation(jest.fn(() => Promis
describe('AmazonPay', () => {
const amazonProps = mock<AmazonPayConfiguration>();
const getElement = (props = {}) =>
new AmazonPay({
new AmazonPay(global.core, {
...defaultProps,
...props,
...amazonProps,
core: global.core
...amazonProps
});

test('always returns isValid as true', () => {
Expand Down
38 changes: 10 additions & 28 deletions packages/lib/src/components/ApplePay/ApplePay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe('ApplePay', () => {
}
});

const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 },
onPaymentFailed: onPaymentFailedMock,
onSubmit(state, component, actions) {
Expand Down Expand Up @@ -88,9 +86,7 @@ describe('ApplePay', () => {
resolve(orderDetails);
});

const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 },
onOrderTrackingRequest: onOrderTrackingRequestMock,
onPaymentCompleted: onPaymentCompletedMock
Expand Down Expand Up @@ -140,9 +136,7 @@ describe('ApplePay', () => {
resolve();
});

const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 },
onOrderTrackingRequest: onOrderTrackingRequestMock,
onPaymentCompleted: onPaymentCompletedMock
Expand Down Expand Up @@ -186,9 +180,7 @@ describe('ApplePay', () => {
reject();
});

const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 },
onOrderTrackingRequest: onOrderTrackingRequestMock,
onPaymentCompleted: onPaymentCompletedMock
Expand Down Expand Up @@ -264,9 +256,7 @@ describe('ApplePay', () => {
actions.reject();
});

const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 },
onAuthorized: onAuthorizedMock,
onChange: onChangeMock,
Expand Down Expand Up @@ -347,34 +337,26 @@ describe('ApplePay', () => {

describe('formatProps', () => {
test('accepts an amount in a regular format', () => {
const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
amount: { currency: 'EUR', value: 2000 }
});
expect(applepay.props.amount.value).toEqual(2000);
expect(applepay.props.amount.currency).toEqual('EUR');
});

test('accepts an amount with default values', () => {
const applepay = new ApplePay({ core: global.core, countryCode: 'US' });
const applepay = new ApplePay(global.core);
expect(applepay.props.amount.value).toEqual(0);
expect(applepay.props.amount.currency).toEqual('USD');
});

test('uses merchantName if no totalPriceLabel was defined', () => {
const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
configuration: { merchantName: 'Test' }
});
const applepay = new ApplePay(global.core, { configuration: { merchantName: 'Test' } });
expect(applepay.props.totalPriceLabel).toEqual('Test');
});

test('can set totalPriceLabel', () => {
const applepay = new ApplePay({
core: global.core,
countryCode: 'US',
const applepay = new ApplePay(global.core, {
configuration: { merchantName: 'Test' },
totalPriceLabel: 'Total'
});
Expand All @@ -384,7 +366,7 @@ describe('ApplePay', () => {

describe('get data', () => {
test('always returns a type', () => {
const applepay = new ApplePay({ core: global.core, countryCode: 'US' });
const applepay = new ApplePay(global.core);
expect(applepay.data).toMatchObject({ paymentMethod: { type: 'applepay' } });
});
});
Expand Down
Loading
Loading