@migopayments/sdk v2.3.0
๐งฐ Prerequisites
- Install node.js in your environment
- Access to merchant and privateKey credentials provided by MigoPayments.
๐ฆ Installation
$ npm install @migopayments/sdk
๐ Initial Configuration
Initialize the SDK with credentials provided by MigoPayments and set up the environment you wish to work in.
import { loadMigo } from "@migopayments/sdk";
const initSdk = async () => {
const migo = await loadMigo({
merchant: "merchant_id", // provided by Migo
privateKey: "private_key", // provided by Migo
environment: "sandbox",
});
// Use `migo` for your transactions
};
initSdk();
Environment | Description |
---|---|
sandbox | Use this to build and test your application ๐งช. |
production | Use this for production. |
The migo
object will expose the multiple methods available in the SDK.
๐งฉ The schema object
The schema object serves a crucial purpose in the SDK by dynamically validating payload information sent by the client. It is custom-tailored to each client, providing a unique framework for organizing and structuring data. By printing it to the console, you can gain valuable insight into how the SDK handles and enforces data validations, making it an indispensable tool for developers.
// print out the schema
console.log(JSON.stringify(migo.schema));
The structure of the config comes in an array, because you can have multiple clients or different branches. So the basic structure is this:
[
{
clients: [ { key: 'migoTest', name: 'Migo Test' }]
processors: [
{
processor: 'processor1', // This is the key to send in some payloads
processorName: 'Processor 1', // Friendly name of the processor,
cards: true, // Flag to know if you can save cards
installments: [1,2,3...], // How many installments it can handle,
inputsMakePayment: [ // Super important part, to know how to create a payload to send when making a payment
{
//.....
},
{
//.....
},
],
...
}
]
},
{
//...
}
]
BUT in most cases, you will have just one client. So the array will come with one object. Please always make sure to print the migo.schema to check that you have assigned your client and the processor keys. If not please contact migo support to validate your credentials.
Tips for Implementing the SDK in Your Frontend
Data Validation: It's important to validate the data being inputted. Specifically, the
amount
field should not accept text.- Suggestion: Consider disabling the 'create transaction' button or turning it gray when the mandatory fields are not populated.
Input Validation: Inputs should be validated based on the type of data they are expected to contain, such as text or numbers.
Security Enhancement: For security purposes, do not use
console.log
specially in data like the merchant'scredentials
andprivateKey
.Handling customKeys: When sending
customKeys
, if there's no error or feedback displayed, it can be confusing for the user.Field Validation: There should be validation checks on input fields based on the required data type.
Handling Non-Existent Tokenized Card Transactions: If a search for a tokenized card transaction yields no results, a message indicating that no transaction was found should be displayed.
๐ More information
9 months ago
9 months ago
9 months ago
10 months ago
1 year ago
10 months ago
1 year ago
10 months ago
12 months ago
10 months ago
1 year ago
10 months ago
12 months ago
10 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
1 year ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
1 year ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
9 months ago
1 year ago
9 months ago
1 year ago
9 months ago
1 year ago
9 months ago
1 year ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago