Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save juanrdlo/0f344b2aecf8569b194f1f6bc4823e2a to your computer and use it in GitHub Desktop.
Save juanrdlo/0f344b2aecf8569b194f1f6bc4823e2a to your computer and use it in GitHub Desktop.

Revisions

  1. Jonathan Carter revised this gist May 21, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -27,9 +27,9 @@ We also have pre-built plugins for many top e-commerce systems.
    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.

    ## Divido API
    -[Divido Api](https://divido.api-docs.io/1.0.1/api-help/api-change-log)
    -[php-sdk](https://packagist.org/packages/divido/merchant-sdk)
    -[Legacy Api](http://developer.divido.com)
    - [Divido Api](https://divido.api-docs.io/1.0.1/api-help/api-change-log)
    - [php-sdk](https://packagist.org/packages/divido/merchant-sdk)
    - [Legacy Api](http://developer.divido.com)

    ## The Divido Process

  2. Jonathan Carter revised this gist May 21, 2019. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -22,14 +22,14 @@ We also have pre-built plugins for many top e-commerce systems.

    [Woocommerce](https://wordpress.org/plugins/finance-gateway-for-woocommerce/)

    [Integrations Release notes](http://integrations.divido.com/category/release-notes/)

    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.

    ## Divido API
    [Divido Api](https://divido.api-docs.io/1.0.1/api-help/api-change-log)
    [php-sdk](https://packagist.org/packages/divido/merchant-sdk)

    [Legacy Api](http://developer.divido.com)
    [Integrations Release notes](http://integrations.divido.com/category/release-notes/)
    -[Divido Api](https://divido.api-docs.io/1.0.1/api-help/api-change-log)
    -[php-sdk](https://packagist.org/packages/divido/merchant-sdk)
    -[Legacy Api](http://developer.divido.com)

    ## The Divido Process

  3. Jonathan Carter revised this gist May 21, 2019. 1 changed file with 15 additions and 8 deletions.
    23 changes: 15 additions & 8 deletions Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -6,23 +6,30 @@ This document assumes you are developing a reusable plugin to a shop system and

    We also have pre-built plugins for many top e-commerce systems.

    [Magento](https://github.com/DividoFinancialServices/divido-magento)
    [Magento](https://github.com/DividoHq/finance-plugin-magento)

    [Magento 2](https://github.com/DividoFinancialServices/divido-magento2)
    [Magento 2](https://github.com/DividoHq/finance-plugin-magento2)

    [Opencart](https://github.com/DividoFinancialServices/divido-opencart)
    [Opencart](https://github.com/DividoHq/finance-plugin-opencart)

    [Prestashop](https://github.com/DividoFinancialServices/divido-prestashop)
    [Prestashop](https://github.com/DividoHq/finance-plugin-prestashop)

    [Shopware](https://github.com/DividoFinancialServices/divido-shopware)
    [Shopware](https://github.com/DividoHq/finance-plugin-shopware)

    [Woocommerce](https://wordpress.org/plugins/divido-for-woocommerce/)
    [OSCommerce](https://github.com/DividoHq/finance-plugin-oscommerce)

    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.
    [Zencart](https://github.com/DividoHq/finance-plugin-zencart)

    [Woocommerce](https://wordpress.org/plugins/finance-gateway-for-woocommerce/)

    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.

    ## Divido API
    [Divido Api](http://developer.divido.com)
    [Divido Api](https://divido.api-docs.io/1.0.1/api-help/api-change-log)
    [php-sdk](https://packagist.org/packages/divido/merchant-sdk)

    [Legacy Api](http://developer.divido.com)
    [Integrations Release notes](http://integrations.divido.com/category/release-notes/)

    ## The Divido Process

  4. Jonathan Carter revised this gist Aug 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -296,7 +296,7 @@ Type: List of strings
    Offers multiple-select boxes or a list of checkboxes with the result from a call to our API getFinances
    Dependencies: Only shown if **Available on finance** is set to "Selected plans".

    ### Calculating available financing plans -- to-do
    ### Calculating available financing plans

    You need to calculate the available financing plans on both the product page and the checkout page. How you do it on the checkout page will depend on your use case, but here we show how we do it in our generic plugins as an example.

  5. Jonathan Carter revised this gist Aug 23, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -7,14 +7,22 @@ This document assumes you are developing a reusable plugin to a shop system and
    We also have pre-built plugins for many top e-commerce systems.

    [Magento](https://github.com/DividoFinancialServices/divido-magento)

    [Magento 2](https://github.com/DividoFinancialServices/divido-magento2)

    [Opencart](https://github.com/DividoFinancialServices/divido-opencart)

    [Prestashop](https://github.com/DividoFinancialServices/divido-prestashop)

    [Shopware](https://github.com/DividoFinancialServices/divido-shopware)

    [Woocommerce](https://wordpress.org/plugins/divido-for-woocommerce/)

    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.

    ## Divido API
    [Divido Api](http://developer.divido.com)


    ## The Divido Process

  6. Jonathan Carter revised this gist Aug 23, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,12 @@ This document assumes you are developing a reusable plugin to a shop system and

    We also have pre-built plugins for many top e-commerce systems.

    [Magento](https://github.com/DividoFinancialServices/divido-magento)
    [Magento 2](https://github.com/DividoFinancialServices/divido-magento2)
    [Opencart](https://github.com/DividoFinancialServices/divido-opencart)
    [Prestashop](https://github.com/DividoFinancialServices/divido-prestashop)
    [Shopware](https://github.com/DividoFinancialServices/divido-shopware)
    [Woocommerce](https://wordpress.org/plugins/divido-for-woocommerce/)

    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.

  7. Jonathan Carter revised this gist Aug 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ At [https://demo.divido.com/](https://demo.divido.com/) you can find an example
    ## Global settings
    To provide the merchant with the possibilites to customise their Divido integration in a way that it suits their business, you need to add a list of options to the payments section of the webshop settings.

    Below is a list of what should minimally be included in this list. More options are discussed under the section [limiting availible payment plans](#limiting-availible-payment-plans)
    Below is a list of what should minimally be included in this list. More options are discussed under the section [limiting available payment plans](#limiting-available-payment-plans)

    Please note that the names of the options are only guidelines and can be changed to suit the shop's platform.

  8. Jonathan Carter revised this gist Aug 23, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Custom Integration Guide.md
    Original file line number Diff line number Diff line change
    @@ -279,7 +279,8 @@ Options: Default settings, Selected plans

    ### Available plans
    Type: List of strings
    Offers multiple-select boxes or a list of checkboxes with the result from a call to our API #endpoint:NJJsNmqqrbt7HZEZ7. Dependencies: Only shown if **Available on finance** is set to "Selected plans".
    Offers multiple-select boxes or a list of checkboxes with the result from a call to our API getFinances
    Dependencies: Only shown if **Available on finance** is set to "Selected plans".

    ### Calculating available financing plans -- to-do

  9. Jonathan Carter renamed this gist Aug 23, 2018. 1 changed file with 0 additions and 0 deletions.
  10. Jonathan Carter created this gist Aug 23, 2018.
    311 changes: 311 additions & 0 deletions Custom Integration Guide
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,311 @@
    # Custom Integration Guide

    An overview of how to integrate Divido as a payment option to any webshop.

    This document assumes you are developing a reusable plugin to a shop system and it will guide through creating your own integration to any platform. If you are adding Divido to a custom-built webshop or as a one-off integration, some of the sections, such as the settings, might not apply to your case.

    We also have pre-built plugins for many top e-commerce systems.


    We are actively developing additional plugins and if your system is not in this list <a href="mailto:[email protected]">contact us</a> to find out if we can add yours.


    ## The Divido Process

    An overview of the steps a customer goes through when checking out using Divido as the payment method:

    |# |Where |Webhook|What's Happening |
    |---|----------|---|-----------------|
    |1 | Merchant |N |Choose Divido as payment method, Select financing plan and deposit percentage|
    |2 |Merchant |N |Confirm, redirections to ...|
    |3 |Divido |Y |Start of Divido application process|
    |4 |Divido |Y |Enter personal and banking info|
    |5 |Divido |Y |Pay deposit|
    |6 |Divido |Y |Sign Contract|
    |7 |Divido |N |Thank you page, redirection to ...|
    |8 |Merchant |N |Success Page|

    At [https://demo.divido.com/](https://demo.divido.com/) you can find an example of a Shopify site that is integrated with Divido and see a standard customer journey.

    ## Sequence Guide

    ![sequence diagram](https://s3-eu-west-1.amazonaws.com/content.divido.com/images/documentation/basic-direct-application-flow.jpg)

    # Parts of the integration

    ## Global settings
    To provide the merchant with the possibilites to customise their Divido integration in a way that it suits their business, you need to add a list of options to the payments section of the webshop settings.

    Below is a list of what should minimally be included in this list. More options are discussed under the section [limiting availible payment plans](#limiting-availible-payment-plans)

    Please note that the names of the options are only guidelines and can be changed to suit the shop's platform.

    ### API Key
    >Type: String

    Example: `sandbox_ccdc53735.b04d5a8270cf7cf8d24238e5a2a5fe4f` Contains the API key necessary for communication with Divido's services.

    ### Enabled
    >Type: Bool

    Quickly enables/disables the Divido payment option and product page calculator.

    ### Title
    >Type: String

    Lets the customer pick their own title for the payment option at checkout.

    ### Show product page widget
    >Type: Bool

    Toggles the product page widget.

    ### Order status on creation
    >Type: Order status

    Provides a list of possible/applicable order statuses, so that the merchant can choose what status an order created by Divido gets.

    ### Order creation level
    >Type: String

    Possible values: `ACCEPTED`, `SIGNED`, `READY`
    Lets the merchant choose when in the Divido process an order is created/escalated. The recommended value is 'READY' as a customer has checked out successfully only after they have signed and thus their application is ready to be fulfilled.

    ### Send automatic fulfilment update
    Type: Bool
    Toggles whether or not the plugin sends an automatic update call to Divido when a Divido order reaches the 'READY' status.

    ### Fulfilment status
    Type: Order status
    If "Send automatic fulfilment update" is True, this is the order status it would react to.

    ### Cart amount limit
    Type: Float
    Lets the merchant define an amount, under which a cart is not eligible to be paid for with Divido.

    ### Product selection
    >Options: All products, Products above specified price

    Above is the two required options, see more under [limiting available payment plans](#limiting-available-payment-plans)

    ### Product price limit
    >Type: Float

    If "Product selection" is set to "Products above specified price", this is the price limit against which products are checked.

    ## Merchant specific javascript
    For every customer, Divido provides javascript generated specifically for them by adding their API key.

    This javascript contains functionality for showing dynamic calculators and widgets, as well as info about available financing products. Since this script is regenerated when the customers plans are updated, it should not be hosted locally, but sourced from Dividos CDN.

    The URL of the script follows this pattern: `//cdn.divido.com/calculator/[API KEY].js` The `[API KEY]` placeholder is replaced by the part of the API key up to the period.

    So if the API key is `sandbox_ccdc53735.b04d5a8270cf7cf8d24238e5a2a5fe4f`
    The part we use for the javascript URL is `sandbox_ccdc53735`

    Example: `//cdn.divido.com/calculator/sandbox_ccdc53735.js`

    This script must be included on the product page and the checkout page and anywhere else you want to display a Divido calculator or widget.

    ## Product page widget

    The Divido product page widget is the Divido calculator which pops up after clicking on the instalment amount that should be displayed close to the product price. It allows the customer to get a quick overview of what financing options are available on that specific product, the cost break-down for each option and how different levels of deposit will affect this cost break-down.

    In its most basic form, it looks like this:

    ```
    <div
    data-divido-widget
    data-divido-mode="popup"
    data-divido-prefix="finance for"
    data-divido-suffix="with"
    data-divido-title-logo
    data-divido-amount="2000"
    data-divido-apply="true"
    data-divido-apply-label=“Apply Now"
    data-divido-plans
    >
    </div>
    ```

    ![Popup Widget](https://s3-eu-west-1.amazonaws.com/content.divido.com/images/documentation/widget-screens/button.png)

    ![Popup Widget](https://s3-eu-west-1.amazonaws.com/content.divido.com/images/documentation/widget-screens/popup_widget.png)


    We suggest you place it directly under the price on the product page. Don't forget to take the values of the "Product selection" and "Product price limit" into account when deciding whether or not to show it!

    It's only the tag that's needed, the Divido javascript will take care of the rest.

    ## Checkout form

    When the customer has chosen Divido as their payment option, you need to provide them with a form where they can choose the finance product and set a deposit amount. Our Calculator Widget provides an interactive user-friendly form.

    Here is the code you need to install the Calculator Widget:

    Include this javascript on the page: `https://cdn.divido.com/calculator/v2.1/production/js/template.divido.js`


    In the head of the page add in your sandbox key as a global js variable.

    Javascript
    ```
    <script>
    var dividoKey = "<YOUR KEY HERE>";
    window.DIVIDO_WIDGET = {
    deposit: 20
    }
    </script>
    ```

    Create a div with the options adjusted to your requirements. Put this div inside the `<form>` element of the checkout -
    It adds two hidden fields for you
    `divido_deposit`
    `divido_plan`

    html
    ```
    <div
    data-divido-widget
    data-divido-prefix="finance for"
    data-divido-suffix="with"
    data-divido-title-logo
    data-divido-amount="2000"
    data-divido-apply="true"
    data-divido-apply-label=“Apply Now"
    data-divido-plans
    >
    </div>
    ```

    If the html is loaded before the javascript is run, you can run the following to reset the widget
    ```html
    TemplateCalculator.reload()
    ```

    The Divido javascript will take care of making this interactive. When the customer has chosen the finance plan and deposit, you need to collect that data and send it, along with additional information about the order and the customer, to make a credit request.

    ## Credit request


    The first step in a credit application starts with a credit request. It is simply an HTTP POST call to our web service, containing customer and order data that is used as the basis for the credit application.

    See Create Application

    You can see the full documentation for this call in the credit request section of our API documentation. Please note that the host name differs depending on whether you're using a live or sandbox key, see API
    endpoints - it will either be http://merchant-api.dev.divido.net

    If the call is correctly done, the response will contain a field named "url". To start the credit application, redirect the user to that URL.

    The customer has now left the merchants shop and is walked through a series of steps in the Divido credit application process. Each of those steps results in an update call back to your server, Webhooks.

    ## Handling Webhooks (automatic updates from Divido)

    Whenever the customer completes a step in the credit application process, an HTTP POST call is sent to the URL specified in the credit request field "response_url".

    These are the events we send updates for, and a list of their possible statuses:

    + Basic application is finished
    + ACCEPTED
    + REFERRED
    + DECLINED

    + Basic application has been cancelled by customer
    + CANCELLED
    + Deposit has been paid
    + DEPOSIT-PAID
    + Contracts have been signed
    + SIGNED
    + READY
    + Merchant marks order as fulfilled
    + ACTION-LENDER

    When the application is done, the information is sent to the underwriter for review. This is for the most part an automated process and the application gets accepted or declined directly.

    In some cases, however, the underwriter will have to do a manual review of the application and its status is set to "referred". This will pause the application process and the customer will be given the choice to wait for the approval process to finish or return to the merchant.

    When referred, the approval process takes up to 3 days and when it is done, the customer gets an email with a link that places them right where they left off in the application process.
    > Here's an example of the payload:

    ```json
    {
    "application": 'C84047A6D-89B2-FECF-D2B4-168444F5178C',
    "reference": 100024,
    "status": 'SIGNED',
    "live": true,
    "metadata": {
    "Invoice Number":"844001",
    "Order Number":"100019"
    }
    }
    ```

    Field for field, these are the contents:

    **application**: The ID of the Application, we recommend you save this for further reference.

    **reference**: Third part reference, if sent with credit request
    status: This is the actual status update!

    **live**: Whether or not this comes from our live environment (false = sandbox environment)

    **metadata**: This contains whatever you sent us in the metadata field when you did the credit request.

    ## Security
    To make sure no one is falsely sending you status updates, you need to verify that the updates are actually from us and that they refer to actual orders. To acheive this, we usually create a unique salt. Store it together with the order id, create a hash based on the salted order ID and send the hash and the order ID in the credit request metadata. When the status update comes back, we salt the order ID, hash it and check it against the hash that is in the metadata.

    ## Limiting available payment plans
    Merchants sometimes need to tailor the list of available finance plans to suit their business needs. To allow this you need to provide a way to limit the overall available finance plans and often more granualar settings targeting categories, brands or individual products.

    What's needed really comes down to the individual merchant. Here we will detail the solution we ship with our generic Magento plugin.

    ### Global settings

    **Shown plans** Options: All plans, Selected plans

    ### Available plans
    Type: List of strings

    Offers multiple-select boxes or a list of checkboxes with the result from a call to our API (http://developer.divido.com/#resources-finances). Dependencies: Only shown if **Shown plans** is set to "Selected plans"

    ### Product selection
    Extra option: Selected products
    When this is option is chosen, a product is only available on finance if it has specifically been enabled. Used in combination with **Shown plans** set to "Selected plans".

    ### Product settings

    ### Available on finance
    Options: Default settings, Selected plans

    ### Available plans
    Type: List of strings
    Offers multiple-select boxes or a list of checkboxes with the result from a call to our API #endpoint:NJJsNmqqrbt7HZEZ7. Dependencies: Only shown if **Available on finance** is set to "Selected plans".

    ### Calculating available financing plans -- to-do

    You need to calculate the available financing plans on both the product page and the checkout page. How you do it on the checkout page will depend on your use case, but here we show how we do it in our generic plugins as an example.

    ### Product

    > Naive pseudo code:

    ```
    If global setting "Product selection" is "Selected products"
    If product setting "Available plans" is "Default settings"
    Let Plans be global setting "Available plans"
    Else
    Let Plans be product setting "Available plans"
    Let Plans be global setting "Available plans"
    Return Plans that has a minimum price lower than the product price
    ```

    ### Cart
    The code added to the webshop's cart to incorporate finance purchases on finance
    > This naive pseudo code will help you build the code for your checkout page:

    ```
    For each product in the cart
    Collect all plans for the product
    Return all plans that has a minimum price lower than the full order value
    Else
    ```