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

Add Support for Sofort on Adyen Components #843

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/recurly/alternative-payment-methods/gateways/adyen.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ class AdyenGateway extends Base {
}

get data () {
return this.state.data;
const methodState = this.state.data;
const componentState = this.webComponent?.activePaymentMethod?.data;

return { ...methodState, ...componentState };
}

async handleAction (action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Recurly.AlternativePaymentMethods', () => {
};

const { onChange } = window.AdyenCheckout.getCall(0).args[0];
onChange({ data: 'payment-method-state', isValid: true });
onChange({ data: { myState: 1 }, isValid: true });

paymentMethods.submit({ billingAddress });

Expand All @@ -264,7 +264,7 @@ describe('Recurly.AlternativePaymentMethods', () => {
countryCode: 'US',
locale: 'en-US',
channel: 'Web',
paymentMethodData: 'payment-method-state',
paymentMethodData: { myState: 1 },
gatewayType: 'adyen',
returnURL: 'https://merchant-website.test/completed',
billingAddress: billingAddress,
Expand All @@ -274,20 +274,20 @@ describe('Recurly.AlternativePaymentMethods', () => {
});

const validateTokenization = submit => {
it("make a POST /js/v1/payment_methods/token with the needed params", done => {
it('make a POST /js/v1/payment_methods/token with the needed params', done => {
sandbox.stub(recurly.request, 'post').resolves({ });
submit();

nextTick(() => assertDone(done, () => {
assert.equal(recurly.request.post.called, true);
assert.deepEqual(recurly.request.post.getCall(0).args[0].route, "/payment_methods/token");
assert.deepEqual(recurly.request.post.getCall(0).args[0].route, '/payment_methods/token');
assert.deepEqual(recurly.request.post.getCall(0).args[0].data, {
currency: 'USD',
amount: 100,
countryCode: 'US',
locale: 'en-US',
channel: 'Web',
paymentMethodData: 'boleto-state',
paymentMethodData: { myState: 2 },
gatewayType: 'adyen',
returnURL: 'https://merchant-website.test/completed',
billingAddress: undefined,
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Recurly.AlternativePaymentMethods', () => {

validateTokenization(() => {
const { onSubmit } = window.AdyenCheckout.getCall(0).args[0];
onSubmit({ data: 'boleto-state' });
onSubmit({ data: { myState: 2 } });
});
});

Expand All @@ -375,7 +375,7 @@ describe('Recurly.AlternativePaymentMethods', () => {
}));

const { onChange } = window.AdyenCheckout.getCall(0).args[0];
onChange({ data: 'boleto-state-2', isValid: true });
onChange({ data: { myState: 3 }, isValid: true });
});
});

Expand All @@ -388,8 +388,8 @@ describe('Recurly.AlternativePaymentMethods', () => {

validateTokenization(() => {
const { onChange } = window.AdyenCheckout.getCall(0).args[0];
onChange({ data: 'boleto-state-2' });
onChange({ data: 'boleto-state' });
onChange({ data: { myState: 3 } });
onChange({ data: { myState: 2 } });

paymentMethods.submit();
});
Expand All @@ -401,7 +401,7 @@ describe('Recurly.AlternativePaymentMethods', () => {
paymentMethods.start()
.finally(() => {
const { onChange } = window.AdyenCheckout.getCall(0).args[0];
onChange({ data: 'boleto-state' });
onChange({ data: { myState: 2 } });

paymentMethods.submit();
done();
Expand Down
Loading