Skip to content

globallypaid/globallypaid-sdk-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Globally Paid .NET SDK

NuGet CI

The official Globally Paid .NET library

Supporting .NET Standard 2.0

Installation

Using the .NET Core CLI tools:

dotnet add package GloballyPaid.net

Using the NuGet CLI:

nuget install GloballyPaid.net

Using the Package Manager Console:

Install-Package GloballyPaid.net

From within Visual Studio:

  1. Open Solution Explorer
  2. Right-click on a project within your solution
  3. Click on Manage NuGet Packages
  4. Click on the Browse tab and search for GloballyPaid.net
  5. Click on the GloballyPaid.net package, select version in the right-tab
  6. Click Install

Documentation

For the Globally Paid API documentation, please visit Globally Paid API documentation

Samples

For a comprehensive list of examples, please visit Globally Paid .NET SDK samples.

Usage

Configuration

There are three ways to configure the Globally Paid SDK:

1. Startup Extension

All SDK calls can be configured within ConfigureServices method in Startup class using the AddGloballyPaid extension. Additionally, this extension call will register all Globally Paid services:

services.AddGloballyPaid("Your Publishable API Key", "Your Shared Secret", "Your APP ID", useSandbox: false, requestTimeoutSeconds: 90);

To register the Globally Paid services only, AddGloballyPaidServices extension can be used:

services.AddGloballyPaidServices();
2. GloballyPaidConfiguration object

All SDK calls can be configured using the static GloballyPaidConfiguration object:

GloballyPaidConfiguration.PublishableApiKey = "Your Publishable API Key";
GloballyPaidConfiguration.SharedSecret = "Your Shared Secret";
GloballyPaidConfiguration.AppId = "Your APP ID";
GloballyPaidConfiguration.UseSandbox = false; //true if you need to test through Globally Paid sandbox
GloballyPaidConfiguration.RequestTimeoutSeconds = 90;

Or using the GloballyPaidConfiguration Setup method:

GloballyPaidConfiguration.Setup("Your Publishable API Key", "Your Shared Secret", "Your APP ID", useSandbox: false, requestTimeoutSeconds: 90);
3. The <appSettings> section

All SDK calls can be configured using the <appSettings> section in configuration files (App.config or web.config):

<appSettings>
    <add key="GloballyPaidPublishableApiKey" value="Your Publishable API Key"></add>
    <add key="GloballyPaidSharedSecret" value="Your Shared Secret"></add>
    <add key="GloballyPaidAppId" value="Your APP ID"></add>
    <add key="GloballyPaidUseSandbox" value="false"></add> <!--true if you need to test through Globally Paid sandbox-->
    <add key="GloballyPaidRequestTimeoutSeconds" value="90"></add>
</appSettings>

Per-request configuration

All SDK service methods accept an optional RequestOptions object, additionally allowing per-request configuration:

var requestOptions = new RequestOptions("Your Publishable API Key", "Your Shared Secret", "Your APP ID", useSandbox: false, requestTimeoutSeconds: 90);

Sample Charge Sale Transaction

var request = new ChargeRequest
            {
                Source = "source", //this can be the token or payment instrument identifier
                Amount = 1299,
                Capture = true, //sale charge
                ClientCustomerId = "12345", //set your customer id
                ClientInvoiceId = "IX213", //set your invoice id
                ClientTransactionDescription = "Tuition for CS" //set your transaction description
            };

//if Globally Paid services are registered, you can inject this as IChargeService in the constructor
var chargeService = new ChargeService(); 
var charge = chargeService.Charge(request);

For any feedback or bug/enhancement report, please open an issue or submit a pull request.