NBluem is a .NET-library that enables usage of the Bluem payment provider.
using System;
using System.Security.Cryptography.X509Certificates;
using NBluem.Net;
using NBluem.Net.Request;
using NBluem.Net.Request.Factory;
using NBluem.Net.RequestTypes;
using NBluem.Net.Response;
using NBluem.Security;
using NBluem.Structure.Net.Response;
using NBluem.ValueObjects;
using NLog;
namespace NBluem
{
public class TestClass
{
public BluemTransactionResponse DoTest()
{
// Create certificate store that contains your Bluem certificate
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
// Create a logger
var logger = new LogFactory().GetCurrentClassLogger(typeof(TestClass));
// Create the signage object to sign your request to Bluem
var signage = new Signage(store, logger);
// Create a new request via the BluemRequestFactory, for instance a payment request
var paymentRequest = new BluemRequestFactory().CreateRequest(
new BluemPaymentRequestType()) as IBluePaymentRequest;
// Add some data to the payment request
paymentRequest.AddPaymentData(
new EntranceCode(), // A unique entrance code
"paymentReference", // Your unique payment-reference
"debtorReference", // A unique debtor-reference
"My description", // A short description
12.34, // The payment amount
DateTime.Today.AddDays(10)); // The due datetime for the payment request
// Create a new Bluem-client to handle the request
BluemClient client = new BluemClient(logger);
// Sign the actual request
var signedRequest = signage.SignRequest(paymentRequest);
// Send the signed request
var response = (BluemTransactionResponse) client.SendRequest(signedRequest);
// Return the actual response
return response;
}
}
}
All communication between your application and Bluem is encrypted via a certificate which can be obtained from Bluem.
Add the following NBluem configuration section to your web.config:
<configSections>
...
<section name="NBluem.BluemConfiguration" type="NBluem.Configuration.BluemConfiguration"/>
</configSections>
Configuration example:
<NBluem.BluemConfiguration
CertificateThumbprint="n533t2mguoq8mkneetdvch2x2dnjx37zullns738"
Fingerprint="E823B6A6AFC5B06E5F9C6B02936764BA80B3A1347948EE876E186A0232B643BF"
SenderId="S1234"
ReturnUrl="https://return.to.me"
PaymentRequestUri="https://test.viamijnbank.net/pr/createTransaction"
PaymentStatusUri="https://test.viamijnbank.net/pr/requestTransactionStatus"
BrandId="IDEAL"
SkinId="PayRequest"
Currency="EUR"
DumpReports="false"
HashSalt="BluemDefaultHashSalt"
HashLength="16"
></NBluem.BluemConfiguration>
Type: string
Format: 40-character alphanumeric string ([0-9a-z]{40})
The certificate thumbprint as it is registered in the Windows Certificate Store.
Type: string
Format: 64-character alphanumeric string ([0-9A-Za-z]{64})
The certificate fingerprint as it is generated by OpenSSL
Type: string
The unique client ID as agreed by Bluem
Type: string
Format: Basic URL-encoded URI
The URL where the paymentrequest is redirected to upon registering the payment. The URL can contain optional format parameters that are automatically replaced with data from the request. The possible parameters are:
entranceCode
paymentReference
debtorReference
So for instance, the following ReturnUrl
can be constructed:
ReturnUrl="https://return.to.me/?ec={entranceCode}&pr={paymentReference}&dr={debtorReference}"
Which will result in something like:
GET https://return.to.me/?ec=123abc&pr=456def&dr=789ghi
Type: string
Format: Basic URL-encoded URI
Default: https://viamijnbank.net/pr/createTransaction
The URI which is used to create a new payment transaction.
Type: string
Format: Basic URL-encoded URI
Default: https://viamijnbank.net/pr/requestTransactionStatus
The URI which is used to create a new payment status transaction.
Type: string
Default: IDEAL
The prefered method of payment.
Type: string
Default: PayRequest
The skin that is used on the payment page as it is set in Bluem.
Type: string
Format: 3-character string
Default: EUR
The currency which is used on your payment-page.
Type: boolean
Default: false
Get a complete dump of the request as it being build-up and sent to Bluem for debugging purposes.
Type: string
Default: BluemDefaultHashSalt
The salt that is used to generate an EntranceCode for each request that's being sent to Bluem.
Type: integer
Default: 16
The length of the hash that is used as an EntranceCode.