Getting Started

By reading this page, you will be ready to connect your website with our financing platform. Your website will show our available financing options on the product pages and have our financing platform as a payment option.

Product financing options

With our JavaScript plugin you'll provide to your users a way to see the financing options available to them with no effect to their credit and start the pre-qualification process.

Install the plugin

The only thing you need to do is place the following script near the end of your page:

<script src="https://plugin.credova.com/plugin.min.js"></script>
tip

Don't insert the script in the head tag. The plugin injects some elements to the page, so it requires the head tag to be fully loaded to work properly.

Configure your store

For the plugin work correctly, you need to call the config method passing the desired environment and your store code:

CRDV.plugin.config({ environment: CRDV.Environment.Sandbox, store: "YOUR-STORE-CODE" });

Show prequalify option

The simplest way to start the pre-qualification process is by using our pre-qualification button. The image below is a sample of how it could look on your page (the text Payment as low as ... was added by the plugin).

You only have to add an element to the page and call the inject method passing the class name of the element as shown below:

CRDV.plugin.inject("your-class-name");

The element can be a <span>, <div> or <p> and you need to include the data attributes amount and type:

<p class="your-class-name" data-amount="1245.67" data-type="popup"></p>

Here's an example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CRDV</title>
</head>
<body>
<p class="credova-button" data-amount="1245.67" data-type="popup"></p>
<script src="https://plugin.credova.com/plugin.min.js"></script>
<script>
CRDV.plugin.config({ environment: CRDV.Environment.Sandbox, store: "ARV000" });
CRDV.plugin.inject("credova-button");
</script>
</body>
</html>

Check the pre-qualification documentation for more customization options.

Add payment option

After the user selects our financing platform during the checkout in your website, you have to create an application using our API passing the user data and the products from the cart.

Authentication

To make authenticated requests, first, you must make a call to the Generate authentication token method to obtain the authentication token:

<?php
$headers = array(
"Content-Type: application/x-www-form-urlencoded"
);
$fields = array(
"username" => "foo",
"password" => "bar"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sandbox-lending-api.credova.com/v2/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=foo&password=bar");
$response = curl_exec($ch);
$decoded = json_decode($response, TRUE);
$authentication_token = $decoded["jwt"];

Create the application

With the authentication token in hands, you can call our API to create the application:

<?php
$authentication_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer ".$authentication_token
);
$fields = array(
"storeCode" => "LIPSUM",
"firstName" => "Lorem",
"lastName" => "Ipsum",
"dateOfBirth" => "1983-04-01",
"mobilePhone" => "123-456-789",
"email" => "[email protected]",
"referenceNumber" => "3456789",
"containsFirearm" => "false",
"address" => array(
"street" => "45999 Center Oak Plaza",
"suiteApartment" => "100",
"city" => "Sterling",
"state" => "VA",
"zipCode" => "20166"
),
"products" => array(
array(
"id" => "1",
"description" => "Foo",
"serialNumber" => "FOO001",
"quantity" => "1",
"value" => "1000.00",
"salesTax" => "100.00"
),
array(
"id" => "2",
"description" => "Bar",
"serialNumber" => "BAR001",
"quantity" => "2",
"value" => "2200.00",
"salesTax" => "220.00"
)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sandbox-lending-api.credova.com/v2/applications");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$response = curl_exec($ch);
$decoded = json_decode($response, TRUE);
$public_id = $decoded["publicId"];
$link = $decoded["link"];

The method returns a Public ID and a link that you can use to redirect the user to complete the process.

If you want to keep the user on your website, you can use the checkout method from our plugin to open the checkout popup.

Open checkout

To open the checkout popup you only have to call the checkout method passing the Public ID returned by the API.

CRDV.plugin.checkout("the-public-id");

The popup will guide the user throughout the checkout process.

The checkout method returns a promise that you can use to check if the user completed the process or closed the popup.

CRDV.plugin.checkout("the-public-id").then(function(completed) {
if (completed) {
console.log("Checkout was completed");
} else {
console.log("Checkout was closed");
}
});

Here's an example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CRDV</title>
</head>
<body>
<script src="https://plugin.credova.com/plugin.min.js"></script>
<script>
CRDV.plugin.config({ environment: CRDV.Environment.Sandbox, store: "ARV000" });
CRDV.plugin.checkout("the-public-id").then(function(completed) {
if (completed) {
console.log("Checkout was completed");
} else {
console.log("Checkout was closed");
}
});
</script>
</body>
</html>

Send order's invoice

When invoices are required, you have to send the order’s invoice to us in order to be funded. Our API has a method to help you automate the upload of the file for a specific application.

You must have an authentication token to upload the invoice.

Here's an example:

<?php
$authentication_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
$public_id = "c4c4eede-cbb0-4efd-8e10-aa1d02392ce6";
$headers = array(
"Content-Type: multipart/form-data",
"Authorization: Bearer ".$authentication_token
);
$fields = array(
"file" => new CurlFile("invoice.pdf", "application/pdf", "invoice.pdf")
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sandbox-lending-api.credova.com/v2/applications/".$public_id."/uploadinvoice");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_exec($ch);

See the upload invoice method documentation for more details.

Next

Check our API v2 and Plugin guides to see how to extend and improve your user experience using our platform.