@permettezmoideconstruire/alma-client
v0.4.0
Published
Typescript client for Alma (using axios)
Downloads
11
Keywords
Readme
@permettezmoideconstruire/alma-client
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