Funding account widget
Read on adding funding accounts in safe and secure way
You will need to use our widget with the type "CARD" to add a card or "BANK" to add a bank as a funding account. A particular user can only have 2 active bank and 2 active card accounts.
To initialize the widget, you will need to first generate a Widget Token, which will only be valid for a certain time period. You will need to pass this token along with the Sender ID to widget initialization snippets.

GET /users/{{user_id}}/widget-token

Response Parameters
Request Sample
Response Sample
Field
Required
Type
Description
token
Yes
String
Token Details
user_id
Yes
UUID
User ID
expiry_minutes
Yes
Numeric
Token validity time
1
curl --location -g --request GET '{{url}}/users/{{user_id}}/widget-token' \
2
--header 'X-Client-Id: {{client_id}}' \
3
--header 'X-Client-Secret: {{client_secret}}' \
4
--header 'Content-Type: application/json'
Copied!
1
{
2
"expiry_minutes": 15,
3
"user_id": "85e1595e-4b08-44d6-acdf-e842149e8f6a",
4
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZW5kZXJJZCI6Ik9EVmxNVFU1TldVdE5HSXdPQzAwTkdRMkxXRmpaR1l0WlRnME1qRTBPV1U0WmpaaFxyXG4iLCJtdG9JZCI6IlFUQXdNd1xyXG4iLCJyb2xlcyI6WyJXSURHRVQiXSwib3JpZ2luYXRvciI6IkEwMDMiLCJleHAiOjE2MzYzMzkxMDEsImFmZmlsaWF0ZSI6IkEwMDMiLCJhZmZpbGlhdGVJZCI6NH0.JEXzaJeqpREbi2j1krWfgTAAKmS9Lh3q7PFpYppO4dU"
5
}
Copied!
After you have the Widget Token, you will need to follow the steps mentioned below to set up the widget.

1. Include the Widget Script

1
<script src="https://widget.v4sandbox.machpay.com/widget/widget.js" charset="utf-8"></script>
Copied!

2. Create a div where widget needs to be placed

1
<div id="widget-root"></div>
Copied!

3. Initialize the Widget

For Card
For Bank
1
<script>
2
var widget = new MachnetWidget({
3
elementId: "widget-root",
4
userId: "{{user_id}}",
5
width: "100%",
6
height: "200px",
7
type: "card",
8
locale: "en",
9
multiStep: true,
10
stylesheet: "https://example.com/mystyle.css",
11
token: "{{token}}",
12
});
13
widget.init();
14
</script>
Copied!
1
<script>
2
var widget = new MachnetWidget({
3
elementId: "widget-root",
4
userId: "{{user_id}}",
5
width: "100%",
6
height: "200px",
7
type: "bank",
8
locale: "en",
9
multiStep: true,
10
stylesheet: "https://example.com/mystyle.css",
11
token: "{{token}}",
12
});
13
widget.init();
14
</script>
Copied!