I have an older application that was written with Visual Studio 2013 using VB.net, framework 4.5
I had to update the stripe.net NuGet package and the API must be different. I used to charge a card (which was populated by the user on a simple form) using the following script:
Dim myCharge = New StripeChargeCreateOptions()
myCharge.Amount = lblPrice.Text * 100 'put into cents for Stripe
myCharge.Currency = "usd"
myCharge.Description = "sample test charge"
myCharge.CardNumber = txtCardNumber.Text
myCharge.CardExpirationYear = txtExpiresYear.Text
myCharge.CardExpirationMonth = txtExpiresMonth.Text
myCharge.CardCvc = txtCVC.Text
myCharge.Capture = True
Dim chargeService = New StripeChargeService
Dim StripeCharge = New StripeCharge
StripeCharge = chargeService.Create(myCharge)
It no longer works, as I think the logic changed!
I cannot seem to figure out how to charge a card a certain amount using the package.
The package details are:
Created by: Stripe, Jayme Davis
Id: Stripe.net
Version: 13.1.0
Dependency: Newtonsoft.Json (>= 9.0.1)
I think I need to create a charge object like this:
Dim charge = New StripeCharge
charge.Amount = lblPrice.Text
charge.Description = "test"
charge.Currency = "USD"
There are no options for the credit card number or card details in the StripeCharge object anymore. I cannot seem to understand the logic I need to do in order to charge a simple transaction.
Does anyone have any experience with this in VB.net?
THE FOLLOWING WAS ADDED AFTER I STARTED WORKING ON THE CODE BASED ON COMMENTS:
Based on a suggestion, I "think" I need to create a card token and then assign that to the charge options. Here's what I'm working on so far:
Dim tokenOptions = New StripeTokenCreateOptions
tokenOptions.Card.Number = txtCardNumber.Text
tokenOptions.Card.ExpirationMonth = txtExpiresMonth.Text
tokenOptions.Card.ExpirationYear = txtExpiresYear.Text
tokenOptions.Card.Cvc = txtCVC.Text
Dim tokenService = New StripeTokenService
Dim token = tokenService.Create(tokenOptions)
Dim charge = New StripeCharge
charge.Amount = lblPrice.Text
charge.Description = "test"
charge.Currency = "USD"
charge.Source.Card.Id = token.Id
Dim chargeService = New StripeChargeService
Dim StripeCharge = chargeService.Create(charge)
I am hoping I create the token properly with my code. The next issue I have (if the token is right) is that chargeService.Create(charge) is wrong. I get the following message for the 'charge' part of it:
Value of type 'Stripe.StripeCharge' canot be converted to 'Stripe.StripeChargeCreateOptions'
So, if I change
Dim charge = New StripeCharge
to
Dim charge = New StripeChargeCreateOptions
... then suddenly the .Amount, .Description, .Currency, .Source.Card.Id are no longer elements to that object.