Coinbase address callbacks not working? - bitcoin

I'm using the Coinbase API. My app generates new receive addresses with callbacks. However, when BTC arrives at any of those addresses, the callbacks don't seem to be firing.
I've verified that the callbacks are indeed being created for the new addresses, and that my app would respond correctly to the callbacks. For instance, this triggers the desired functionality on my server:
curl --data "address=someaddress&amount=1.2" https://mydomain.com/callback?secret_token=mysecret
Alas, there are no calls being made to my server whatsoever (any call would show up in the logs, but none do).
Anyone using Coinbase address callbacks successfully? Any hints for debugging this?

Have you tried using a json request with php to set the callback url? If you login and look at the addresses section, do you see the correct url in the callback section? Make sure there is no typo. I was able to do this a few months ago but have left the project that did this.

create a php file callback.php
put this code in your callback.php
<?php
$jsonData = file_get_contents('php://input');
$postDatacoinbase = json_decode($jsonData, true);
print_r ($postDatacoinbase);
?>
login into Coinbase and click on " Merchant settings " and
input your http://mydomain.com/callback.php url into callback url
and click test now to see the results .

Related

How to use delegate token for storefront API Shopify?

I made a node application based on storefront API of shopify. However there are rate limit per ip address imposed. Due to this I can execute certain Graphql queries a set amount of time. For example, password reset only works 2 times and after that it show Limit Exceeded error, after which I need to wait for 60 seconds.
The issue is I have deployed application as lambda function and the IP will always be the same. I found the solution on storefront API stating I need to use delegate token and user IP to as header while sending the request. But I did not quite understand.
Can someone please help me how should I use delegate token in my node application, so that the whenever a request is sent it uses the client browser IP instead of the AWS server!
Ok, believe I figured it out.
First thing you to do is create a delegate token using this endpoint (POST).
https://{{shopify_store_name}}.myshopify.com/admin/access_tokens/delegate.json
Your POST should look something like this:
{
"delegate_access_scope": ["unauthenticated_write_checkouts"]
}
I suggest you go into your shopify store front API and view which permissions the storefront API has and use something similar. Note that your admin API needs to at least have those permissions to grant them.
Also note that the customerRecover needs the "unauthenticated_write_checkouts" permission to be called.
After you created that token (And this was the problem I had) REMOVE the X-Shopify-Storefront-Access-Token from your header, and REPLACE it with Shopify-Storefront-Private-Token
Remove:
X-Shopify-Storefront-Access-Token : {{{Storefront Token}}}
and Replace with:
Shopify-Storefront-Private-Token : {{{Your delegate token}}}
You will also need to forward your customers API address in the header by grabbing it out of the context and putting into the header as well
Shopify-Storefront-Buyer-IP' : this.sourceIp
After I did this, I noticed my rate limiting on forgot password was IP based on the client hitting it and not the servers IP being throttled.
Hope this helps!

Shopify : How to test webhooks in php

I am new in shopify. I have created one app in php for shopify. I have registered webhooks using admin apis. But i don't know how to test webhooks. I have spent lots of time to figure out but not getting any proper response. How to get response and write stuff over there?
Is it like Apis? How to notify that webhooks are called or not.
Please help me.
Unlike APIs, Webhook is event driven(triggered on any event e.g. Order Creation) and send data in JSON/XML format to particular URL.
You can create a Webhook in your Shopify store by following steps.
Go to Settings -> Notification -> Webhooks -> Create Webhook
Select Event on which your webhook will be triggered data Format and URL(https) to which you want to send your data.
Now your data is available in JSON format to server location you have shared in URL field. You can use following code.
<?php
define('SHOPIFY_APP_SECRET', 'my_shared_secret');
function verify_webhook($data, $hmac_header){
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
return hash_equals($hmac_header, $calculated_hmac);
}
$hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
$data = file_get_contents('php://input');
$verified = verify_webhook($data, $hmac_header);
error_log('Webhook verified: '.var_export($verified, true)); //check error.log to see the result
?>

How to specify and implement Telegram API methods in Requests?

I am trying simply connect to Telegram API servers and get response.
I've create a app in my.telegram.org, Now I have my api_id, api_hash and also IP address to Telegram api MTproto serever. for getting start documentation says we have to Authorize first using auth.sendCode method to send a code to api user's phone.
so I tried this python script to use auth.sendCode method:
q="auth.sendCode \"phone_number\" 0 api_id \"api_hash\" \"en\""
res = requests.post("http://149.154.167.50:443",data=q)
and when I print res, it says Response [404]. according to the documentation it means An attempt to invoke a non-existent object, such as a method.
I am sure the problem is about my data field in post request. the string I made for calling auth.sendCode method is wrong so server can't recognize what I am trying to reach to.
there is a Query example for that method in documentation :
(auth.sendCode "79991234567" 1 32 "test-hash" "en")
please someone helps me to correct that data string (according to this example). how can I implement API methods in Post Requests?
First steps: Understand how to generate a Telegram AuthKey.
That exercise will help you build up the the basic knowledge need to move tackle Telegram API (and the rest API documentation) on your own.
For starters, i have outlined some of the basics in this SO Post (using vb.net)

