Skip to content

citypay/citypay-api-client-dotnet

Repository files navigation

CityPay API Client for DotNet

Build Status

This CityPay API is an HTTP RESTful payment API used for direct server to server transactional processing. It provides a number of payment mechanisms including: Internet, MOTO, Continuous Authority transaction processing, 3-D Secure decision handling using RFA Secure, Authorisation, Refunding, Pre-Authorisation, Cancellation/Voids and Completion processing. The API is also capable of tokenized payments using cardholder Accounts.

Compliance and Security

Your application will need to adhere to PCI-DSS standards to operate safely and to meet requirements set out by Visa and MasterCard and the PCI Security Standards Council. These include

  • Data must be collected using TLS version 1.2 using strong cryptography. We will not accept calls to our API at lower grade encryption levels. We regularly scan our TLS endpoints for vulnerabilities and perform TLS assessments as part of our compliance program.
  • The application must not store sensitive cardholder data (CHD) such as the card security code (CSC) or primary access number (PAN)
  • The application must not display the full card number on receipts, it is recommended to mask the PAN and show the last 4 digits. The API will return this for you for ease of receipt creation
  • If you are developing a website, you will be required to perform regular scans on the network where you host the application to meet your compliance obligations
  • You will be required to be PCI Compliant and the application must adhere to the security standard. Further information is available from https://www.pcisecuritystandards.org/
  • The API verifies that the request is for a valid account and originates from a trusted source using the remote IP address. Our application firewalls analyse data that may be an attempt to break a large number of security common security vulnerabilities.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 6.6.23
  • SDK version: 1.3.2
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen For more information, please visit https://www.citypay.com/contacts/

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using CityPayAPI.Api;
using CityPayAPI.Client;
using CityPayAPI.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out CityPayAPI.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using CityPayAPI.Api;
using CityPayAPI.Client;
using CityPayAPI.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.citypay.com";
            // Create a temporal ApiKey using your client id and licence key
            config.AddApiKey("cp-api-key", new ApiKey("CLIENT_ID", "LICENCE_KEY").GenerateKey());

            var apiInstance = new AuthorisationAndPaymentApi(config);
            var authRequest = new AuthRequest(); // AuthRequest | 

            try
            {
                // Authorisation
                Decision result = apiInstance.AuthorisationRequest(authRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling AuthorisationAndPaymentApi.AuthorisationRequest: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.citypay.com

Class Method HTTP request Description
AuthorisationAndPaymentApi AuthorisationRequest POST /v6/authorise Authorisation
AuthorisationAndPaymentApi BinRangeLookupRequest POST /v6/bin Bin Lookup
AuthorisationAndPaymentApi CResRequest POST /v6/cres CRes
AuthorisationAndPaymentApi CaptureRequest POST /v6/capture Capture
AuthorisationAndPaymentApi PaResRequest POST /v6/pares PaRes
AuthorisationAndPaymentApi RefundRequest POST /v6/refund Refund
AuthorisationAndPaymentApi RetrievalRequest POST /v6/retrieve Retrieval
AuthorisationAndPaymentApi VoidRequest POST /v6/void Void
BatchProcessingApi BatchProcessRequest POST /v6/batch/process Batch Process Request
BatchProcessingApi BatchRetrieveRequest POST /v6/batch/retrieve BatchReportRequest
BatchProcessingApi CheckBatchStatusRequest POST /v6/batch/status CheckBatchStatus
CardHolderAccountApi AccountCardDeleteRequest DELETE /v6/account/{accountid}/card/{cardId} Card Deletion
CardHolderAccountApi AccountCardRegisterRequest POST /v6/account/{accountid}/register Card Registration
CardHolderAccountApi AccountCardStatusRequest POST /v6/account/{accountid}/card/{cardId}/status Card Status
CardHolderAccountApi AccountChangeContactRequest POST /v6/account/{accountid}/contact Contact Details Update
CardHolderAccountApi AccountCreate POST /v6/account/create Account Create
CardHolderAccountApi AccountDeleteRequest DELETE /v6/account/{accountid} Account Deletion
CardHolderAccountApi AccountExistsRequest GET /v6/account-exists/{accountid} Account Exists
CardHolderAccountApi AccountRetrieveRequest GET /v6/account/{accountid} Account Retrieval
CardHolderAccountApi AccountStatusRequest POST /v6/account/{accountid}/status Account Status
CardHolderAccountApi ChargeRequest POST /v6/charge Charge
DirectPostApi DirectCResAuthRequest POST /direct/cres/auth/{uuid} Handles a CRes response from ACS, returning back the result of authorisation
DirectPostApi DirectCResTokeniseRequest POST /direct/cres/tokenise/{uuid} Handles a CRes response from ACS, returning back a token for future authorisation
DirectPostApi DirectPostAuthRequest POST /direct/auth Direct Post Auth Request
DirectPostApi DirectPostTokeniseRequest POST /direct/tokenise Direct Post Tokenise Request
DirectPostApi TokenRequest POST /direct/token Direct Post Token Request
OperationalFunctionsApi AclCheckRequest POST /v6/acl/check ACL Check Request
OperationalFunctionsApi DomainKeyCheckRequest POST /dk/check Domain Key Check Request
OperationalFunctionsApi DomainKeyGenRequest POST /dk/gen Domain Key Generation Request
OperationalFunctionsApi ListMerchantsRequest GET /v6/merchants/{clientid} List Merchants Request
OperationalFunctionsApi PingRequest POST /v6/ping Ping Request
PaylinkApi TokenAdjustmentRequest POST /paylink/{token}/adjustment Paylink Token Adjustment
PaylinkApi TokenChangesRequest POST /paylink/token/changes Paylink Token Audit
PaylinkApi TokenCloseRequest PUT /paylink/{token}/close Close Paylink Token
PaylinkApi TokenCreateBillPaymentRequest POST /paylink/bill-payment Create Bill Payment Paylink Token
PaylinkApi TokenCreateRequest POST /paylink/create Create Paylink Token
PaylinkApi TokenPurgeAttachmentsRequest PUT /paylink/{token}/purge-attachments Purges any attachments for a Paylink Token
PaylinkApi TokenReconciledRequest PUT /paylink/{token}/reconciled Reconcile Paylink Token
PaylinkApi TokenReopenRequest PUT /paylink/{token}/reopen Reopen Paylink Token
PaylinkApi TokenStatusRequest GET /paylink/{token}/status Paylink Token Status

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

cp-api-key

  • Type: API key
  • API key parameter name: cp-api-key
  • Location: HTTP header

cp-domain-key

  • Type: API key
  • API key parameter name: cp-domain-key
  • Location: URL query string