Overview
When we think about online payment, we automatically assume that we can only use our bank accounts or credit cards. But now CryptoCurrency is trending. People can use their cryptocurrency amount for purchases or payments online. Now you will have a question about how cryptocurrency can be used as your real money?
So let me give you some brief ideas about the Maldo payment gateway. By using maldo pay you can deposit cryptocurrencies. Maldo Pay provides more than 50 plus payment methods Crypto Currency Deposit is one of them. Here we have used the Maldo pay payment gateway in one of our projects.
Get Integration Credentials From Maldo Pay
To start integration first we need
- EncryptingKey
- APIKey
- AuthorizationKey
- ClientId
- BrandId
- ServiceId
- IntegrationId
This is the required thing to start integration, that all are provided by Maldo pay to the owner.
Users Authentication
The payment integration process starts with first authenticating the user with the required details.
Once you have sent details in you will get to what is required in Payment initiate Request API.
Query Type: POST
Headers: Content-Type:application/x-www-form-urlencoded
Post Key: Json
Post value:
In response you will get token
Once you get a token you have to use it in a payment initiate request.
Payment Initiate Request
Query Type: POST
Headers: Content-Type:application/x-www-form-urlencoded
Post Key: Json
Post value:
Also, you have to pass an API key which you will get from the Payment gateway.
After that, you have to create a checksum of this JSON post value object.
Steps To Do:
- Serialize the string and encrypt that with EncryptingKey you find in the owner’s profile.
- Pass key as checksum and value as that checksum result.
C# function to create checksum:
static string calcHmac(string data, string EncryptingKey) { byte[] key = Encoding.ASCII.GetBytes(EncryptingKey); HMACSHA256 myhmacsha256 = new HMACSHA256(key); byte[] byteArray = Encoding.ASCII.GetBytes(data); MemoryStream stream = new MemoryStream(byteArray); string result = myhmacsha256.ComputeHash(stream).Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s); return result; }
Once it will complete in response you will find the URL with some other data.
You will be redirected to that URL and the screen will look like this.
Step 1. Here you have to select one of their cryptocurrencies and you get a QR code to deposit with scanning there that QR.you have to make payment with a valid application that supports cryptocurrency transactions.
Step 2. There is no minimum or maximum limit for the deposit amount.
Step 3. In case you fail to deposit within 30 min your token will be expired and you have to request again.
Step 4. When you complete the transaction you will see a screen like this.
Callback Process
You have to add a call-back URL in the integration part of maldo pay you will find up to 5 text boxes for call back URL.
Note: you have to add a Live API URL that accepts the post application/x-www-form-urlencoded content type.
After receiving a response you have to follow certain steps to validate that checksum to ensure the integrity of the data.
Steps:
- Assign the received ‘checksum’ in a new variable.
- Add (|) Sign after removing checksum and create a string.
- Again generate checksum with the created new string and with encrypting Key.
- Compare both checksums and if both are the same then update the status of the transaction in your database.
Check Transaction Status
Every payment gateway will provide you an API from which unique transaction id you can check the transaction status.
You can create a mechanism that gets all pending transaction details and checks and updates the transaction status accordingly.
Key Points
- Always whitelist all of your IPs from which you are going to call third-party APIs.
- Make sure you know in which format you have to send data and you will get a response.
- Always cross-check your issue with the support team of that payment gateway because sometimes the provided document can not be updated.
- Always make sure that you have matching the minimum and maximum limit of transactions.
- Call back process may affect your flow so make the redirect process accordingly.
- Must do an auto FAILED transaction after some amount of time and try to schedule the API so it can automatically do so after a fixed amount of time.
- Avoid Actual payment, try to do it manually, after all, your implementation is done then try with the actual transaction.
Conclusion
In this blog, we have covered some basic steps which are needed to integrate any payment gateway. However, there may be a chance of a different approach but in most cases, you will find the same.