A .NET standard library to integrate with Eway's Rapid Payment API.
Sign up with Eway at:
- Australia: https://www.eway.com.au/
- New Zealand: https://eway.io/nz/
- Hong Kong: https://eway.io/hk/
- Malaysia: https://eway.io/my/
- Singapore: https://eway.io/sg/
For testing, get a free Eway Partner account: https://www.eway.com.au/developers
Rapid's .NET Standard implementation is broken down into three packages:
- Eway.Rapid.Standard.Extensions.DependencyInjection
- Eway.Rapid.Standard
- Eway.Rapid.Standard.Abstractions
This package should be used when the host application is using the ASP.NET CORE framework.
It provides dependency injection for the RapidClient
, and inherts functionality from the Eway.Rapid.Standard package.
This package should be used when the host application is not using the ASP.NET CORE framework, or a custom DI framework is preferred (or DI is not used in the application). It provides a implementation for the HTTP Client, and handles API calls on your behalf. The package inherits functionality from the Eway.Rapid.Standard.Abstractions package.
This package should be used when you want full control of the Http Client, and API calls; but would like to use the pre-defined interface and protocol. The package contains data contracts, models, and Rapid endpoints. Here you may create your own custom HTTP client, and handle API calls in a custom manner.
Use one of the following command to install relevant package:
PM> Install-Package Eway.Rapid.Extensions.Standard.DependencyInjection
OR
PM> Install-Package Eway.Rapid.Standard
.NET CLI Console:
> dotnet add package Eway.Rapid.Extensions.Standard.DependencyInjection
OR
> dotnet add package Eway.Rapid.Standard
See Eway's Rapid API Reference for more details.
Sample app settings entry for RapidClient's
configuration.
Required nuget package: Eway.Rapid.Standard.Extensions.DependencyInjection.
{
"RapidClient":
{
"RapidEndPoint": "Sandbox",
"ApiKey": "Rapid API Key",
"Password": "Rapid API Password"
}
}
Invoke the dedicated extension method for RapidClient
in your app's configuration section.
public void ConfigureServices(IServiceCollection services)
{
services.AddRapidClient();
}
You're now able to inject IRapidClient
into services as required.
public class HomeController : Controller
{
IRapidClient rapidClient { get; set; }
public HomeController(IRapidClient rapidClient)
{
this.rapidClient = rapidClient;
}
}
Sample configuration when not using ASP.NET CORE's default dependency injector.
Can be used with any other DI framework, or even without one.
Required nuget package: Eway.Rapid.Standard package.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Eway.Rapid;
using Eway.Rapid.Abstractions.Interfaces;
using Eway.Rapid.Abstractions.Models;
using Eway.Rapid.Abstractions.Request;
namespace ConsoleApp1
{
class Program
{
static async Task Main(string[] args)
{
HttpClient httpClient = new HttpClient();
RapidOptions rapidOptions = new RapidOptions
{
ApiKey = "Rapid API KEY",
Password = "Rapid API Password",
RapidEndPoint = RapidEndpoints.SANDBOX
};
rapidOptions.ConfigureHttpClient(httpClient);
IRapidClient rapidClient = new RapidClient(httpClient);
}
}
}
Once you have configured the RapidClient
using either the provided DI extension method, or via configuration; we can use the client as follows.
Required nuget package, either: Eway.Rapid.Standard.Extensions.DependencyInjection, or: Eway.Rapid.Standard package.
public void DirectPayment()
{
// Create a direct connection request.
DirectPaymentRequest transaction = new DirectPaymentRequest()
{
Customer = new DirectTokenCustomer()
{
CardDetails = new CardDetails()
{
Name = "John Smith",
Number = "4444333322221111",
ExpiryMonth = "12",
ExpiryYear = "22",
CVN = "123"
}
},
Payment = new Payment()
{
TotalAmount = 1000
},
TransactionType = TransactionTypes.Purchase
};
// Use the RapidClient to process the request.
var response = await rapidClient.CreateTransaction(transaction);
// View the result of the direct connection response.
Console.WriteLine(response.ResponseCode);
Console.WriteLine(response.ResponseMessage);
Console.WriteLine(response.TransactionID);
Console.ReadLine();
}
Please see CHANGELOG for more information what has changed recently.
The MIT License (MIT). Please see License File for more information.