@permettezmoideconstruire/alma-client
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

@permettezmoideconstruire/alma-client

build status code style libraries status

See Documentation

Install

yarn add @permettezmoideconstruire/alma-client

Usage

import type { AxiosResponse } from 'axios'

import {
  getClient,
  createPayment,
  AlmaPaymentOrderPayload,
  AlmaPayment
} from '@permettezmoideconstruire/alma-client'

// This creates and configure
// dedicated Axios instance for Alma
const almaClient = getClient(
  process.env.ALMA_API_KEY,
  // Optional but typically useful to switch to sandbox API endpoint
  process.env.ALMA_API_ENDPOINT
)

// API types helpers for payloads
const paymentOrderPayload: AlmaPaymentOrderPayload = {
  payment: {
    billing_address: {
      country: 'France'
    },
    purchase_amount: 150000
  }
}

// Each call is curryfied : method(almaClient)(data / options)
const result: AxiosResponse<Payment> = await createPayment(almaClient)(paymentOrderCreation)

// API types for returns
const payment: Payment = result.data

Readme

Keywords

none

Package Sidebar

Install

npm i @permettezmoideconstruire/alma-client

Weekly Downloads

18

Version

0.4.0

License

MIT

Unpacked Size

53.3 kB

Total Files

71

Last publish

Collaborators

  • brolyus
  • algar
  • cyril.chapon