I need to make a http post request using the following instructions:
curl https://api.stripe.com/v1/tokens \
-u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
-d "bank_account[country]=US" \
-d "bank_account[routing_number]=110000000" \
-d "bank_account[account_number]=000123456789"
I have no idea how to go from curl to NSUrlrequest, especially the -u (user?) part. The stripe SDK has left this out from their SDK and has no example on their site.
Thanks
STPCard has a method -(NSData *)formEncode that stripe.m uses to populate the body of the nsurlrequest. I used their format to create my own encode with bank account information instead of the card.
Stripe's token creation with a card:
Stripe.m
STPCard.m
My barebones bank_account creation:
BankAccount.h
BankAccount.m
My Stripe.m Additions. Notice I use a BankAccount object, and then use it's - (NSData *)bankAccountEncode instead of STPCard's formEncode.
EDIT:I created another answer specifically for getting a token for a bank_account. This answer was for generally how to make a call using parse's back end using an example of creating a recipient.
The stipe documentation is a little off here, the call for creating a bank_account token is actually made using the publishable key directly from the app. Make sure not to use your secret key in the iOS app itself. Only your public key should be used via:
You need to use a web back end to implement the complete functionality of the stripe payment system. The ios sdk they include only gets you as far as getting a token from a credit card. The web back end is there you would implement the secret key. I use parse.com as my backend for stripe but many implement their own.
Stripe ios Tutorial
Below is a simple httpRequest cloud code that can perform most stripe tasks. Feed it a method, prefix, suffix, postfix, and then the parameters of the request. I'm not saying this is the best way to implement stripe's httpRequests, but it covers the bases for you to start working on it. The code below is tested, and it works, I created a john doe recipient in my stripe test sandbox.
Parse Cloud code:
So when it comes to creating a recipient, you would feed it a method of "POST", and a prefix of "recipients", and leave the suffix, and postfix empty. This would generate a url of such:
In addition to the method & pre/suf/postfix you would need to feed it parameters. You can do this by sending a dictionary of keyed objects. Using Stripe's documentation, lets create a recipient named john doe:
Here is the iOS call of the cloud code using the John Doe example. I have implemented a general method the you pass the method, pre/suf/postfix's and parameters. I then create many additional methods to handle the specific stripe calls, like creating a recipient for example.
ViewController.m
ELStripe.m