How to send request to Telegram bot API?

After creating a telegram bot and gain bot token, I want to send a request to the bot API.
This link says we must send the HTTP request like this:
https://api.telegram.org/bot<token>/METHOD_NAME and brings example for easiest method "getme" which has not any input parameters.
Imagine I want to send some messages. I should use the sendMessage method which has two Required input parameters: chat_ID and text.
Now my Questions begins:
How can I write this sendMessage method in above request format with its parameters? I tried sendMessage(param1,param2) and received method not found message.
What is chat_id? if I want to send a message to the contact, how can I know his chat_id?
I searched a lot on the internet, there are plenty of projects on GitHub especially for this purpose, and honestly none of them makes any sense.
for god's sake someone please help me. I am loosing way.
Regards.
You just send a POST request to:
https://api.telegram.org/bot{token}/{method}
For example:
https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/sendMessage
In the body of the request, you URL encode the parameters:
chat_id=12345&text=hello%20friend
For example, in Python using the requests module:
import requests
response = requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
data={'chat_id': 12345, 'text': 'hello friend'}
).json()
When a user chats with your bot, you get a Message object that has a chat id (and a user id, which you can substitute for a chat id). There's no way to initiate a chat with a user unless you already know their user id, so you have to wait for a user to talk to you. You can simplify that by using deep linking and having the user click on a link that sends a pre-made message when they hit the Start button.
Edit: for those struggling to find chat_id, here's a way:
1.- Create a bot: on Telegram's search look for #BotFather. Click start, write /newbot, give it a name and a username. You should get a token to access the HTTP API. Save this token.
2.- Find your bot on Telegram with its username. Write something to it e.g. 'test'. This will come in handy later.
3.- Print chat_id. Before running this function, make sure that you have at least written one message to your bot on Telegram (step 2)
Javascript code:
var token = "123456:kioASDdjicOljd_ijsdf"; // Fill this in with your token
var telegramUrl = "https://api.telegram.org/bot" + token;
function getChat_id(){
var res = UrlFetchApp.fetch(telegramUrl+"/getUpdates").getContentText();
var res = JSON.parse(res);
Logger.log(res.result[0].message.chat.id.toString());
}
Try this
https://api.telegram.org/bot{token}/sendMessage?chat_id=<chat_id>&text=<Enter your text here>
Example
https://api.telegram.org/bot449123456:AAHSAnSGDm8PW2Z-1ZiwdVDmgv7sM3NMTxg/sendMessage?chat_id=311911234&text=Hi+Everyone

LinkedIn OAuth Request with no Verifier

Introduction:
Hi everyone, i am currently writting a lib to make generic OAuth Requests in C#.
The first part, of getting a Token and a Token secret is working for Twitter and Linkedin already ( RequestTokens ), but as soon as i jump to the Authorization part it does not work for Linkedin,but it does for twitter.
Useful Informations
I am currently using a method to generate AUTHORIZATION_URL for the Request. For Example :
https://api.linkedin.com/uas/oauth/authorize?MyToken
Same for Twitter,using its own url. Both services are getting a correctly generated URL, and the window that pops up when i copy it in the browser is correcly.
After the user hits the button, different things happens depending on the service.
1 - Twitter : The browser redirects me to the Callback Page, and on the url there is a Verifier that i am currently parsing and storing it. Perfect.
2 - LinkedIn : In the sample i have,everything works just as twitter does, but when i use my own lib, there is no redirect for the callback url,instead, i am getting redirected to a url with a oob? tag, and a verifier number is shown in the screen, instead of appearing in the querystring.
Doubt:
What should i do to make sure that the OAuth method i will be using is the Normal one,instead of the Out Of Band method. I am making sure that the CALLBACK URL that i set in the lib, is being used for the Signature on the First Request (REQUEST_TOKEN STEP). Also, twitter works when i do this.
Any idea of whats happening ? Let me know if there is any useful information i can add to make sure that my question will be as complete as possible.
Thanks in advance
I solved it.
I forgot to add the Callback parameter to the Signature in the BaseGenerator,instead, it was commented.
Thanks anyways for everyone