Stripe API

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Nick26
Posts: 27
Joined: Fri Aug 07, 2020 6:59 am
Location: Melbourne, Australia

Stripe API

Post by Nick26 »

I'm trying to integrate a simple (well I thought so...) Stripe API REST into aware IM.

Basically, when a new user signs up, I want it to create a stripe customer.

I've got the cURL code:

https://api.stripe.com/v1/customers \
-u sk_test_aaaa \
-d description="My First Test Customer (created for API docs)"

When submitting the process, its coming up with the error "Service provider returned the following error: { "error": { "message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.", "type": "invalid_request_error" }}"

I have used the "Request HTTP Headers" in the REST settings as instructed, but still no luck.

I'm pretty sure I'll able to integrate attributes, I just can't seem to get past the Authentication

Anyone got any ideas or done this before?
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Stripe API

Post by joben »

Is this oauth?
Which AwareIM version are you on?
Do you have this option when creating a REST channel?
oauth.png
oauth.png (177.13 KiB) Viewed 3450 times
Regards, Joakim

Image
Nick26
Posts: 27
Joined: Fri Aug 07, 2020 6:59 am
Location: Melbourne, Australia

Re: Stripe API

Post by Nick26 »

Well, that's what I thought too. But I tried that, that didn't work...

It says this on Stripes website:

Authentication to the API is performed via HTTP Basic Auth. Provide your API key as the basic auth username value. You do not need to provide a password.

If you need to authenticate via bearer auth (e.g., for a cross-origin request), use -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" instead of -u sk_test_4eC39HqLyjWDarjtT1zdp7dc.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

https://stripe.com/docs/api/authentication
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Stripe API

Post by joben »

Do you use an API tool like Postman to test your requests?
https://www.postman.com/
If not, it is highly recommended for troubleshooting!
I usually think of it this way: If you can't get it to work in Postman, It will not work in AwareIM.
Regards, Joakim

Image
Nick26
Posts: 27
Joined: Fri Aug 07, 2020 6:59 am
Location: Melbourne, Australia

Re: Stripe API

Post by Nick26 »

Wow postman is great!

The type of authentication its using is Bearer. Not sure how to authorise that in Aware though.

Couldn't get the OAuth to work in postman
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Stripe API

Post by joben »

I don't think this type of authentication is classified as OAuth. I was wrong before.
Here is what I did for it to work in Postman:

1. Added the bearer token, sent a request, it worked:
bearer1.png
bearer1.png (70.06 KiB) Viewed 3441 times


2. Looked at the actual headers and displayed the hidden ones, this is what you should enter in AwareIM:
bearer3.png
bearer3.png (56.28 KiB) Viewed 3441 times


3. This is where I believe the key should be placed in AwareIM (I have not tested this yet but it should work):
bearer2.png
bearer2.png (112.98 KiB) Viewed 3441 times
Good luck!
Regards, Joakim

Image
Nick26
Posts: 27
Joined: Fri Aug 07, 2020 6:59 am
Location: Melbourne, Australia

Re: Stripe API

Post by Nick26 »

Got it working, thanks heaps!
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Stripe API

Post by hpl123 »

I would be very interested in either getting this integrated in some way in Aware or a document or sample with all that is needed to use the Stripe API in Aware apps. I would pay for that and I am sure others would as well.

The solution should be able to handle all aspects of charging (only charge and all things required to make that work like create customer in Stripe account, add CC details to customer, changing CC details for customer, charge x amount etc.. Things like refunds is not needed) users via Stripe (without storing credit card information "locally" in an Aware DB).

Anyone feel up to the task of this or maybe already have it working and would consider selling a document or sample detailing how to get this up and running?
Henrik (V8 Developer Ed. - Windows)
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Stripe API

Post by joben »

Have had similar thoughts hpl123.

I imagine a future with free and paid API sample .bsv's connected to popular services such as Mailchimp, Azure, various RMM and ERP systems.
Basically, you import the .bsv package and just enter your own API keys and parameters and you have saved tons of hard work.
AwareIM could have its own marketplace on the website with their own API packages as well as those made by third parties (its many talented users).
Regards, Joakim

Image
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Stripe API

Post by hpl123 »

joben wrote: Wed Jan 12, 2022 8:27 am Have had similar thoughts hpl123.

I imagine a future with free and paid API sample .bsv's connected to popular services such as Mailchimp, Azure, various RMM and ERP systems.
Basically, you import the .bsv package and just enter your own API keys and parameters and you have saved tons of hard work.
AwareIM could have its own marketplace on the website with their own API packages as well as those made by third parties (its many talented users).
Ditto, would be great!
Henrik (V8 Developer Ed. - Windows)
Post Reply