TwoCheckoutCore 1.0.0

dotnet add package TwoCheckoutCore --version 1.0.0
NuGet\Install-Package TwoCheckoutCore -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TwoCheckoutCore" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TwoCheckoutCore --version 1.0.0
#r "nuget: TwoCheckoutCore, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TwoCheckoutCore as a Cake Addin
#addin nuget:?package=TwoCheckoutCore&version=1.0.0

// Install TwoCheckoutCore as a Cake Tool
#tool nuget:?package=TwoCheckoutCore&version=1.0.0

2Checkout .NET Standard 2.1 Library

This library provides developers with a simple set of bindings to the 2Checkout purchase routine, Instant Notification Service and Back Office API.

Full documentation for each binding is provided at in the wiki.

NOTE: This is the .NET Standard 2.1 version, provided by SaasyCloud.com forked from the original 2Checkout .NET library.

Installation

Install the NuGet package:

Install-Package TwoCheckoutCore -Version 1.0.0

Example Payment API Usage:

Example Usage:

TwoCheckoutConfig.SellerID = "1817037";
TwoCheckoutConfig.PrivateKey = "8CE03B2D-FE41-4C53-9156-52A8ED5A0FA3";
//TwoCheckoutConfig.Sandbox = true;   <-- Set Mode to use your 2Checkout sandbox account

try
{
    var Billing = new AuthBillingAddress();
    Billing.addrLine1 = "123 test st";
    Billing.city = "Columbus";
    Billing.zipCode = "43123";
    Billing.state = "OH";
    Billing.country = "USA";
    Billing.name = "Testing Tester";
    Billing.email = "example@2co.com";
    Billing.phoneNumber = "5555555555";

    var Customer = new ChargeAuthorizeServiceOptions();
    Customer.total = (decimal)1.00;
    Customer.currency = "USD";
    Customer.merchantOrderId = "123";
    Customer.billingAddr = Billing;
    Customer.token = "MzIwNzI3ZWQtMjdiNy00NTVhLWFhZTEtZGUyZGQ3MTk1ZDMw";

    var Charge = new ChargeService();
    
    var result = Charge.Authorize(Customer);
    Console.Write(result);
}
catch (TwoCheckoutException e)
{
    Console.Write(e);
}

Example Response:

{TwoCheckout.Authorization}
    responseMsg: "Successfully authorized the provided credit card"
    responseCode: "APPROVED"
    type: "AuthResponse"
    orderNumber: 205205956108
    merchantOrderId: "123"
    transactionId: 205205956117
    currencyCode: "USD"
    total: 1.00
    lineItems: ...
      {TwoCheckout.AuthLineitem}
        type: "product"
        name: "123"
        quantity: 1
        price: 1.0
        tangible: "N"
        productId: ""
        recurrence: null
        duration: null
        startupFee: null
        options: ...
        billingAddr: { }
      {TwoCheckout.AuthBillingAddress}
        name: "Testing Tester"
        addrLine1: "123 test st"
        addrLine2: null
        city: "Columbus"
        state: "OH"
        zipCode: "43123"
        country: "USA"
        email: "example@2co.com"
        phoneNumber: null
        phoneExt: null

Example Exception:

Unauthorized

Example Admin API Usage

Example Usage:

TwoCheckoutConfig.ApiUsername = "APIuser1817037";
TwoCheckoutConfig.ApiPassword = "APIpass1817037";

try
{
    var ServiceObject = new SaleService();
    var ArgsObject = new SaleRefundServiceOptions();
    ArgsObject.invoice_id = invoice_id;
    ArgsObject.comment = "test refund";
    ArgsObject.category = 5;
    var result = ServiceObject.Refund(ArgsObject);
}
catch (TwoCheckoutException e)
{
    // read e.message
}

Example Response:

{TwoCheckout.TwoCheckoutResponse}
  response_code: "OK"
  response_message: "refund added to invoice"

Example Checkout Usage:

Example Usage:

var dictionary = new Dictionary<string, string>();
dictionary.Add("sid", "1817037");
dictionary.Add("mode", "2CO");
dictionary.Add("li_0_type", "product");
dictionary.Add("li_0_name", "Example Product");
dictionary.Add("li_0_price", "1.00");

String PaymentForm = ChargeService.Submit(dictionary);

Example Return Usage:

Example Usage:

TwoCheckoutConfig.SecretWord = "tango";
TwoCheckoutConfig.SellerID = "1817037";

var Return = new ReturnService();
var Args = new ReturnCheckServiceOptions();
Args.total = "0.01";
Args.order_number = Request.Params["order_number"];
Args.key = Request.Params["key"];
bool result = Return.Check(Args);

Example Response:

true

Example INS Usage:

Example Usage:

TwoCheckoutConfig.SecretWord = "tango";
TwoCheckoutConfig.SellerID = "1817037";

var Notification = new NotificationService();
var Args = new NotificationCheckServiceOptions();
Args.invoice_id = Request.Params["invoice_id"];
Args.sale_id = Request.Params["sale_id"];
Args.md5_hash = Request.Params["md5_hash"];
bool result = Notification.Check(Args);

Example Response:

true

Exceptions:

TwoCheckoutException exceptions are thrown by if an error has returned. It is best to catch these exceptions so that they can be gracefully handled in your application.

Example Catch

TwoCheckoutConfig.SellerID = "1817037";
TwoCheckoutConfig.PrivateKey = "8CE03B2D-FE41-4C53-9156-52A8ED5A0FA3";

try
{
    var Billing = new AuthBillingAddress();
    Billing.addrLine1 = "123 test st";
    Billing.city = "Columbus";
    Billing.zipCode = "43123";
    Billing.state = "OH";
    Billing.country = "USA";
    Billing.name = "Testing Tester";
    Billing.email = "example@2co.com";
    Billing.phone = "5555555555";

    var Customer = new ChargeAuthorizeServiceOptions();
    Customer.total = (decimal)1.00;
    Customer.currency = "USD";
    Customer.merchantOrderId = "123";
    Customer.billingAddr = Billing;
    Customer.token = "MzIwNzI3ZWQtMjdiNy00NTVhLWFhZTEtZGUyZGQ3MTk1ZDMw";

    var Charge = new ChargeService();
    
    var result = Charge.Authorize(Customer);
    Console.Write(result);
}
catch (TwoCheckoutException e)
{
    Console.Write(e);
}

Example Exception

Unauthorized

Full documentation for each binding is provided at in the wiki.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 724 5/15/2021