If your service is developed in .NET, the features we provide are available through the SDK. The Gluwa SDK for .NET is a library with powerful features that enable .NET developers to easily make requests to the Gluwa APIs.
Please note that the sandbox environment is deprecated and will be replaced with an alternative solution in the future.
At the moment, our .NET SDK only supports Gluwacoin transfers. For Bitcoin transfers, please use the REST API.
Getting Started
The namespace of Gluwa SDK is Gluwa.SDK_dotnet. The SDK requires .NET Core 2.1 or above.
Refer to the Microsoft documentation below to learn how to install Nuget packages.
Clients
To use Gluwa API, you need to create a Client object and initialize it. There are two types of Clients:
GluwaClient for managing funds by creating or retrieving transaction
QRCodeClient for creating QR codes.
Type
Description
bool
false by default. If you want to use the SandBox mode, set true
GluwaClient
GluwaClient gluwaClient = new GluwaClient();
// If you want to use the SandBox mode
GluwaClient gluwaClient = new GluwaClient(true);
QRCodeClient
QRCodeClient qrCodeClient = new QRCodeClient();
// If you want to use the SandBox mode
QRCodeClient qrCodeClient = new QRCodeClient(true);
ECurrency currency = "{USDG or KRWG or NGNG or BTC}";
string address = "{Your Gluwacoin public Address}";
string privateKey = "{Your Gluwacoin Private Key}";
string amount = "{Transaction amount, not including the fee}";
string target = "{The address that the transaction will be sent to}";
string merchantOrderID = "{Identifier for the transaction that was provided by the merchant user}"; // default to null. Optional
string note = "{Additional information about the transaction that a user can provide}"; // default to null. Optional
string nonce = "{Nonce for the transaction. For Gluwacoin currencies only}"; // default to null. Optional
string idem = "{Idempotent key for the transaction to prevent duplicate transactions}"; // default to null. Optional
string paymentID = "{ID for the QR code payment}"; // default to null. Optional
string paymentSig = "{Signature of the QR code payment. Required if PaymentID is not null}"; // default to null. Optional
Result<bool, ErrorResponse> result = await gluwaClient.CreateTransactionAsync(
currency,
address,
privateKey,
amount,
target,
merchantOrderID, // optional, default = null
note, // optional, default = null
nonce, // optional, default = null
idem, // optional, default = null
paymentID, // optional, default = null
paymentSig // optional, default = null
);
if (result.IsFailure)
{
switch (result.Error.Code)
{
case "ErrorCode1":
// handle error 1
break;
case "ErrorCode2":
// handle error 2
break;
default:
// handle error
break;
}
}
else
{
// successful response. See result.Data for the response
}
Returns true if successful and false if unsuccessful. Successful response means that the transaction has been accepted by Gluwa and will be included in the blockchain in a couple of minutes.
string apiKey = "{Your API Key}";
string secret = "{Your API Secret}";
string address = "{Your public address}";
string privateKey = "{Your private Key}";
EPaymentCurrency currency = "{USDG or KRWG or NGNG}";
string amount = "{Payment amount}";
string format = "{Desired image format}"; // defaults to null. Returns base64 string. Optional.
// if you want to receive an image file put ‘image/jpeg’ or ‘image/png’ instead.
string note = "{Additional information, used by the merchant user}"; // default to null. Optional
string merchantOrderID = "{Identifier for the payment, used by the merchant user}"; // default to null. Optional
int expiry = "{Time of expiry for the QR code in seconds}"; // default to 1800. Optional”
Result<string, ErrorResponse> result = await qRCodeClient.GetPaymentQRCodeAsync(
apiKey,
secret,
address,
privateKey,
currency,
amount,
format, //optional, default = null
note, //optional, default = null
merchantOrderID, //optional, default = null
expiry //optional, default = 1800
);
if (result.IsFailure)
{
switch (result.Error.Code)
{
case "ErrorCode1":
// handle error 1
break;
case "ErrorCode2":
// handle error 2
break;
default:
// handle error
break;
}
}
else
{
// successful response. See result.Data for the response
}
Webhook Validation
A method for validating if the webhook is from Gluwa or not. Gluwa sends a webhook request when a transaction is created or completed. Learn more about webhooks from Gluwa here.
PayLoad payLoad = new PayLoad()
{
Data = new Data
{
MerchantOrderID = "My merchant order ID",
EventType = EEventType.TransactionConfirmed,
Type = ENotificationType.Webhook,
ResourceID = "0xfd820a7e9d9851537e259289269db88826a561a04e1c6982b4d860c797a625ce"
}
};
string signature = "{The value of X-REQUEST-SIGNATURE header}";
string webhookSecretKey = "{Your Webhook Secret}";
bool bValidated = Webhook.ValidateWebhook(
payLoad,
signature,
webhookSecretKey); // true if validation was successful