Create an reoccurring subscription with a First Billing Amount

The steps below will outline an example on how a re-occurring debit with a first billing amount is configured.

📘

NOTE:

For an on-going subscription without a billing end date or Total Amount to be collected configured, the plan's that is used needs to be an on-going plan configuration as well.

1. Create An On-going Subscription

[POST] https://api-sandbox.ezypay.com/v2/billing/subscriptions

Example below:

  • Customer will start his subscription starting on the 11th July 2019 (Or future id needed).
  • Customer will have a re-occurring date to be debited every monday starting from the 22th July.
  • Customer will have a First Debit Amount of AUD 1000 configured (this will be collected on the first debit attempted).
  • Customer will be charged a pro-rata amount for his first debit.
{
    "customerId": "aaf40599-0fbc-44d3-8902-55365c6de9e5",
    "planId": "dd248af1-9be7-4a7b-bb3d-7790fc370a3b",
    "name": "JustTest",
    "accountingCode": "testinModule",
    "autoPayment": "true",
    "markAsPending": "false",
    "startDate": "2019-07-11",
    "intervalUnit": "WEEK",
    "interval": 2,
    "recurringBillingDate": "2019-07-22",
    "amount": {
        "currency": "AUD",
        "value": 100,
        "type": null
    },
    "tax": {
        "rate": 10
    },
    "firstBilling": "prorate",
    "firstBillingAmount": {
        "currency": "AUD",
        "value": 1000
    }
}
{
    "id": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
    "customerId": "aaf40599-0fbc-44d3-8902-55365c6de9e5",
    "planId": "dd248af1-9be7-4a7b-bb3d-7790fc370a3b",
    "name": "JustTest",
    "status": "ACTIVE",
    "startDate": "2019-07-11",
    "endDate": null,
    "paymentMethodToken": "e8f39a55-f48f-4dd1-9330-43283ef85b2d",
    "accountingCode": "testinModule",
    "amount": {
        "currency": "AUD",
        "value": 100.00,
        "type": null
    },
    "tax": {
        "rate": 10
    },
    "nextBillingDate": "2019-07-22",
    "nextFutureInvoice": {
        "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
        "date": "2019-07-22",
        "cycleStartDate": "2019-07-22",
        "cycleEndDate": "2019-08-04",
        "items": [
            {
                "description": "Justin Loh",
                "amount": {
                    "currency": "AUD",
                    "value": 100.00,
                    "type": null
                },
                "tax": {
                    "rate": 10
                },
                "type": "subscription_payment",
                "accountingCode": "testinModule"
            },
            {
                "description": "Transaction Fee",
                "amount": {
                    "currency": "AUD",
                    "value": 1.49,
                    "type": null
                },
                "tax": {
                    "rate": 10.00
                },
                "type": "transaction_fee",
                "accountingCode": null
            }
        ],
        "amount": {
            "currency": "AUD",
            "value": 101.49,
            "type": null
        },
        "totalTax": {
            "currency": "AUD",
            "value": 9.23,
            "type": null
        }
    },
    "interval": 2,
    "intervalUnit": "WEEK",
    "totalPaid": {
        "currency": "AUD",
        "value": 1000.00,
        "type": null
    },
    "totalBillingCycles": 1,
    "remainingToPay": null,
    "remainingBillingCycles": null,
    "endTargetAmount": null,
    "endTargetBillingCycles": null,
    "cancelledDate": null,
    "failedPaymentHandling": null,
    "failedAttemptsCount": 0,
    "totalPastDue": {
        "currency": "AUD",
        "value": 0.00,
        "type": null
    },
    "totalDiscounted": {
        "currency": "AUD",
        "value": 0.00,
        "type": null
    },
    "metadata": null,
    "createdOn": "2019-07-11T05:55:57.860",
    "autoPayment": true,
    "setupPayments": null
}

2. Retrieve future invoice based on the subscription created

[GET] https://api-sandbox.ezypay.com/v2/billing/futureinvoices?subscriptionId={{SubscriptionId}}&customerId={{CustomerId}}&limit=5

