Integration Steps
Integrate your .NET-based website with our SDK to start accepting payments using the Nimbbl Payment Partner.
Project Structure
This integration uses a NuGet package based SDK. If you are not using NuGet, download the latest version of the SDK from GitHub and add the required DLL in your project reference.
Before you proceed:
- Get the Access Key and Access Secret from the Command Center → Developer Settings → Credentials.
- Know about the Payment Flow and follow these integration steps:
Integration Overview
| Step | Description |
|---|---|
| 1. Build Integration | Integrate with your .NET-based website |
| 2. Test Integration | Test the integration by making a test payment |
| 3. Go-live Checklist | Check the go-live checklist |
1. Build Integration
1.1 Install the SDK
Install the Nimbbl .NET SDK via NuGet:
- .NET CLI
- Package Manager Console
dotnet add package Nimbbl.Sdk.Rest --version 1.3.5
Install-Package Nimbbl.Sdk.Rest -Version 1.3.5
You can find all versions on NuGet: Nimbbl.Sdk.Rest.
1.2 Configure the SDK
Create a .env file in your project root for local development:
cp env.example .env
Required Environment Variables
| Variable | Description |
|---|---|
NIMBBL_ACCESS_KEY | Your Access Key from Command Center |
NIMBBL_ACCESS_SECRET | Your Access Secret from Command Center |
NIMBBL_ACCESS_KEY=your_access_key_here
NIMBBL_ACCESS_SECRET=your_access_secret_here
Optional Environment Variables
| Variable | Description | Default |
|---|---|---|
NIMBBL_API_HOST | API host URL (do NOT include /api) | https://api.nimbbl.tech |
NIMBBL_ENABLE_LOGGING | Enable SDK logging | false |
NIMBBL_DEBUG_LOGGING | Enable debug-level logs | false |
NIMBBL_LOG_FILE | Path to log file | - |
ENCRYPT_PAYLOAD | Encrypt outgoing request payloads (see supported APIs below) | false |
When ENCRYPT_PAYLOAD=true, the SDK encrypts request payloads for the following APIs:
- Create Order (
/api/v3/orders) - Initiate Refund (
/api/v3/refund) - Transaction Enquiry (
/api/v3/transaction-enquiry) - List Banks (
/api/v3/list-banks) - List Wallets (
/api/v3/list-wallets)
For responses, the SDK auto-detects encrypted_response and decrypts it automatically.
For more details on encryption/decryption logic, see Using Encrypted Payloads.
#NIMBBL_API_HOST=https://api.nimbbl.tech
NIMBBL_ENABLE_LOGGING=true
NIMBBL_DEBUG_LOGGING=false
#NIMBBL_LOG_FILE=logs/nimbbl_debug.log
ENCRYPT_PAYLOAD=false
1.3 Register the SDK (Dependency Injection)
In your Program.cs or Startup.cs, register the SDK with ASP.NET Core's dependency injection:
using Nimbbl.Sdk.Rest.Extensions;
builder.Services.AddNimbbl(
accessKey: Environment.GetEnvironmentVariable("NIMBBL_ACCESS_KEY")!,
accessSecret: Environment.GetEnvironmentVariable("NIMBBL_ACCESS_SECRET")!
);
1.4 Create an Order in Server
Order is an important step in the payment process.
- An order should be created for every payment.
- You can create an order using the Nimbbl .NET SDK or by directly calling the Create an Order API. It is a server-side API call.
- The
tokenreceived in the response should be passed to checkout. This ties the Order with the payment and secures the request from being tampered.
The SDK simplifies order creation by handling authentication, request signing, and error handling automatically. The sample code below demonstrates creating an order using the SDK.
1.4.1 Sample Code
using Nimbbl.Sdk.Rest.Api;
using System.Text.Json;
public class OrdersController : Controller
{
private readonly NimbblApi _api;
public OrdersController(NimbblApi api) => _api = api;
public async Task<IActionResult> CreateOrder()
{
// Create order - SDK handles authentication automatically
var order = await _api.Orders().CreateOrderAsync(new Dictionary<string, object?>
{
["invoice_id"] = $"INV-{Guid.NewGuid():N}",
["total_amount"] = 100.0,
["currency"] = "INR"
});
// Extract order token (used to launch checkout)
var orderToken = order.TryGetProperty("token", out var ot) && ot.ValueKind == JsonValueKind.String
? ot.GetString()
: null;
if (string.IsNullOrWhiteSpace(orderToken))
return BadRequest("Order token not returned from create order.");
return Ok(new
{
order_id = order.TryGetProperty("order_id", out var oid) ? oid.ToString() : null,
token = orderToken,
raw = order
});
}
}
1.4.2 Request Parameters
{
"invoice_id": "inv_asjjeibdhakk49hnek3",
"total_amount": 2205.00,
"currency": "INR",
"amount_before_tax": 2100.00,
"tax": 105.00,
"user": {
"email": "[email protected]",
"first_name": "Diana",
"last_name": "Prince",
"country_code": "+91",
"mobile_number": "9876543210"
},
"shipping_address": {
"address_1": "1080 Beach Mansion",
"street": "Magic Beach Drive",
"landmark": "Opposite Magic Mountain",
"area": "Elyria",
"city": "Atlantis",
"state": "Castalia",
"pincode": "100389",
"address_type": "Home"
},
"billing_address": {
"address_1": "1080 Beach Office",
"street": "Magic Beach Drive",
"landmark": "Opposite Magic Mountain",
"area": "Elyria",
"city": "Atlantis",
"state": "Castalia",
"pincode": "100320",
"address_type": "Other",
"label": "Sunny Office"
},
"order_line_items": [
{
"sku_id": "item_2783027490",
"title": "Best Sliced Alphonso Mango",
"description": "The Alphonso mango is a seasonal fruit harvested from mid-April through the end of June.",
"image_url": "https://en.wikipedia.org/wiki/Alphonso_mango#/media/File:Alphonso_mango.jpg",
"rate": 1050,
"quantity": 2,
"amount_before_tax": 2100.00,
"tax": 105.00,
"total_amount": 2205.00
}
]
}
For complete request parameters, see Create an Order API.
1.4.3 Response Parameters
A successful order creation returns the following fields:
- Plain Response
- Encrypted Response
{
"order_id": "o_9yo5wxlLlbJGK6dp",
"order_date": "2021-04-15 04:34:15.990152",
"status": "new",
"invoice_id": "inv_asjjeibdhakk49hnek3",
"attempts": 0,
"currency": "INR",
"amount_before_tax": 2100,
"tax": 105,
"total_amount": 2205,
"user": {
"email": "[email protected]",
"first_name": "Diana",
"last_name": "Prince",
"country_code": "+91",
"mobile_number": 9876543210,
"user_id": "user_78hsjkdhb2482ndk"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJzdWJfbWVyY2hhbnRfaWQiOjMsImV4cCI6MTcwNzg5ODk1OSwidHlwZSI6Im1lcmNoYW50IiwiaWF0IjoxNzA3ODk3NzU5LCJpc3MiOiJ1cm46bmltYmJsIiwidG9rZW5fdHlwZSI6InRyYW5zYWN0aW9uIn0.YLpLWonfBIlB8FFBEXQcLt_JA6ymnN0zXANR1J_Bg2M",
"token_expiration": "2021-01-09T09:49:57.715413",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJzdWJfbWVyY2hhbnRfaWQiOjMsImV4cCI6MTcwNzg5ODk1OSwidHlwZSI6Im1lcmNoYW50IiwiaWF0IjoxNzA3ODk3NzU5LCJpc3MiOiJ1cm46bmltYmJsIiwidG9rZW5fdHlwZSI6InRyYW5zYWN0aW9uIn0.YLpLWonfBIlB8FFBEXQcLt_JA6ymnN0zXANR1J_Bg2M",
"refresh_token_expiration": "2021-01-09T09:49:57.715413",
"next": [
{
"action": "payment_modes",
"url": "/api/v3/payment-modes"
},
{
"action": "update_order",
"url": "/api/v3/update-order"
},
{
"action": "resolve_user",
"url": "/api/v3/resolve-user"
}
]
}
{
"encrypted_response": "3164351ca6195e9871cca9de3117cb8f1e3cd01c984796dc79a252206cd4532994a6dd1dfcd1f3aac92ad834a49b2f1823b7092535bc6f92401223e2598b31781646339ecdd5d1f219bed267f69c5ef8c26f78fc6ef7fa2c47023f15a6343f75c7944ce1f8f26710effbbfda30fdc7385c1cd405fdbd1609d95411782fb6a62caf0104f0575ba4b68c7edb244bf60116b914e614f9c482c04172efcf0262cf7e547c25d7281d57513f76ce64069218a3a00894ee2c2be05286cfae5c0df94bb0550dfa66b743dd98885e2ae956ae93b159d6996cd3ef478480a2235e2f125ae58062bea75acdac580489a25236491a7027d1df1e38be092f49c07d402707d1b6375f0cc9a4f3e9c795912a3389d6ee45414c2ed34d0e61cc4667b6c50bc1e538b9a55e69ff1f90fd003040c54b70abc477cfa91f4f24c3503a1491b1b9076c5cbd8be47ab52e520b3c352e597f03568f61c36b475659081331371ce7b5e997fa916aee7c98969ee7e62453e44481170c723f1676ecc5bbc34ccccfc2ac4e5f111af3b09a5edaed242f3d11878dfa534c25841e4671c421d960ddec24b992b359c6b340073fb7961da47a39c10e01f51833852d13e4b5b2f0282277d6b3d165f4005778d92fff458a53aa48d5de948bf42ea7619277581a9cb921e43377ab5a1ac576fe0166652de79b4c4c05135926f6c96f86c2dcf28ebde91977b6cebc9a02c00dd15118f9bf47a63a355500f5303be025d3b12342a262115c105ae24f548a4cc25d879fdbb879f006cfd5f26a03ac38f3e820641124ce92864a669d1c0f24a80fb179c2c76404f6e4b5848a565f9219d9451e8a37e588cbc0502df49af523354631eaec855b79694d128d4624602b5755918a9debc46dc53fee1de166ad9fc70d6657ed969a0e56778f819da93f8286e92ed91671b2e1cd7ab7bc2065a8eec49556371d7b3df83a5246d4a45e9703730fe5a2df8bb2b0f4820bf9be5ed691acf2a0e10e842a74852c75a0cedf932a0b0c8e4ba813e02bdb1d54f1865618b4cfd4c0d9193a95c120b99fd0558bb26c258ca5ea2f58ed176e48e504dd9e9c121f67f132180f62552d0a24d3649d212c1a5ac87d44db9f94d01acfa21033d0ed4149e2a8a2ab32f401b7aaefd1f171c964f0616d556fdff82496f4cba1e552560da1e54b40afebc90b037847184c8817678af5fdbb229110b6124a0035f3f1902ff4f85c8a3c4710e674de1940758cf38727d7d7b80aa47f2fa1b5c1f7221a313a9e4d382529e27f26ef26837dcc0c3f5652988f94aa818526d79ab6192ef647db6edb878e3867445ac2381d7468ed523b87f0391f10011882435716a5c5d3c0fde6ecfbe2c0365696d8a529a09ee0954775a3c7e7f1945abc60ba05ab6537db9cdc42ae52fe0a82c05b39be924fa34b656f02c17d8f2cea7bf76d33982ba2dd3286a8cc019902b90861e9604571d6ff73a61e5e1ded40e80ff9df40a923b7cd338ec8fa0dd1a6fe7fe3991694f02379aa8e0cb523f9395946593a3c63ea0151d7ee973cfc34bcc74ea472e3ff5db678b9e3c668551ee6ea241a38666f77e520f9668863477be9699b3accaa940d1ef5ec8d206101677a1b402aa72a054245b271107f077a07d5fff171454cd3954530a0d580d69f046ac8a2ff192df8d1b6823a08012c4bd19ec52b04aeb4348c7e50eae63d36c4978a9b23ae347007502afae55394f3bceaada92398b50a95ee14a9ee13fae3b91612de40f58aa38ef4c4285833793f56d8c7e379064cbf51c0ff2ae3e90af7bd887b4d9ec488d32a8fb444c6bfa78dbc0a18467ee29c94b322367a1c70d4f23be905a8d122e16c278ab631c2cb7456e73966d71d797c3e41376a48bc0e4803ec8fb56bfae126ce5559c8e085830adab0f266ca0dcf25c2a8be9f863e5e51b735cd38e107cfdaa4a961bf1b1f4f0870372fa2a82ca0c52a3104266cdca32a77882aa11d0c77309e66671d7600951fa87c510f8643123d73cfb738f8ee5b35364921aa21c40d90cef96d4426d2d1ba7964f34282af6f51ba682ea10e4ff69f7c3e736531ebe8665ffed316f8d42d5536b3982e3261fa75b8426ab8965959a0e0ba14ceb95b9f32300888979d3c82aa7dda23fad7fa3d1108f1efa1c6f69876af973d92863b5f8e52359e52e329e105eb332906d95f8358a115772dd58d367bcfab9437544d535a60aba726aacd780c6f8c46b4e570a27ddab8118d9c1220d24163a9738b93189da7a1fb01147d80b21c0834b0b892ac68f3f6db1946c97b9e8d5734cfc1477f87dea1a1650a47904ef3658c42da4c0e1f4a1431d8a903145619dd373fb9fd301f2afb87bd941b601e550d6c295d9ef31ea53c2d1ed9eba488627bf19f24ae3d77b4272e040f867662d8bda6402750aae9b3a113160705482399ea3a402e3e50930ed05dfa9b3d13649ae3a0525ff035b739b14a50e12d77abac1585dd9bf1eb44fded8672609ccf10e8ffcc4c38b9df0f3660a81d498f25e04d095b8f95d40fa6b9da582e7a6ac429e34d3cab509ef6b62f08d49eb9f42a2b2d0a806536a348d0460ed0a3593f85ca6c436efa1c0753cd0c1037034664e07470c5ec5d98704f33827db4c37865d0a4c49e5900bc899dbd972da764a573b2c8531687d8beccdf33c7d9a358fa85b5ac405f621545b48fa62c83fcf0bd3e914ed6ac9427d5093dc621538aa3aae9e5dea7ab105bbd901de4d3de1935776b7f45e280b5a4ea14be31f037b513902d0c47ef02279611390037c00807d3fc6b5477aa5018de21a4514744f9cb9f366e2c9d639a4d6e446d16732044b3175476e90735a11196cebb86c4156197ecd018f837caa03f1f0ffda19d4c5850788770b61a9af3877d0a2130fca437621c32b6f2e428769371c5da14d1d3ae425679e6bda08c9c3df7246e955daf71f2c47927949d71ee5b7d884b334218e35122e2ed1f5108b08fdd45eb9434cc776f6cd4f50cc3f4d5af662feb6769a944f0df0ed282e1a5f1cbc53d22a419080439e21058092ff5591f70648890826eb0c68c80342b2563204eaa733bafb889bc346d273e3a1d1a4fd2ca03773ba15b9897c442e08f3c1db6188f19f0060605707a3b807430613793eb8806264c882e3ecca76bb978328327ca55b49dede37c173f5ff9e4594f1ea041eead4677da7087347d1d42431b74b00273252780833f9fa3ace8c28786e0ad0887c5fdc42257545405a4cbd4fbf0a24c6fa2ef3e2bab34d061a4417a17bfbf91d58b4e741ffe33032ed2fcad8f5a2b6142ad993f202f072947801ec6790dee924c86d64911bbb011e908ea930f5066c28c982cf931fb6fddcc07fef2088c2f41a48c19f84945fb20c2351db12874824aecc97affa41fc59ec75822cbacaef85f24faf959f61bad8a2af014b69f8b7ff8aa13510088add31d2784fe8f90e97af94d29d252aef5e3ef5663acdae23bc4558fd3e9e43b5810b8e037d9208f5be18a27dc28ffad08fb28501c2196c530193311429bb804f9cbdd7971e255dc1732e285c29373d5326b1548c3d274b9073a6e0160035f7c93723f7353d60b98ae140f00c97f701bb822728a412bfdd48160d552b23fb7b5e253096812b434b4819f88948d0c0d5e17b497e8b3b5993cebe53822a6fe7413c40070ea05a0b6d469e18b5922afa304e85255a109ce5ad79077e374a3b93aa9e3051bc9abaefb6fe558b7420cc5165a21e7681a33ff6ebff9666853a83cdd970a79984d3cedc7300b17db398790592b57156de4944b325c7d422d265ebb39f52b5c4a1e2f706b0a3509bf907b9739a9be52049d37de678550386d1af83df896f31dbdee78426168b6696b354c34ae9d4eff314069723be410dd0df6dd43a547a1b7829710773e344fe9525c9722bf790250448a47de6d974e40d2756007f39963596f51c8841d1185f9106d3bc748d723655dbf59b71c872e6e93d049f869d1a07c1b42328463c6fc106523b5c142f6b7deda8bf4600b7cb1462ebbcd1c28ef2d342ae279f61585a29ffdbda051fda444335dac496ab8b05654cd84"
}
Once you decrypt the encrypted_response key, you will get the unencrypted response shown in the Plain Response tab.
To learn more about encryption/decryption, please refer to Using Encrypted Payloads.
1.5 Add Checkout Options
The sample app launches checkout via nimbbl_sonic using the order token returned by the Create Order API.
1.5.1 Callback Handler or Callback URL
You can handle payment responses in two ways:
- Popup (Handler Function)
- Redirect (Callback URL)
<script type="module">
import Checkout from "https://cdn.jsdelivr.net/npm/nimbbl_sonic@latest";
// token: order token returned from create order API response
const checkout = new Checkout({ token: "<ORDER_TOKEN>" });
const options = {
callback_handler: async function (response) {
// Send raw callback + (optional) encrypted_response to backend for verification/decryption
const encryptedResponse = response?.payload?.encrypted_response;
const res = await fetch("/payment-callback", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
encrypted_response: encryptedResponse || null,
callback: response
})
});
const data = await res.json();
console.log("Parsed response:", data.parsed);
}
};
checkout.open(options);
</script>
<script type="module">
import Checkout from "https://cdn.jsdelivr.net/npm/nimbbl_sonic@latest";
// token: order token returned from create order API response
const checkout = new Checkout({ token: "<ORDER_TOKEN>" });
// Redirect flow: provide callback_url (backend handles GET /payment-callback)
const options = {
callback_url: "https://merchant.example.com/payment-callback"
};
checkout.open(options);
</script>
- Replace
<ORDER_TOKEN>with the actual token received from your Create Order API. - For Payment Mode options (
payment_mode_code,bank_code,wallet_code, UPI/EMI fields, etc.), refer to Web Integration → Properties related to Payment Mode.
1.5.2 Checkout Options
| Parameter | Required | Type | Description |
|---|---|---|---|
token | Yes | string | Order token returned from Create Order API |
callback_handler | Conditional | function | Handler function for popup mode (required if not using callback_url) |
callback_url | Conditional | string | Redirect URL for redirect mode (required if not using callback_handler) |
1.6 Handle Payment Callback
After a payment is completed, Nimbbl sends the payment response to your callback endpoint. You can configure your own callback URL based on your application's routing.
| Mode | HTTP Method | Description |
|---|---|---|
| Redirect | GET | Response sent as response query parameter to your callback_url |
| Popup | POST | Response sent in request body to your callback_handler |
1.7 Verify Payment Signature
This is a mandatory step to confirm the authenticity of the details returned for successful payments.
The SDK provides utility methods for signature verification. In the sample app, the callback controller:
- Parses the callback payload
- Auto-detects encrypted payloads via
encrypted_response - Decrypts (when applicable) and verifies signature
- Returns a normalized JSON response
See the sample app's Controllers/HomeController.cs for the full implementation.
For detailed information on signature validation logic and implementation, see Validating Payment Response with Signature.
1.8 Handle Webhooks
Configure webhooks to receive real-time payment notifications on your server. Email us at [email protected] or contact your dedicated account manager.
Your webhook endpoint should handle POST requests and:
- Parse the incoming webhook payload
- Auto-detect encrypted webhooks via
encrypted_response - Decrypt (when applicable) and verify signature
Enable webhook logging via environment variables:
NIMBBL_ENABLE_LOGGING=true
NIMBBL_DEBUG_LOGGING=false
Webhooks are the primary and most efficient method for event notifications. They are delivered asynchronously in near real-time. For critical user-facing flows that need instant confirmation, supplement webhooks with API verification.
Recommended approach:
- Rely on webhooks for all automation, which can be asynchronous.
- If a critical user-facing flow requires instant status, perform an immediate API call to verify the status using Transaction Enquiry API.
2. Test Integration
After the integration is complete, a Pay button appears on your webpage/app.
Quick Start with Sample App
Use the official sample app as a reference implementation:
git clone https://github.com/nimbbl-tech/nimbbl-dotnet-sampleapp.git
cd nimbbl-dotnet-sampleapp
cp env.example .env
# Edit .env with your Access Key and Access Secret
dotnet restore
dotnet run
The app runs on http://localhost:5001 (or the port in Properties/launchSettings.json).
Click the Pay button and make a test transaction to ensure the integration is working as expected.
- Ensure you have entered your Test Mode credentials in the
.envfile. - No real money is deducted when using test credentials. This is a simulated transaction.
3. Go-live Checklist
Consider these steps before taking the integration live.
3.1 Accept Live Payments
Perform an end-to-end simulation of funds flow in Test Mode. Once confident that the integration is working as expected, switch to Live Mode and start accepting payments from customers.
Ensure you are switching your test credentials with credentials generated in Live Mode.
To switch to Live Mode:
- Log in to the Command Center and switch to Live Mode.
- Navigate to Developer Settings → Credentials to get Live Mode Access Key and Access Secret.
- Replace the Test credentials with Live credentials in your
.envfile. - Start accepting actual payments.
3.2 Set Up Webhooks
For webhook configuration and best practices, see Webhooks and Transaction Enquiry.
Sample App & SDK Links
| Resource | Link |
|---|---|
| SDK (NuGet) | Nimbbl.Sdk.Rest |
| SDK (GitHub) | nimbbl-tech/nimbbl-dotnet-sdk |
| Sample App | nimbbl-tech/nimbbl-dotnet-sampleapp |
| API Reference | API Reference Introduction |