RechargeSharp 12.2.4

dotnet add package RechargeSharp --version 12.2.4                
NuGet\Install-Package RechargeSharp -Version 12.2.4                
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" Version="12.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RechargeSharp --version 12.2.4                
#r "nuget: RechargeSharp, 12.2.4"                
#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 as a Cake Addin
#addin nuget:?package=RechargeSharp&version=12.2.4

// Install RechargeSharp as a Cake Tool
#tool nuget:?package=RechargeSharp&version=12.2.4                

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 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
12.2.4 666 10/8/2024
12.2.3 1,851 10/30/2023
12.2.2 1,798 11/8/2022
12.2.1 669 9/13/2022
12.2.0 909 9/13/2022
12.1.1 490 9/5/2022
12.1.1-alpha.2 299 7/27/2022
12.1.1-alpha.1 131 7/27/2022
12.1.0-alpha.3 124 7/27/2022
12.0.0-alpha.3 662 6/2/2022
12.0.0-alpha.2 124 6/2/2022
12.0.0-alpha.1 124 6/2/2022
11.2.0-alpha.2 122 5/24/2022
11.2.0-alpha.1 136 4/26/2022
11.1.0-beta.5 2,736 3/23/2022
11.1.0-beta.4 129 3/2/2022
11.1.0-beta.3 951 2/24/2022
11.1.0-beta.1 124 2/17/2022
11.0.1 740 2/9/2022
11.0.1-alpha.1 132 2/9/2022
11.0.0 484 2/7/2022
11.0.0-alpha.7 396 2/1/2022
11.0.0-alpha.6 145 1/10/2022
11.0.0-alpha.4 1,868 12/14/2021
11.0.0-alpha.3 158 12/12/2021
11.0.0-alpha.2 158 12/10/2021
10.0.0 547 12/8/2021
10.0.0-alpha.3 628 11/30/2021
10.0.0-alpha.2 417 11/23/2021
9.0.0 1,217 11/9/2021
9.0.0-alpha.2 524 10/8/2021
9.0.0-alpha.1 278 10/7/2021
8.1.0-alpha.3 379 10/1/2021
8.1.0-alpha.2 222 9/28/2021
8.1.0-alpha.1 158 9/27/2021
8.0.1 436 9/23/2021
7.0.0 526 9/8/2021
7.0.0-alpha.4 477 8/4/2021
7.0.0-alpha.3 197 8/3/2021
7.0.0-alpha.2 160 8/2/2021
7.0.0-alpha.1 182 8/2/2021
6.0.1 533 7/13/2021
6.0.0 461 7/12/2021
5.1.0 467 7/5/2021
5.0.0 779 6/9/2021
5.0.0-alpha.1 172 6/9/2021
4.6.0 728 5/20/2021
4.6.0-beta.2 200 5/13/2021
4.6.0-beta.1 184 5/13/2021
4.5.0 424 5/11/2021
4.5.0-beta.8 167 5/11/2021
4.5.0-beta.7 189 4/27/2021
4.5.0-beta.5 150 4/27/2021
4.5.0-beta.4 165 4/27/2021
4.5.0-beta.3 199 4/23/2021
4.5.0-beta.2 178 4/22/2021
4.5.0-beta.1 174 4/21/2021
4.4.6 583 4/12/2021
4.4.6-beta.1 172 4/12/2021
4.4.4 429 4/9/2021
4.4.4-beta.1 170 4/8/2021
4.4.3 496 4/5/2021
4.4.2 525 3/26/2021
4.4.1 616 3/14/2021
4.4.0 805 2/9/2021
4.3.2 408 1/27/2021
4.3.1 374 1/27/2021
4.3.0 459 1/20/2021
4.2.0 410 1/13/2021
4.1.4 423 12/29/2020
4.1.3 411 12/29/2020
4.1.2 488 12/21/2020
4.1.1 1,043 5/29/2020
4.1.0 526 5/29/2020
4.1.0-beta.1 274 5/27/2020
4.0.3-beta.2 325 5/11/2020
4.0.3-beta.1 280 5/11/2020
4.0.2 601 4/9/2020
4.0.1 609 3/25/2020
4.0.0 504 3/25/2020
4.0.0-beta.2 262 3/24/2020
4.0.0-beta.1 267 3/24/2020
3.2.8 536 3/23/2020
3.2.7 542 3/19/2020
3.2.6 547 3/9/2020
3.2.5 549 3/5/2020
3.2.4 536 3/4/2020
3.2.3 572 3/4/2020
3.2.2 521 3/4/2020
3.2.1 528 3/4/2020
3.2.0 579 3/4/2020
3.1.0 537 3/4/2020
3.0.10 546 2/27/2020
3.0.9 485 2/24/2020
3.0.7 507 2/24/2020
3.0.6 603 2/3/2020
3.0.5 540 2/3/2020
3.0.3 610 1/31/2020
3.0.1 551 1/13/2020
3.0.0 650 12/28/2019
2.2.9 606 12/13/2019
2.2.8 543 12/13/2019
2.2.7 656 11/21/2019
2.2.6 566 11/12/2019
2.2.5 540 11/8/2019
2.2.4 531 11/6/2019
2.2.3 540 11/6/2019
2.2.2 539 11/6/2019
2.2.1 538 11/6/2019
2.2.0 540 11/6/2019
2.1.1 520 11/1/2019
2.1.0 525 10/31/2019
2.0.1 567 10/29/2019
2.0.0 554 10/29/2019
1.5.0 542 10/25/2019
1.4.0 521 10/23/2019
1.3.0 541 10/16/2019
1.2.0 545 10/16/2019
1.1.4 527 10/9/2019
1.1.0 567 10/9/2019
1.0.0 552 9/18/2019
0.2.58 536 9/17/2019
0.2.57 583 9/16/2019
0.2.56 578 9/16/2019
0.2.55 783 9/16/2019
0.2.54 562 9/16/2019
0.2.53 578 9/16/2019
0.2.52 574 9/16/2019
0.2.51 554 9/13/2019
0.2.50 590 9/12/2019
0.2.49 571 9/12/2019
0.2.48 592 9/10/2019
0.2.47 567 9/10/2019
0.2.46 611 9/9/2019
0.2.43 588 9/7/2019
0.2.42 588 9/7/2019
0.2.37 579 9/7/2019
0.2.36 559 9/7/2019
0.2.35 576 9/7/2019
0.2.34 583 9/6/2019
0.2.33 552 9/5/2019
0.2.32 541 9/5/2019
0.2.31 555 9/5/2019
0.2.30 560 9/4/2019
0.2.25 573 9/4/2019
0.2.24 580 9/4/2019
0.2.23 537 9/3/2019
0.2.14 541 9/3/2019
0.2.13 563 9/3/2019
0.2.9 562 9/3/2019
0.2.8 538 9/3/2019
0.2.7 532 9/3/2019
0.2.6 550 9/3/2019
0.1.9 566 8/30/2019
0.1.8 590 8/15/2019
0.1.4 574 8/15/2019
0.1.3 534 8/15/2019
0.1.2 553 8/15/2019
0.1.1 528 8/15/2019
0.1.0 570 7/30/2019
0.0.32 575 7/26/2019
0.0.31 578 7/26/2019
0.0.24 569 7/25/2019
0.0.23 596 7/25/2019
0.0.22 545 7/25/2019
0.0.21 570 7/25/2019
0.0.20 556 7/25/2019
0.0.19 558 7/25/2019
0.0.18 585 7/25/2019
0.0.17 568 7/25/2019
0.0.16 603 7/23/2019
0.0.15 574 7/22/2019
0.0.14 630 7/22/2019
0.0.13 621 7/22/2019
0.0.12 570 7/22/2019
0.0.11 634 7/11/2019
0.0.10 619 7/10/2019
0.0.9 627 7/10/2019
0.0.8 590 7/9/2019
0.0.7 574 7/9/2019
0.0.6 579 7/9/2019
0.0.5 596 7/8/2019
0.0.4 593 7/8/2019
0.0.3 590 7/7/2019
0.0.2 572 7/4/2019
0.0.1 590 6/25/2019

Added missing storefront purchase option