Rails: Setting Up Stripe Webhook - ruby-on-rails-3

I have stripe all set accepting payments and the stripe_event gem installed. In the docs for the gem it says to just do something like this in routes.rb:
mount StripeEvent::Engine => '/stripe'
but that is failing to show anything at that route. What else do I need to do to get the webhook working in my development environment? Is it even possible? (I did set the stripe webhook to be sent to 0.0.0.0:3000 but I am sure that is wrong.
Thank you!

For anyone else trying to receive webhooks on localhost with a Rails application I highly recommend this tool I just came across. Setup and running in seconds:
http://www.ultrahook.com

The webhook endpoint you set with Stripe needs to be a live url, not 0.0.0.0 or localhost. The routes appear to be setup correctly. You can test locally using curl:
$ curl -X POST -H "Content-type: application/json" -H "Accept: application/json" -d '{"id":"evt_REPLACEME"}' localhost:3000/your-webhook-path

Related

user authentication in wso2 via curl

I need to authenticate admin user via curl command so I can pragmatically add,delete, modify users in wso2
I can call the api end points for user add/mod/delete no problem. But without being able to first authenticate to wso2 it is all for naught. When I send the curl command I get no response back, and nothing shows in the logs.
This is my basic curl command, right out of the books:
curl -X POST "https://xxxxxxx.com:9443/login/portal" -H "Content-Type: application/x-form-urlencoded" -d "username=uid&password=foo&grantType=password"
You can use SCIM APIs with basic authentication to manage users.
If you want to use OAuth2 tokens, you can get them like this.
curl -k -d "grant_type=password&username=<username>&password=<password>"
-u <Consumer_key>:<Consumer_secret>
-H "Content-Type: application/x-www-form-urlencoded"
https://localhost:9443/oauth2/token
[1] https://docs.wso2.com/display/IS530/SCIM+1.1+APIs

How do I solve this RabbitMQ REST call 415 response issue?

In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of
{"read":".*","write":".*","configure":".*"}
and an HTTP header Content-Type:application/json;charset=UTF-8
This all looks reasonable to me - but the response is
HTTP/1.1 415 Unsupported Media Type
This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...
I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.
Any suggestions what is wrong?
It turned out that the Apache HttpClient was adding a second content-type header to the message, caused the rejection on RabbitMQ Management plugin.
Yes, content type should not be applied
curl -s -i -u guest:guest -H "content-type: application/json" -H "content-type: application/json" -X POST --data '{"properties":{"delivery_mode":2},"routing_key":"program.*","payload":"{\"id\":\"123456\"}","payload_encoding":"string"}' 'http://127.0.0.1:15672/api/exchanges/%2F/my-exchange/publish'
return HTTP/1.1 415 Unsupported Media Type
Without content-type or just one :
curl -s -i -u guest:guest -H "content-type: application/json" -X POST --data '{"properties":{"delivery_mode":2},"routing_key":"program.*","payload":"{\"id\":\"123456\"}","payload_encoding":"string"}' 'http://127.0.0.1:15672/api/exchanges/%2F/my-exchange/publish'
return HTTP/1.1 200 OK

Google FCM - can not subscribe to topic - returns 502 or "error INTERNAL"

Trying to subscribe device token to a topic on server. According to FCM server docs proceeding the request:
curl --header "Authorization: key=AAAA...qC1GXg" \
--header "Content-Type:application/json" \
-X POST -d '{}' \
"https://iid.googleapis.com/iid/v1/BY7kK...rbZ/rel/topics/mytopic"
which returns :
502. The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds
The same 502 is returned when I'm trying to get token info with "details" parameter, like this:
curl --header "Authorization: key=AAAA...C1GXg" \
"https://iid.googleapis.com/iid/info/BY7kK...rbZ?details=true"
While if not adding "details" parameter, it all ok - it returns 200 and json data:
{"applicationVersion":"24","attestStatus":"UNKNOWN","application":"com.my.app","scope":"*","authorizedEntity":"...","appSigner":"...","platform":"ANDROID"}
I have also tried a batchAdd:
curl --header "Authorization: key=AAAA...81GXg" \
--header "Content-Type:application/json" \
-X POST \
-d '{"to":"/topics/mytopic", "registration_tokens": ["BY7k...rbZ"]}' \
"https://iid.googleapis.com/iid/v1:batchAdd"
and it ends up with :
{"results":[{"error":"INTERNAL"}]}
Authorization key and device token I use should be OK, since I can get token data (without topics), and sending messages to that device (also using curl) works OK.
Still, this 502 is happening for more than 24h for me so far.
That's a new FCM project - I'm not migrating from GCM or anything. Android app is live on market for some time, but I haven't used cloud messaging there before.
Any ideas with what could be wrong here? Thank you.
Found the cause. In case if someone will make the same mistake:
My Android app is published under one Google account, while I have created a project in Firebase console under a different account.
Having the app and Firebase project under same Google account - and all works like a charm.
Meanwhile, Google maps API keys, which also are used in my Android app, were generated under that second account, and everything is OK.

How to cURL an `https://` URL from OpenShift container

Following up on my earlier question, I realized that even if I SSH into my OpenShift container and attempt to manually cURL an HTTPS URL, it seems to get internally re-routed to the HTTP equivalent. How can I actually access the HTTPS version?
From my local machine:
$ curl -X POST -H “Authorization: Basic <TOKEN>” -H “Content-Type: application/x-www-form-urlencoded” -H “Content-Length: 0” https://api.stubhub.com/login
{”error”:”invalid_request”,”error_description”:”Missing grant_type parameter value”}
And from my remote machine (via SSH):
> curl -X POST -H “Authorization: Basic <TOKEN>” -H “Content-Type: application/x-www-form-urlencoded” -H “Content-Length: 0” https://api.stubhub.com/login
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
You don't have permission to access “http://api.stubhub.com/login” on this server.<P>
Reference #18.63de6bd1.1459386064.30c676b
</BODY>
</HTML>
Note the http URL in the latter's response body.
(And of course, I'm using a working/tested <TOKEN>.)
You should contact stubhub and see if they are blocking the ip address(es) that you are attempting the connection from. I am able to curl other https url's from OpenShift Online without any issues.

How to get Authorization Token for Ceilometer API Openstack

I am new to openstack, trying to use Ceilometer python API to pull some data from a testbed server, I am accessing the server from a remote site
the problem is that I cannot figure out how get the an authorization token
I used the following command
curl -i 'http://HOST:8774/' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d/tokens auth": {"tenantName": "project", "passwordCredentials": {"username": "user", "password": "password"}}}'
But it does not give me anything,
curl -X GET -H "X-Auth-Token:$MY_TOKEN" http://HOST:8774/tokens
also does not give me any token
From your use of port 8774 I suspect you might be using DevStack. Try this
curl -s -X POST http://$OPENSTACK_KEYSTONE_HOST:5000/v2.0/tokens -d '{"auth": {"passwordCredentials": {"username":"my-username", "password":"my-password"}, "tenantName":"my-tenantName"}}
In DevStack Keystone (the auth service you get tokens from) is running on port 5000 by default. This may or may not be true in your case. Ask your friendly OpenStack operator what host (and port) Keystone is running on and put that in place of $OPENSTACK_KEYSTONE_HOST:5000