Dictionary within a Dictionary (HTMLFormData)

According to the Stripe API documentation (Found here), to create a new charge, “a dictionary containing a user’s credit card details” needs to be submitted with the general charge information. How would I go about including a “dictionary” within the dictionary that defines the charge details?

[code] Dim form As new Dictionary
Dim card As new Dictionary

card.Value("number") = "4242424242424242"
card.Value("exp_month") = "01"
card.Value("exp_year") = "2015"
card.Value("cvc") = "123"
card.Value("address_zip") = "12345"

form.Value("amount") = "400"
form.Value("currency") = "usd"
form.Value("card") = card

HTTPS1.Secure = True
HTTPS1.ConnectionType = SSLSocket.SSLv3
HTTPS1.SetRequestHeader("Authorization", "Bearer " + App.StripeTestKey)
HTTPS1.Post(App.StripeAPI + "customers")

The Create a new card API (Found here) also requires “a dictionary containing a user’s credit card details” so simply assigning the value to each variable produces an error.

Thanx for the help.

It doesn’t look like you need a Xojo dictionary for what you are trying to do. Instead it appears you need a JSON style dictionary which is very different from the built in dictionary. I would recommend that you create a class to handle the data storage and formatting for you that can then pass the required data as a string that is understood by the API.

form.Value("amount") = "400" form.Value("currency") = "usd" form.Value("card[number]") = "4242424242424242" form.Value("card[exp_month]") = "01" form.Value("card[exp_year]") = "2015" form.Value("card[cvc") = "123" form.Value("card[address_zip]") = "12345"
does the trick.