{
    "data": [
        {
            "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
            "date": "2019-07-22",
            "cycleStartDate": "2019-07-22",
            "cycleEndDate": "2019-08-04",
            "items": [
                {
                    "description": "JustTest",
                    "amount": {
                        "currency": "AUD",
                        "value": 100.00,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "subscription_payment",
                    "accountingCode": "testinModule"
                },
                {
                    "description": "Transaction Fee",
                    "amount": {
                        "currency": "AUD",
                        "value": 1.49,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "transaction_fee",
                    "accountingCode": null
                }
            ],
            "amount": {
                "currency": "AUD",
                "value": 101.49,
                "type": null
            },
            "totalTax": {
                "currency": "AUD",
                "value": 9.23,
                "type": null
            }
        },
        {
            "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
            "date": "2019-08-05",
            "cycleStartDate": "2019-08-05",
            "cycleEndDate": "2019-08-18",
            "items": [
                {
                    "description": "JustTest",
                    "amount": {
                        "currency": "AUD",
                        "value": 100.00,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "subscription_payment",
                    "accountingCode": "testinModule"
                },
                {
                    "description": "Transaction Fee",
                    "amount": {
                        "currency": "AUD",
                        "value": 1.49,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "transaction_fee",
                    "accountingCode": null
                }
            ],
            "amount": {
                "currency": "AUD",
                "value": 101.49,
                "type": null
            },
            "totalTax": {
                "currency": "AUD",
                "value": 9.23,
                "type": null
            }
        },
        {
            "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
            "date": "2019-08-19",
            "cycleStartDate": "2019-08-19",
            "cycleEndDate": "2019-09-01",
            "items": [
                {
                    "description": "JustTest",
                    "amount": {
                        "currency": "AUD",
                        "value": 100.00,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "subscription_payment",
                    "accountingCode": "testinModule"
                },
                {
                    "description": "Transaction Fee",
                    "amount": {
                        "currency": "AUD",
                        "value": 1.49,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "transaction_fee",
                    "accountingCode": null
                }
            ],
            "amount": {
                "currency": "AUD",
                "value": 101.49,
                "type": null
            },
            "totalTax": {
                "currency": "AUD",
                "value": 9.23,
                "type": null
            }
        },
        {
            "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
            "date": "2019-09-02",
            "cycleStartDate": "2019-09-02",
            "cycleEndDate": "2019-09-15",
            "items": [
                {
                    "description": "JustTest",
                    "amount": {
                        "currency": "AUD",
                        "value": 100.00,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "subscription_payment",
                    "accountingCode": "testinModule"
                },
                {
                    "description": "Transaction Fee",
                    "amount": {
                        "currency": "AUD",
                        "value": 1.49,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "transaction_fee",
                    "accountingCode": null
                }
            ],
            "amount": {
                "currency": "AUD",
                "value": 101.49,
                "type": null
            },
            "totalTax": {
                "currency": "AUD",
                "value": 9.23,
                "type": null
            }
        },
        {
            "subscriptionId": "bd64f730-fdfb-46b5-8a19-cf70661040cc",
            "date": "2019-09-16",
            "cycleStartDate": "2019-09-16",
            "cycleEndDate": "2019-09-29",
            "items": [
                {
                    "description": "JustTest",
                    "amount": {
                        "currency": "AUD",
                        "value": 100.00,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "subscription_payment",
                    "accountingCode": "testinModule"
                },
                {
                    "description": "Transaction Fee",
                    "amount": {
                        "currency": "AUD",
                        "value": 1.49,
                        "type": null
                    },
                    "tax": {
                        "rate": 10.00
                    },
                    "type": "transaction_fee",
                    "accountingCode": null
                }
            ],
            "amount": {
                "currency": "AUD",
                "value": 101.49,
                "type": null
            },
            "totalTax": {
                "currency": "AUD",
                "value": 9.23,
                "type": null
            }
        }
    ],
    "paging": {
        "nextUrl": null,
        "nextCursor": 0,
        "limit": 0,
        "totalCount": 52
    }
}

The response from the [GET] Future Invoice will show the first Billing amount at AUD 1000 to be collected on the configured date.

All re-occurring debits after that will be attempted on every fortnightly


Did this page help you?