Calculate conditions
You might opt to consume the raw data that feeds Nemuru's simulation widget and present available credit conditions to your customer in whichever way you choose.
This method (available within the JavaScript library, nemuru.js
) allows you to obtain the credit conditions for an specific amount, product, and set of terms. If there are no credit conditions available for these parameters, the method will return an empty array.
Firstly, make sure to load and initialize the nemuru.js JavaScript library if you haven't already.
How to call the calculate conditions
Once the library is loaded, the .calculateConditions()
method, made available within the Nemuru
object provided by the library, can be called.
Nemuru.calculateConditions({
conditions: {
amount: 300,
product: "instalments",
terms: [10]
},
onError: (error) => console.log('ON ERROR CALLBACK', error),
});
[
{
"term": 10,
"product": "instalments",
"program": "free_program",
"annualInterest": {
"value": 0,
"string": "0.00 %"
},
"apr": {
"value": 0.3515,
"string": "35.15 %"
},
"setupFeeType": "type_fixed_amount",
"setupFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"principalAmount": {
"value": 300,
"string": "300.00 €"
},
"instalmentAmount": {
"value": 30,
"string": "30.00 €"
},
"instalmentFeeAmount": {
"value": 3.5,
"string": "3.50 €"
},
"instalmentTotalAmount": {
"value": 33.5,
"string": "33.50 €"
},
"downpaymentAmount": {
"value": 30,
"string": "30.00 €"
},
"downpaymentFeeAmount": {
"value": 3.5,
"string": "3.50 €"
},
"downpaymentTotalAmount": {
"value": 33.5,
"string": "33.50 €"
},
"lastInstalmentAmount": {
"value": 30,
"string": "30.00 €"
},
"lastInstalmentFeeAmount": {
"value": 3.5,
"string": "3.50 €"
},
"lastInstalmentTotalAmount": {
"value": 33.5,
"string": "33.50 €"
},
"totalAmount": {
"value": 335,
"string": "335.00 €"
},
"totalInterestAmount": {
"value": 0,
"string": "0.00 €"
},
"totalInstalmentFeeAmount": {
"value": 35,
"string": "35.00 €"
}
}
]
Parameter details:
Field | Type | Required | Description | Example |
---|---|---|---|---|
conditions | object | Required | Input parameters for the calculation | |
conditions.amount | number | Required | The amount to be financed (cents as decimals). | 300.00 |
conditions.product | string | Required | The financial product to be simulated. Possible values are: instalments , split_pay . | "instalments" |
conditions.terms | number[] | Optional | The different terms to be included in the calculation. If no terms provided, the calculation will return all available terms for the amount and product passed | [10, 12] |
onError | function | Optional | This callback fires every time there is an error. For example, the product is not available. |
Although the types of products enabled depend on the agreement between the merchant and lender(s), the common ones are:
instalments
: Your customer pays in instalments with interest or fixed cost per instalment. Pay the first instalment at the checkout (which may have an opening fee) and the rest on the same day for the following X months.split_pay
: Your customer divides the payment in equal parts, no interests applied. Pay the first instalment at the checkout (which may have an opening commission) and the rest on the same day for the following X months.
When the .calculateConditions()
method is called, the result is a breakdown of the various credit conditions for each term specified; that is, an array of objects where each object will refer to a term (term
). If the result is an empty array, it means that for the amount
, product
and terms
provided, there is no combination of conditions available.
Examples
The following examples are based on a fake pricing:
- Amount of 591€.
- Product
instalments
. - Terms 10 and 12 months.
Nemuru.calculateConditions({
conditions: {
amount: 591.00,
product: "instalments",
terms: [10, 12]
}
});
[
{
"term": 10,
"product": "instalments",
"program": "free_program",
"annualInterest": {
"value": 0,
"string": "0.00 %"
},
"apr": {
"value": 0.3575,
"string": "35.75 %"
},
"setupFeeType": "type_fixed_amount",
"setupFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"principalAmount": {
"value": 591,
"string": "591.00 €"
},
"instalmentAmount": {
"value": 59.1,
"string": "59.10 €"
},
"instalmentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"instalmentTotalAmount": {
"value": 66.1,
"string": "66.10 €"
},
"downpaymentAmount": {
"value": 59.1,
"string": "59.10 €"
},
"downpaymentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"downpaymentTotalAmount": {
"value": 66.1,
"string": "66.10 €"
},
"lastInstalmentAmount": {
"value": 59.1,
"string": "59.10 €"
},
"lastInstalmentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"lastInstalmentTotalAmount": {
"value": 66.1,
"string": "66.10 €"
},
"totalAmount": {
"value": 661,
"string": "661.00 €"
},
"totalInterestAmount": {
"value": 0,
"string": "0.00 €"
},
"totalInstalmentFeeAmount": {
"value": 70,
"string": "70.00 €"
}
},
{
"term": 12,
"product": "instalments",
"program": "free_program",
"annualInterest": {
"value": 0,
"string": "0.00 %"
},
"apr": {
"value": 0.3471,
"string": "34.71 %"
},
"setupFeeType": "type_fixed_amount",
"setupFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"principalAmount": {
"value": 591,
"string": "591.00 €"
},
"instalmentAmount": {
"value": 49.25,
"string": "49.25 €"
},
"instalmentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"instalmentTotalAmount": {
"value": 56.25,
"string": "56.25 €"
},
"downpaymentAmount": {
"value": 49.25,
"string": "49.25 €"
},
"downpaymentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"downpaymentTotalAmount": {
"value": 56.25,
"string": "56.25 €"
},
"lastInstalmentAmount": {
"value": 49.25,
"string": "49.25 €"
},
"lastInstalmentFeeAmount": {
"value": 7,
"string": "7.00 €"
},
"lastInstalmentTotalAmount": {
"value": 56.25,
"string": "56.25 €"
},
"totalAmount": {
"value": 675,
"string": "675.00 €"
},
"totalInterestAmount": {
"value": 0,
"string": "0.00 €"
},
"totalInstalmentFeeAmount": {
"value": 84,
"string": "84.00 €"
}
}
]
- Amount of 300€.
- Produt
split_pay
.
Nemuru.calculateConditions({
conditions: {
amount: 300.00,
product: "split_pay",
}
});
[
{
"term": 3,
"product": "split_pay",
"program": "zero_program",
"annualInterest": {
"value": 0,
"string": "0.00 %"
},
"apr": {
"value": 0,
"string": "0.00 %"
},
"setupFeeType": null,
"setupFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"principalAmount": {
"value": 300,
"string": "300.00 €"
},
"instalmentAmount": {
"value": 100,
"string": "100.00 €"
},
"instalmentFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"instalmentTotalAmount": {
"value": 100,
"string": "100.00 €"
},
"downpaymentAmount": {
"value": 100,
"string": "100.00 €"
},
"downpaymentFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"downpaymentTotalAmount": {
"value": 100,
"string": "100.00 €"
},
"lastInstalmentAmount": {
"value": 100,
"string": "100.00 €"
},
"lastInstalmentFeeAmount": {
"value": 0,
"string": "0.00 €"
},
"lastInstalmentTotalAmount": {
"value": 100,
"string": "100.00 €"
},
"totalAmount": {
"value": 300,
"string": "300.00 €"
},
"totalInterestAmount": {
"value": 0,
"string": "0.00 €"
},
"totalInstalmentFeeAmount": {
"value": 0,
"string": "0.00 €"
}
}
]
- Amount of 8000€.
- Product
split_pay
There are no conditions available for this amount and product
Nemuru.calculateConditions({
conditions: {
amount: 8000.00,
product: "split_pay",
}
});
[]