Payment Plugin

The Payment Plugin is an iframe, embeddable in your own site, that enables the user to sign-up or sign-in, apply for a spending limit, enter payment method(s), submit their First Payment, and sign the

The Payment Plugin is a suite of embeddable components that enable your customers to sign-up or sign-in through FlexShopper, apply for a spending limit, enter payment method(s), submit their First Payment and sign their lease.

Embed Inline Frame (iframe)

<script src="https://pp3.flexshopper.com/sdk/js?authKey=AUTH_KEY"></script>
<script>
    FlexSDK.Button({
        createOrder: function() {}
        onSign: function() {}
    }).render('#elementSelector');
</script>

Create Transaction

To create a lease, the createOrder method must be implemented. It will be called when the customer clicks on the FlexPay Payments button; once called, createOrder:

  • Makes use of actions.transaction.create() to create a valid order.

  • Launches the FlexShopper Payment modal where the customer may apply, get a spending limit, and sign the lease for their cart. Upon receiving a spending limit, customers are also given the chance to return to the store and add more items to their cart.

FlexSDK.Button({
    createOrder: function(data, actions) {
        return actions.transaction.create({
                cost: 120.34,
                transactionId: "ABC-129384",
                items: [
                    {
                        description: "Macbook Pro 13",
                        sku: "ABC123",
                        cost: 120.34,
                        brand: "Apple",
                        condition: "new",
                        quantity: 1,
                        images: [ // optional
                          "https://images.dog.ceo/breeds/husky/n02110185_11635.jpg"
                        ],
                        shipping: {
                          cost: 10.33,
                          date: new Date(),
                          method: "UPS"
                        }
                    }
                ]
            });
    }
}).render('#elementSelector');

Finalize Transaction

Once the consumer has signed their lease, the onSign method will be called. In this method you are required to:

  • Retrieve the order from FlexShopper's system and validate the signed agreement.

  • Finalize the order, confirming the lease's total value and items, as well as confirming that the shipping process is underway.

If these steps are not followed, orders may not be fulfilled or billed correctly. You will have to implement an endpoint that your customers can interact with that consumes our Backend API:

Client-side

FlexSDK.Button({
    onSign: function(data) {
        return fetch('/validate-order', {
            method: 'POST',
            body: JSON.stringify(data)
        })
    }
}).render('#elementSelector');

The data object will have the following shape:

{
    "leaseNumber": "1234567",
    "transactionId": "ABC-129384"
}

Server-side

const axios = require('axios');
// helper method holding business logic to validate order
const checkOrder = require('utils/check-order.js');

const flexShopperClient = axios.create({
 baseURL: '/v3',
 headers: {
  Authorization: 'YOUR_API_KEY'
 }
});

 export const validateOrderHandler = async (req, res) => {
  const transactionId = req.body.transactionId;
  const transaction = await flexShopperClient.get(`/transactions/${transactionId}`)
  const orderStatus = await checkOrder(transaction)

  if (!orderStatus.isValid) {
   res.json({valid: false, errors: orderStatus.errors});
   return res.send(400);
  }

  await flexShopperClient.post(`/transactions/${transactionId}/finalize`)

  res.json({valid: true});
  res.send(200);
 };

Confirm Order

Once FlexShopper receives confirmation that the consumer has received their item (delivery confirmation), your organization will be paid for the value of the lease. Use the Confirm Shipment API endpoint to inform FlexShopper of the shipment's status:

Confirm Shipment

Once you've confirmed shipment, you're done. That's all there is to it!

Last updated

Was this helpful?