APIs

How to integrate our solutions with APIs

API Integration Guide

Table of Contents

  1. Introduction

  2. API Overview

  3. Getting Started

  4. API Integration Steps

  5. Best Practices and Considerations

  6. Troubleshooting and Support

In this guide you will find snippets for Node.js, Java, PHP and Python server langages.

1. Introduction

This API integration guide will walk you through the process of setting up your environments so you can later consume scalexpert APIs into your application or platform.

By integrating these APIs, you'll be able to initiate and manage e-financing subscriptions on behalf of your customers or dynamically propose warranty extensions for some items on their basket prior checkout.

2. API Overview

The APIs allow for seamless interaction with our platform, enabling you to initiate and manage financing or insurance proposals seamlessly pro-grammatically . Here are some key aspects of the APIs:

  • RESTful architecture: Utilize standard HTTP methods (GET, POST, PUT, DELETE) to interact with the API.

  • JSON-based data format: Send and receive data in JSON format, ensuring compatibility and ease of integration across different programming languages.

  • oAuth2 client credentials authentication flow (server to server).

For more details refer to:

Authentication and Authorization

To access these APIs, you'll need to authenticate your requests by obtaining an oAuth2 access token. API Keys are obtained from the developer portal, which serves as your access credential. They are used to authenticate your service using oAuth 2.0 client credentials flow. Upon authorization for the claimed scopes the issued token will be used to identify each subsequent request.

Refer to authentication API reference for more details:

Obtain an oAuth2 access token

Node.js native
var https = require('follow-redirects').https;
var fs = require('fs');

var qs = require('querystring');

var options = {
  'method': 'POST',
  'hostname': 'api.e-commerce.societegenerale.com',
  'path': '/baas/prod/auth-server/api/v1/oauth2/token',
  'headers': {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': 'Basic ZmU3ZmVmYjktNmEyZ...zdqQW89'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = qs.stringify({
  'grant_type': 'client_credentials',
  'scope': 'e-financing:rw'
});

req.write(postData);

req.end();

API Endpoints and Request/Response Formats

The API provides various endpoints for managing subscriptions or retrieving relevant data. Each endpoint supports specific actions and requires specific parameters. Requests should include appropriate headers, and responses are returned in JSON format.

Refer to the API reference section for detailed information on each endpoint, including request/response examples and required parameters.

3. Getting Started

Prerequisites for Integration

Before starting the integration process, make sure you have complete the prerequisites. Refer to "Before you start" pages for more details

Also have a look at "Security best practices" pages. For instance, make attention that API must be implemented at server side and not at front side.

API Access Credentials and Keys

Refer to "Before you start/API key" section for instructions:

Testing Environment Setup

Set up a testing environment to ensure smooth integration and testing of the E-Financing API:

  • User Acceptance Test for customer (UATC) environment that will simulates the production environment. Use this environment for development, integration, and testing purposes.

  • API Documentation: Familiarize yourself with the API documentation, including endpoint details, request/response examples, and any available snippets that can expedite the integration process.

4. API Integration Steps

Now let's dive into the steps involved in integrating the E-Financing API into your application or platform:

Step 1: Check Eligible E-Financing Solutions

To determine the eligible e-financing solutions available for a specific purchase, follow these steps:

  1. Collect Purchase Information: Gather relevant purchase details, such as the total amount and country of the buyer end user (or by default country of your site).

  2. Make a GET Request: Utilize the API endpoint responsible for checking eligibility, passing the necessary purchase information.

  3. Handle Response: Capture and process the response, which will indicate the available e-financing solutions and their associated merchant communication kit informations.

  4. According the response render the solution to end users for instance on product page by showcasing the solutions (see next step).

Refer to API GET /eligible-solutions

