How to use the @mollie/api-client function in @mollie/api-client

To help you get started, we’ve selected a few @mollie/api-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mollie / mollie-api-node / examples / refunds / create.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/refunds-api/create-refund
 * @docs https://docs.mollie.com/reference/v2/orders-api/create-order-refund
 */
import createMollieClient, { Refund } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    // Create payment refund
    const paymentRefund: Refund = await mollieClient.payments_refunds.create({
      paymentId: 'tr_WDqYK6vllg',
      amount: {
        value: '5.95',
        currency: 'EUR',
      },
    });

    console.log(paymentRefund);

    // Create order refund
    const orderRefund: Refund = await mollieClient.orders_refunds.create({
github mollie / mollie-api-node / examples / refunds / list.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/refunds-api/list-refunds
 * @docs https://docs.mollie.com/reference/v2/orders-api/list-order-refunds
 */
import createMollieClient, { List, Refund } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    // Payment refunds
    const paymentRefunds: List = await mollieClient.payments_refunds.all({ paymentId: 'tr_WDqYK6vllg' });

    console.log(paymentRefunds);

    // Order refunds
    const orderRefunds: List = await mollieClient.orders_refunds.all({ orderId: 'ord_stTC2WHAuS' });

    console.log(orderRefunds);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / customers / create-recurring-payment.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
 */
import createMollieClient, { Payment, SequenceType } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const customerId = 'cst_pzhEvnttJ2';

    const payment: Payment = await mollieClient.customers_payments.create({
      amount: { value: '10.00', currency: 'EUR' },
      description: 'Recurring payment',
      redirectUrl: 'https://example.org/redirect',
      webhookUrl: 'http://example.org/webhook',
      metadata: { orderId: 'Order #23' },
      customerId,
      sequenceType: SequenceType.recurring,
    });

    console.log(payment);
github mollie / mollie-api-node / examples / orders / cancel.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/orders-api/cancel-order
 */
import createMollieClient, { Order } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const canceledOrder: Order = await mollieClient.orders.cancel('ord_8wmqcHMN4U');

    console.log(canceledOrder);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / customers / list-payments.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/customers-api/list-customer-payments
 */
import createMollieClient, { List, Payment } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const payments: List = await mollieClient.customers_payments.all({ customerId: 'cst_pzhEvnttJ2' });

    console.log(payments);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / mandates / list.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/mandates-api/list-mandates
 */
import createMollieClient, { List, Mandate } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const mandates: List = await mollieClient.customers_mandates.all({
      customerId: 'cst_pzhEvnttJ2',
    });

    console.log(mandates);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / subscriptions / get.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/subscriptions-api/get-subscription
 */
import createMollieClient, { Subscription } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const subscription: Subscription = await mollieClient.customers_subscriptions.get('sub_PCN3U3U27K', {
      customerId: 'cst_pzhEvnttJ2',
    });

    console.log(subscription);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / customers / update.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/customers-api/update-customer
 */
import createMollieClient, { Customer } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const customer: Customer = await mollieClient.customers.update('cst_pzhEvnttJ2', {
      name: 'Updated customer name',
      email: 'updated-email@example.org',
    });

    console.log(customer);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / customers / list.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/customers-api/list-customers
 */
import createMollieClient, { List, Customer } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const customers: List = await mollieClient.customers.all();

    console.log(customers);
  } catch (error) {
    console.warn(error);
  }
})();
github mollie / mollie-api-node / examples / orders / update.ts View on Github external
/**
 * @docs https://docs.mollie.com/reference/v2/orders-api/update-order
 */
import createMollieClient, { Order } from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  try {
    const order: Order = await mollieClient.orders.update('ord_kEn1PlbGa', {
      billingAddress: {
        organizationName: 'Mollie B.V.',
        streetAndNumber: 'Keizersgracht 313',
        city: 'Amsterdam',
        region: 'Noord-Holland',
        postalCode: '1234AB',
        country: 'NL',
        title: 'Dhr',
        givenName: 'Piet',
        familyName: 'Mondriaan',
        email: 'piet@mondriaan.com',
        phone: '+31208202070',