mollie / mollie-api-node

Official Mollie API client for Node
http://www.mollie.com
BSD 3-Clause "New" or "Revised" License
228 stars 62 forks source link

transaction id #309

Closed SteffenBarthel closed 1 year ago

SteffenBarthel commented 1 year ago

Hey,

is there any way to get the transaction ID? (tr_urZ2D3dfgh) I see it as an output from payment. Is there a function to get it out.

Code:

const { createMollieClient } = require('@mollie/api-client');
const mollieClient = createMollieClient({ apiKey: mollieApiKey });

const payment = await mollieClient.payments.create({
      amount: {
          value: 10.00,
          currency: 'EUR'
      },
      description: data.uuid,
      redirectUrl: `https://example.domain/`,
});

console.log(payment);

Output:

Payment tr_urZ2D3dfgh {
  amount: { currency: 'EUR', value: '10.00' },
  createdAt: '2023-01-18T16:52:41+00:00',
  description: 'some Text',
  expiresAt: '2023-01-18T17:07:41+00:00',
  isCancelable: false,
  metadata: null,
  method: null,
  mode: 'test',
  profileId: 'pfl_d7K2ofHDHm',
  redirectUrl: 'https://example.domain/',
  sequenceType: 'oneoff',
  status: 'open'
}
Pimm commented 1 year ago

Hi Steffen,

You certainly can!

console.log(payment.id);