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

Fix/mollie klarna AutoCapture doesn't work! #2446

Merged
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
7 changes: 4 additions & 3 deletions packages/payments-plugin/e2e/mollie-payment.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ describe('Mollie payments (with useDynamicRedirectUrl set to true)', () => {
body: JSON.stringify({ id: mockData.mollieOrderResponse.id }),
headers: { 'Content-Type': 'application/json' },
});
// tslint:disable-next-line:no-non-null-assertion
const { order: adminOrder } = await adminClient.query(GET_ORDER_PAYMENTS, { id: order!.id });
const { order: adminOrder } = await adminClient.query(GET_ORDER_PAYMENTS, { id: order?.id });
expect(adminOrder.state).toBe('ArrangingPayment');
});

Expand Down Expand Up @@ -457,7 +456,7 @@ describe('Mollie payments (with useDynamicRedirectUrl set to true)', () => {
adminClient,
order.lines[0].id,
10,
// tslint:disable-next-line:no-non-null-assertion
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
order.payments!.find(p => p.amount === 108990)!.id,
SURCHARGE_AMOUNT,
);
Expand All @@ -468,6 +467,8 @@ describe('Mollie payments (with useDynamicRedirectUrl set to true)', () => {
});

describe('Handle pay-later methods', () => {
// TODO: Add testcases that mock incoming webhook to: 1. Authorize payment and 2. AutoCapture payments

it('Should prepare a new order', async () => {
await shopClient.asUserWithCredentials(customers[0].emailAddress, 'test');
const { addItemToOrder } = await shopClient.query<
Expand Down
3 changes: 2 additions & 1 deletion packages/payments-plugin/src/mollie/mollie.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export class MollieService {
* Settle an existing payment based on the given mollieOrder
*/
async settleExistingPayment(ctx: RequestContext, order: Order, mollieOrderId: string): Promise<void> {
order = await this.entityHydrator.hydrate(ctx, order, { relations: ['payments'] });
const payment = order.payments.find(p => p.transactionId === mollieOrderId);
if (!payment) {
throw Error(
Expand Down Expand Up @@ -335,7 +336,7 @@ export class MollieService {
}
const client = createMollieClient({ apiKey });
// We use the orders API, so list available methods for that API usage
const methods = await client.methods.list({resource: 'orders'});
const methods = await client.methods.list({ resource: 'orders' });
return methods.map(m => ({
...m,
code: m.id,
Expand Down