Node.js native
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'api.scalexpert.uatc.societegenerale.com',
  'path': '/baas/uatc/e-financing/api/v1/eligible-solutions?financedAmount=500&buyerBillingCountry=FR',
  'headers': {
    'Authorization': 'Bearer eyJlbmMiOi...TxWr8u9ooNMZ3zI'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();

Step 2: Showcasing the solutions

By "showcasing solutions" we mean rendering the solutions at product or checkout pages (see more details here). This will be possible with the response of GET /eligible-solutions and object "communicationKit" and its attributes that contains texts with HTML, logos, images ...

Response GET /eligible-solutions
{
    "solutions": [
        {
            "solutionCode": "SCFRLT-TXNO",
            "familyCode": "SC",
            "marketCode": "FR",
            "conditions": "PS",
            "communicationKit": {
                "solutionCode": "SCFRLT-TXNO",
                "visualTitle": "<div class=scalexpert_title>Etalez votre paiment avec un crรฉdit</div>",
                "visualDescription": "Un crรฉdit vous engage et doit รชtre remboursรฉ. Vรฉrifiez vos capacitรฉs de remboursement avant de vous engager.",
                "visualInformationIcon": "https://scalexpert.societegenerale.com/app/merchantKit/visual_information_icon.svg",
                "visualAdditionalInformation": "<div class=scalexpert_subtitle>Comment รงa marche ?</div><ol> <li>Ajoutez le produit ร  votre panier et finalisez votre achat. Validez votre panier</li> <li>Au moment du paiement, choisissez d'รฉtaler votre paiement avec un crรฉdit.</li> <li>Renseignez les informations demandรฉes, munissez-vous de votre piรจce d'identitรฉ et signez รฉlectroniquement votre contrat de financement. Obtenez une rรฉponse immรฉdiate de notre partenaire FRANFINANCE. <br>C'est terminรฉ! </li></ol>",
                "visualLegalText": "<div class=scalexpert_subtitle>Mentions lรฉgales</div><p>Un crรฉdit vous engage et doit รชtre remboursรฉ. Vรฉrifiez vos capacitรฉs de remboursement avant de vous engager. Offre valable toute lโ€™annรฉe, ร  partir de 1000 euros de crรฉdit et sous rรฉserve dโ€™acceptation du crรฉdit affectรฉ par FRANFINANCE (SA au capital de 31.357.776,00 euros - 719 807 406 RCS Nanterre - 53 rue du Port, CS 90201, 92724 Nanterre Cedex - France -, Intermรฉdiaire en assurance inscrit lโ€™ORIAS Nยฐ 07 008 346 - www.orias.fr). Vous disposez dโ€™un dรฉlai de rรฉtractation de 14 jours ร  compter de la date de signature du contrat de crรฉdit. Le vendeur est intermรฉdiaire de crรฉdit non exclusif de FRANFINANCE, immatriculรฉ ร  lโ€™ORIAS sous le numรฉro XXXXX (www.orias.fr).</p>",
                "visualTableImage": null,
                "visualLogo": "https://scalexpert.societegenerale.com/app/merchantKit/e_financing_visual_logo_FR.svg",
                "visualInformationNoticeURL": null,
                "visualProductTermsURL": null
            }
        },
```

Rendering of communication KIT (ex long term credit):

<!-- create css classes scalexpert_title and scalexpert_subtitle and standard html tags according your graphical layout standards--> 

<div class=scalexpert_title>Etalez votre paiment avec un crรฉdit</div>

<div class=scalexpert_subtitle>Comment รงa marche ?</div>
<ol> 
    <li>Ajoutez le produit ร  votre panier et finalisez votre achat. Validez votre panier</li>
    <li>Au moment du paiement, choisissez d'รฉtaler votre paiement avec un crรฉdit.</li>
    <li>Renseignez les informations demandรฉes, munissez-vous de votre piรจce d'identitรฉ et signez รฉlectroniquement votre contrat de financement. Obtenez une rรฉponse immรฉdiate de notre partenaire FRANFINANCE. <br>C'est terminรฉ! </li>
</ol>

<div class=scalexpert_subtitle>Mentions lรฉgales</div>
<p>Un crรฉdit vous engage et doit รชtre remboursรฉ. Vรฉrifiez vos capacitรฉs de remboursement avant de vous engager. Offre valable toute lโ€™annรฉe, ร  partir de 1000 euros de crรฉdit et sous rรฉserve dโ€™acceptation du crรฉdit affectรฉ par FRANFINANCE (SA au capital de 31.357.776,00 euros - 719 807 406 RCS Nanterre - 53 rue du Port, CS 90201, 92724 Nanterre Cedex - France -, Intermรฉdiaire en assurance inscrit lโ€™ORIAS Nยฐ 07 008 346 - www.orias.fr). Vous disposez dโ€™un dรฉlai de rรฉtractation de 14 jours ร  compter de la date de signature du contrat de crรฉdit. Le vendeur est intermรฉdiaire de crรฉdit non exclusif de FRANFINANCE, immatriculรฉ ร  lโ€™ORIAS sous le numรฉro XXXXX (www.orias.fr).</p>

Make sure at minimum "visualLegalText" is always rendered on your site for legal compliance.

Step 3: Initiate an E-Financing Subscription

To initiate an e-financing subscription for a customer, follow these steps:

  1. Collect Customer Information: Gather the required customer information, such as name, contact details, and billing address.

  2. Make a POST Request: Use the appropriate API endpoint, passing the necessary customer information and subscription details.

  3. Handle Response: Capture and process the response, which will contain the subscription ID and any additional information provided by the API.

Refer to API POST /susbscriptions

Node.js - Native
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.e-commerce.uatc.societegenerale.com',
  'path': '/baas/uatc/e-financing/api/v1/subscriptions',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJlbmMiOiJBMjU2Q0J...u9ooNMZ3zI'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "financedAmount": 119.9,
  "solutionCode": "SCFRSP-4XTS",
  "merchantBasketId": "647aeb24-a89c-11ed-afa1-0242ac120002",
  "merchantGlobalOrderId": "XbB6_sMPbkvRk0y#206578",
  "merchantBuyerId": "701943",
  "merchantUrls": {
    "confirmation": "https://mymerchand.domain/uri"
  },
  "buyers": [
    {
      "billingContact": {
        "lastName": "Dupont",
        "firstName": "Paul",
        "commonTitle": "Mr.",
        "email": "paul.dupont@mail.com",
        "mobilePhoneNumber": "+33684749393",
        "professionalTitle": "Professor",
        "phoneNumber": "+33184749393"
      },
      "billingAddress": {
        "locationType": "billingAddress",
        "streetNumber": 147,
        "streetNumberSuffix": "B",
        "streetName": "main street",
        "streetNameComplement": "block 47",
        "zipCode": "92060",
        "cityName": "Paris",
        "regionName": "รŽle-de-France",
        "countryCode": "FR"
      },
      "deliveryContact": {
        "lastName": "Dupont",
        "firstName": "Paul",
        "commonTitle": "Mr.",
        "email": "paul.dupont@mail.com",
        "mobilePhoneNumber": "+33684749393",
        "professionalTitle": "Professor",
        "phoneNumber": "+33184749393"
      },
      "deliveryAddress": {
        "locationType": "billingAddress",
        "streetNumber": 147,
        "streetNumberSuffix": "B",
        "streetName": "main street",
        "streetNameComplement": "block 47",
        "zipCode": "92060",
        "cityName": "Paris",
        "regionName": "รŽle-de-France",
        "countryCode": "FR"
      },
      "contact": {
        "lastName": "Dupont",
        "firstName": "P",
        "commonTitle": "Mr.",
        "email": "paul.dupont@mail.com",
        "mobilePhoneNumber": "+33684749393",
        "professionalTitle": "Professor",
        "phoneNumber": "+33184749393"
      },
      "contactAddress": {
        "locationType": "billingAddress",
        "streetNumber": 147,
        "streetNumberSuffix": "B",
        "streetName": "main street",
        "streetNameComplement": "block 47",
        "zipCode": "92060",
        "cityName": "Paris",
        "regionName": "รŽle-de-France",
        "countryCode": "FR"
      },
      "deliveryMethod": "Click & Collect",
      "birthName": "Dupont",
      "birthDate": "01021975",
      "birthCityName": "Montpellier",
      "birthCountryName": "FR",
      "vip": false
    }
  ],
  "basketDetails": {
    "basketItems": [
      {
        "id": "M12345785513211",
        "quantity": 2,
        "model": "5KPM5",
        "label": "PANTALON B MAGO",
        "price": 9500,
        "currencyCode": "EUR",
        "orderId": "OD456742",
        "brandName": "KitchenAid",
        "description": "Le robot pรขtissier ร  bol relevable trรจs rรฉsistant idรฉal pour mixer de grandes quantitรฉs d'ingrรฉdients, รฉquipรฉ d'un bol en acier inoxydable amovible.",
        "specifications": "Puissance (W) 315, Tension (V) 220-240, Frรฉquence (Hz) 50/60",
        "category": "R78757857",
        "isFinanced": true,
        "sku": "50"
      }
    ]
  }
});

req.write(postData);

req.end();

Step 4: Retrieve E-Financing Subscription Details

To retrieve the details of a specific e-financing subscription, follow these steps:

  1. Get Subscription ID: Obtain the unique subscription ID associated with the e-financing subscription you want to retrieve details for.

  2. Make a GET Request: Use the appropriate API endpoint, providing the unique subscription ID, to retrieve the subscription details.

  3. Handle Response: Capture and process the response, which will contain comprehensive information about the requested subscription, including payment schedule, repayment amounts, and status.

Node.Js - Native
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'api.e-commerce.hml.societegenerale.com',
  'path': '/baas/uat/e-financing/api/v1/subscriptions/eb6adb12-5c1d-4b30-9b24-7854d755cd55',
  'headers': {
    'Authorization': 'Bearer eyJlbmMiOiJBMjU2Q0JDLUhTNTE...Uj6m2ZXbgRPYXZ_8wKIRfI'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();