Skip to content

Commit

Permalink
fix(payments-plugin): Fix Mollie klarna AutoCapture (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvdbrug authored Oct 12, 2023
1 parent 3fd93c7 commit 8db459a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 8db459a

Please sign in to comment.