gpayments
Simple 4Geeks Payments API Client for NodeJS.
Installation
$ npm install gpayments
Usage
const gpayments = const gpApi =
gpApiplans // or with async/await const plan = await gpApiplans
API
You will need your 4Geeks Payment Client ID
and a Client Secret
in order to use this library.
For additional information on all supported parameters of each method you can visit the official 4Geeks Payment API Documentation.
gpayments(options)
Create a new instance of gpayment
api by passing the required clientId
and clientSecret
properties.
const api =
You can also set the GPAYMENTS_CLIENT_ID
and GPAYMENTS_SECRET_ID
environment variables instead of passing clientId
and clientSecret
properties directly.
For example, lets say somewhere in your app you have:
const api =
You can startup your node application like this:
GPAYMENTS_CLIENT_ID=abc123 GPAYMENTS_SECRET_ID=123abcsecret node app.js
api.me.fetch()
Fetch my account information.
const account = await apime console
api.me.update(data)
Update my account information.
const account = await apime console
api.customers.fetch([key])
Fetch customers. You can also pass a customer key to fetch an specific customer.
const customers = await apicustomers console
Or to fetch a single customer.
const customer = await apicustomers console
api.customers.create(data)
Create a new customer.
const customer = await apicustomers console
api.customers.update(key, data)
Update a customer.
const data = email: 'brucebanner2@hulk.com' const customer = await apicustomers console
api.customers.remove(key)
Delete a customer.
await apicustomers
api.plans.fetch([key])
Fetch all plans. You can also pass a plan key to fetch an specific plan.
const plans = await apiplans console
Or to fetch a single plan.
const plan = await apiplans console
api.plans.create(data)
Create a new plan.
const plan = await apiplans console
api.plans.remove(key)
Delete a plan.
await apiplans
api.subscriptions.fetch([id])
Fetch all subscriptions. You can also pass a subscription id to fetch an specific subscription.
const subscriptions = await apisubscriptions console
Or to fetch a single subscription.
const subscription = await apisubscriptions console
api.subscriptions.subscribe(data)
Create a subscription.
await apisubscriptions
api.subscriptions.unsubscribe(id)
Delete a subscription.
await apisubscriptions
api.charges.create(data)
Create a new charge.
await apicharges
You can also just simple charge a credit card by omitting a customer_key
and adding just the credit card information:
// Simple charge the credit card provided.await apicharges
api.charges.logs([id])
List all charges logs. You can also pass a charge id to fetch an specific charge log.
const logs = await apicharges console
Or to fetch a single charge log.
const log = await apicharges console
Run tests
$ npm install$ npm run test
License
Under The MIT License