RechargeSharp.v2021-11 1.0.0-alpha.1

This is a prerelease version of RechargeSharp.v2021-11.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package RechargeSharp.v2021-11 --version 1.0.0-alpha.1                
NuGet\Install-Package RechargeSharp.v2021-11 -Version 1.0.0-alpha.1                
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="RechargeSharp.v2021-11" Version="1.0.0-alpha.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RechargeSharp.v2021-11 --version 1.0.0-alpha.1                
#r "nuget: RechargeSharp.v2021-11, 1.0.0-alpha.1"                
#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 RechargeSharp.v2021-11 as a Cake Addin
#addin nuget:?package=RechargeSharp.v2021-11&version=1.0.0-alpha.1&prerelease

// Install RechargeSharp.v2021-11 as a Cake Tool
#tool nuget:?package=RechargeSharp.v2021-11&version=1.0.0-alpha.1&prerelease                

RechargeSharp, a C# library for RechargePayments

Get it here https://www.nuget.org/packages/RechargeSharp/

Built to work with the api documented at https://developer.rechargepayments.com/

Please feel free to submit issues and pull requests on github

Supported API versions

  • 2021-01: The namespace for this is just RechargeSharp.
  • 2021-11: The namespace for this is RechargeSharp.v2021-11.

You can use services from both namespaces simultaneously without issues.

Recharge API version 2021-11

Quickstart

Dependency injection

Use the AddRechargeSharp2021_11() to add the services to the service collection, like so:

var hostBuilder = Host.CreateDefaultBuilder()
    .ConfigureServices(collection =>
    {
        var apiKey = "<insert-your-API-key-here>";
        collection.AddRechargeSharp2021_11(options => options.ApiKey = apiKey);
    });

After this, the DI container will be able to resolve services for implemented endpoints, such as the IAddressService, ICustomerService, and so on.

Here is a tiny example of a class that uses the ICustomerService.

private readonly ICustomerService _customerService;

public YourServiceThatUsesRechargeSharp(ICustomerService customerService)
{
    _customerService = customerService;
}

protected async Task PrintCustomerEmail()
{
    GetCustomerTypes.Response? response = await _customerService.GetCustomerAsync(1234);
    Console.WriteLine($"Customer email: {response!.Customer!.Email}");    
}

Recharge API version 2021-01

Quickstart

Dependency injection

If you set up your appsettings.json like this:

{  
    "RechargeConfiguration": {
        "ApiKey": [
            "1",
            "2",
            "3",
            "4"
        ]
  }
}

Add RechargeSharp to dependency injection. After that the services will be constructor injected.

// this example shows how you can get a list of api keys from configuration that the services will swap between automatically when encountering throttling.
services.AddRechargeSharp(opts =>
                {
                    opts.ApiKeyArray = _configuration.GetSection("RechargeConfiguration:ApiKey").GetChildren().Select(x => x.Value).ToArray();
                    opts.WebhookApiKey = _configuration["RechargeConfiguration:ApiKey:0"];
                })
// if you only have 1 api key you wish to work with you can do the following.
services.AddRechargeSharp(opts => 
                {
                    opts.ApiKeyArray = new[] { "apikey" });
                    opts.WebhookApiKey = "apikey";
                }
Subscriptions
public class SubscriptionTestClass {
    private readonly SubscriptionService _subscriptionService;

    // constructor inject the subscription service to start working with subscriptions.
    public SubscriptionTestClass(SubscriptionService subscriptionService){
        _subscriptionService = subscriptionService;
    }

    public async Task DoStuff(){
        // get all subscriptions with status ACTIVE and created after two months ago.
        var subscriptions = await subscriptionService.GetAllSubscriptionsWithParamsAsync(status: "ACTIVE", createdAtMin: DateTime.Today.AddMonths(-2));

        // iterate results and print subscription Id.
        foreach (var subscription in subscriptions)
        {
            Console.WriteLine(subscription.Id);
        }
    }
}
Customers
public class CustomerTestClass {
    private readonly CustomerService _customerService;

    // constructor inject the customer service to start working with customers.
    public CustomerTestClass(CustomerService customerService){
        _customerService = customerService;
    }

    public async Task DoStuff(){
        // get all customers created in the last two days.
        var customers = await _customerService.GetAllCustomersWithParamsAsync(createdAtMin: DateTime.Now.AddDays(-2));

        // iterate results and print whether the customer has a valid payment method.
        foreach (var customer in customers)
        {
            Console.WriteLine(customer.HasValidPaymentMethod);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
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-alpha.3 2,374 3/24/2022
1.0.0-alpha.2 126 3/23/2022
1.0.0-alpha.1 155 3/21/2022

Simplify target frameworks