cmpayments/payments-sdk-net is a nuget package to use CM Payment's services in a .net Framework or .net Core library.
Currently the following payment methods are supported:
- Afterpay
- Bancontact
- Credit Card (VISA/MasterCard)
- iDEAL
- iDEAL QR
- PayPal
- SOFORT
- WireTransfer
- Direct debit
For installation, reference the NuGet package in your project.
PM> Install-Package CM.Payments.SDK
After installation, it is a simple creation of the client before using it.
using CM.Payments.Client;
public class Program
{
private string _consumerKey = "your_payments_key";
private string _consumerSecret = "your_payments_secret";
private PaymentClient _client;
public Program()
{
_client = new PaymentClient(_consumerKey, _consumerSecret);
}
}
As it is bad practice to use credentials in a hard-code manner, move the credentials to a configuration file or database. For example in a Web.config file.
<appSettings>
<add key="PaymentClient.Consumer.Key" value="your_payments_key" />
<add key="PaymentClient.Consumer.Secret" value="your_payments_secret" />
</appSettings>
And read from the file before using it in your project.
using CM.Payments.Client;
using System.Configuration;
public class Program
{
private string _consumerKey;
private string _consumerSecret;
private PaymentClient _client;
public Program()
{
_consumerKey = ConfigurationManager.AppSettings["PaymentClient.Consumer.Key"];
_consumerSecret = ConfigurationManager.AppSettings["PaymentClient.Consumer.Secret"];
_client = new PaymentClient(_consumerKey, _consumerSecret);
}
}
The \Sample-folder contains a simple example MVC webshop implementing the CM Payments SDK. Open \Sample\CM.Payments.SDK.Sample.sln in Visual Studio, restore the missing NuGet packages and run the application to see it in action. The payment methods will show a demo account using simulated money transfers.
Bugs and feature request are tracked on GitHub
The cmpayment/payments-sdk-net library is copyright (C) CM Payments and licensed for use under the MIT License (MIT). Please see LICENSE for more information.