Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

feat(instant_charge): Ability to define charge as instant #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/models/charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Charge {
if (isPresent(this.attributes.id)) result.id = this.attributes.id;
if (isPresent(this.attributes.billableMetricId)) result.billable_metric_id = this.attributes.billableMetricId;
if (isPresent(this.attributes.chargeModel)) result.charge_model = this.attributes.chargeModel;
if (isPresent(this.attributes.instant)) result.instant = this.attributes.instant;
if (isPresent(this.attributes.properties)) result.properties = this.attributes.properties;
if (isPresent(this.attributes.groupProperties)) result.group_properties = this.attributes.groupProperties;

Expand Down
8 changes: 6 additions & 2 deletions test/plan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import Plan from '../lib/models/plan.js';
import Charge from '../lib/models/charge.js';

let client = new Client('api_key')
let charge = new Charge({billableMetricId: 'billable_metric_id', amountCurrency: 'EUR',
chargeModel: 'standard'
let charge = new Charge({
billableMetricId: 'billable_metric_id',
amountCurrency: 'EUR',
chargeModel: 'standard',
instant: false
})
let charges = [charge]
let plan = new Plan({name: 'name1', code: 'code1', interval: 'weekly', amountCents: 1000,
Expand All @@ -33,6 +36,7 @@ let response = {
lago_billable_metric_id: 'id',
created_at: '2022-04-29T08:59:51Z',
charge_model: 'standard',
instant: false,
properties: {},
group_properties: []
}
Expand Down