.NET Standard Service and Wrapper for the Paygate Payment Gateway.
Please support us by providing PayGate with our DeveloperId: DEVF57C1B4
You can use this link paypal.me/nanotechcomputers if you want to donate via Paypal.
Install the NuGet package
Install-Package IPaygateServiceNext, you will need to provide IPaygateService with your URL, MerchantId and MerchantSecret key in code, build the request model and create the transaction on PayGate.
####Console Application:
In Program.cs, call:
const string url = "https://secure.paygate.co.za/payhost/process.trans";
const string merchantId = "10011064270";
const string merchantSecret = "test";
var paygate = new PaygateService(url, merchantId, merchantSecret);
var data = new CreateTransactionModel{
...
};
var response = paygate.CreateTransaction(data);
//TODO: Process the response received from PayGatePlease see example console application for more info/options
####.net core MVC Web Application:
In Startup.cs, call:
services.AddPaygate(options =>
{
options.MerchantId = "10011064270";
options.MerchantSecret = "test";
options.Url = "https://secure.paygate.co.za/payhost/process.trans";
});In your Controller's Constructor, use dependency injection to access the PaygateService
private IPaygateService _paygateService;
public HomeController(IPaygateService paygateService)
{
_paygateService = paygateService;
}In your controller method, call:
var data = new CreateTransactionModel{
...
};
var response = _paygateService.CreateTransaction(data);
//TODO: Process the response received from PayGateIf you used 3D secure then in your controller's redirect return method, call:
var dict = Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString());
dict.TryGetValue("PAY_REQUEST_ID", out var paygateRequestId);
var queryResponse = _paygateService.QueryTransaction(paygateRequestId); //Paygate does not return userdefinedfields on 3d secure redirects.
var validChecksum = _paygateService.VerifyTransaction(dict, queryResponse.Reference); //the reference should ideally be stored locally for the verification but for this example we will use what is returned from Paygate
Debug.WriteLine(validChecksum ? "Checksum Matches" : "Checksum does not match, possible tampering");
//TODO: Process the queryResponse received from PayGatePlease see example .net core Web Application for more info/options