Sample code: Web Services 

 

Below you can find examples of Web Services interface (WCF) calls. In this page, you can also download sample codes to help your Web Services implementation. The examples assume you have added the WSDL to your project with the namespace BBS.

Please note that below mentioned calls are meant to be only examples and shouldn’t be used as such.  For example [MERCHANTID] and [TOKEN] in the examples need to be replaced for the values provided by Nets. In addition, a unique value needs to be generated for each transaction in the TransactionId tag. After the registration phase, you should refer to this unique value in all later operations for this transaction.

 

Step 1: Register payment with recurring info

var registerRequest = new RegisterRequest
{
    Order = new Order
    {
        Amount = "1000",
        OrderNumber = "12345",
        CurrencyCode = "EUR"
    },
    Terminal = new Terminal
    {
        RedirectUrl = "http://localhost/Test/"
    },
    Environment = new Environment
    {
        WebServicePlatform = "WCF"
    },
    Recurring = new Recurring
    {
        Type = "R",
        ExpiryDate = "20201231", // required on initial recurring payment
        Frequency = "28", // required on initial recurring payment
        // PanHash = "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" // required on subsequent recurring payment, the actual panHash value is returned in query call
	RecurringTransactionType = null
    }
};
RegisterResponse response;
using (var client = new NetaxeptClient())
{
    response = await client.RegisterAsync([MERCHANT_ID], [TOKEN], registerRequest);
}
string transactionId = response.TransactionId;

 

Step 2: Authorize and capture payment

var processRequest = new ProcessRequest
{
    TransactionId = [TRANSACTION_ID],
    Operation = "SALE", // to capture the amount partially one shall call AUTH operation instead, followed by CAPTURE operation
};
ProcessResponse processResponse;
using (var client = new NetaxeptClient())
{
    processResponse = await client.ProcessAsync([MERHCANT_ID], [TOKEN], processRequest);
}
string authorizationId = processResponse.AuthorizationId;
string batchNumber = processResponse.BatchNumber;

 

Step 3: Credit payment

var processRequest = new ProcessRequest
{
    TransactionId = [TRANSACTION_ID],
    Operation = "CREDIT",
    TransactionAmount = "100"
};
ProcessResponse processResponse;
using (var client = new NetaxeptClient())
{
    processResponse = await client.ProcessAsync([MERCHANT_ID], [TOKEN], processRequest);
}
string batchNumber = processResponse.BatchNumber;

 

Step 4: Run query to payment

var queryRequest = new QueryRequest
{
    TransactionId = [TRANSACTION_ID],
};
QueryResponse queryResponse;
using (var client = new NetaxeptClient())
{
    queryResponse = await client.QueryAsync([MERCHANT_ID], [TOKEN], queryRequest);
}
string panHash = ((PaymentInfo)queryResponse).Recurring.PanHash;

 

Below you can download sample code for the Web Services implementation: