ProgrammingAsk
ProgrammingAsk

Reputation: 65

Stripe charge in C#.NET 4.6

I installed the latest stripe library from nuget. This is original Stripe library for .NET.

I had the same older library and exsisting code was working OK. The latest library doesn't support those classes. How to charge as exsisting code with the latest library?

    public void ChargeStripe(string stripeEmail, string stripeToken, string payAmount, string 
                             currency, string customerId, string paymentDescription) 
                                 
    {
        // public ActionResult Charge(string stripeEmail, string stripeToken)
        var customers = new StripeCustomerService();
        var charges = new StripeChargeService();

        var customer = customers.Create(new StripeCustomerCreateOptions
        {
            Email = stripeEmail,
            SourceToken = stripeToken
        });

        var charge = charges.Create(new StripeChargeCreateOptions
        {
            Amount = payAmount,  // charge in cents
            Description = paymentDescription,
            Currency = currency,
            CustomerId = customerId
        });
    }

Upvotes: 0

Views: 158

Answers (1)

Lukasz Szczygielek
Lukasz Szczygielek

Reputation: 3110

Please look at Stripe changelog. I see that they changed some names between versions. Probably you will need only to change them.

Upvotes: 1

Related Questions