When you show a buy button on Facebook the callback to your bot is an "invoke". Details here [Show the buy button and process the payment on facebook messenger with Bot Framework
It is up to the bot to respond to FB with a 200 for success or something else for a failure. No matter what response I've sent Facebook processes the request as if it were successful.
v3.0 of the bot framework with the C# Connector SDK
I've attempted:
Standard reply:
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity replyToConversation = activity.CreateReply();
replyToConversation.Recipient = activity.From;
replyToConversation.Type = "invoke";
connector.Conversations.ReplyToActivity(replyToConversation);
or
return Request.CreateResponse(HttpStatusCode.InternalServerError);
or
return Request.CreateErrorResponse(...);
or
return null;
I've also forced the Controller to respond with an error by throwing a new exception.
There was a suggestion to rely using channelData however channelData seems to only support attachment type replies and what is needed here is a direct reply to the Payment request.
How do I correctly respond to FB to indicate the payment was NOT successful?
Related
i am working with Facebook Checkbox Plugin everything is working fine and I am able to render the plugin. My problem is that facebook is not sending request to my webhook url when Confirming Opt-in. in the facebook docs it is mentioned that
After the opt-in event, we will post a webhook event to your server
if the checkbox state was checked. This callback has the same format
as the opt-in callback, but instead of a sender field, it has an optin
object with a user_ref field.
my code for subscribing to the webhook is .
if request.method=='GET':
try:
myfb_token='xxxx'#to go to settings
if self.request.query_params['hub.mode']:
if self.request.query_params['hub.verify_token']==myfb_token:
res=int(self.request.query_params['hub.challenge'])
status_code=200
else:
status_code=422
res={"unable to verify"}
except Exception as e:
res={"invalid request"}
status_code = 422
return Response(res, status=200)
else:
print(request.data)
return Response("webhook posts", status=200)
This works fine and am able to subscribe. Am also able to test my webhook and hit my server from my app . However the webhook does post to my server when the plugin is checked. My app is still in development mode and am using my facebook account for testing as an admin.
I have also subcribed to the messaging_optin webhook
I am trying to use Sender Actions as described in the messenger Send API docs. However when I send a typing_on POST I do no see anything happen in messenger. I have tried on chrome desktop and the messenger android app.
I am able to send a mark_seen POST and this does update the chat with an icon indicating my message has been seen.
The request body looks as follows:-
{
"recipient":{
"id":"<PSID>"
},
"sender_action":"typing_on"
}
When sending mark_seen, typing_on or typing_off I always get the following response body.
{
"recipient_id": "<PSID>"
}
Are there additional steps needed to get the typing indicator to display? Does it only work on a specific platform? I cannot find any more documentation, and I am not getting any error messages, the POST status comes back OK identically when sending mark_seen or typing_on, I just can't see any effect after typing_on.
Okay I got reply from Facebook developer team on Facebook Developers group
Quote:
"This changed recently for mobile and is currently assigned to an internal team". Looks like something internal.
I have created an Ionic app. I have some items to order. Payment is done using Paypal. I have called a web url using window.open(url) which is redirecting me to the Paypal.
I'm able to do the payment successfully, but Can anyone please let me know how I can come back to my ionic app after successful payment.
Note: I have not used Paypal plugin as it is not developed for windows
Few days back even i was facing the same issue, i was able to do payment where the ionic app drags to the third party api but after the payment it was not redirecting to the ionic app in the mobile/smartphone.
after soing dome R and D i got the solution that when the app is running on the mobile it will not be having any port number running on i,e., http://localhost/dashboard instead of http:localhost:8100/dashboard, where 8100 is the port number running for the ionic server.
after specifying the return back url as http://localhost/dashboard i was able to redirect back to the ionic app.
Use loadsart event of the InAppBrowser to catch the urls when load pages after payment was done. Then you can process your tasks according to those urls and their parameters as you prefer. As an example, when you have the payment successful url you can navigate back to your app after closing the open browser. Also you can have the data passing back when the payment is success or fail, into your application using this way. Hope this will help to you.
addEventListener('loadstart', function(event) { var currentUrl = event.url /*do the rest according to the url inside your application */});
I just add a pseudo-code below.
browserRef.addEventListener('loadstart', function(event) {
var param = getParameters(event.url); //Read the parameters from the url
if (isCorrectParameters(param)) { //Check parameters agaist the payment gateway response url
browserRef.close(); // colse the browser
//Handle the success and failed scenarios
if(success){
$state.go('test');
}else{
// handle fail scenario
}
}
});
I have fully integrated my website with paypal using paypal RESTful's API PHP SDK. Now my problem is every once in a while on the payment process, once the user approves the payment and it comes back to my website for execution, the API execution request comes back with the following responses from paypal. The HTTP response code's in these scenarios are 400 and 500. Below I have listed the error name and error message which comes as a part of the JSON response I get form paypal on execute action (https://api.paypal.com/v1/payments/payment/PAY-xxxxxxxxxxxxxxxxxxxxxxxxxx/execute):
400 PAYMENT_NOT_APPROVED_FOR_EXECUTION,Payer has not approved payment
500 INTERNAL_SERVICE_ERROR,An internal service error has occurred
In terms of the code I use to make that call I have added the function which executes the payment. I should add that this is working in 98% of times. Below is the code:
public function getExecute()
{
// Payment is cancelled
if (!(Input::get('success') && Input::get('success') == 'true'))
return $this->runPaymentExitProcess();
// No paymentId
if (!Session::has('paymentId'))
return "No payment id to execute";
$paymentId = Session::get('paymentId');
$this->payment = Payment::get($paymentId, $this->apiContext);
// The payer_id is added to the request query parameters when the user is redirected from paypal back to your site
$this->execution->setPayer_id(Input::get('PayerID'));
$response = $this->payment->execute($this->execution, $this->apiContext);
// Check for paypal errors
if (isset($response->name)) {
// When we have a paypal error
if ($this->hasPaypalError($response)) {
$error = array('name' => $response->name, 'message' => $response->message);
Session::put('error', $error);
return (MODE == 'LIVE') ? Redirect::to('/paypalerror') : Redirect::to('/paypalerror'.MODE_PARAM);
die;
}
}
// Unset session
Session::forget('paymentId');
// execution successful
if ($this->addPaymentIdToUser($paymentId))
return (MODE == 'LIVE') ? Redirect::to('/') : Redirect::to('/'.MODE_PARAM);
}
The code is in laravel. Please note that the $this->apiContext is set in the constructor of the class. Also this is the function is the success url which is set in the API under redirect_urls.
Can someone please help me figure out if this issue is coming from my side or Paypal's side?
For the 400 error, this would occur if the user decided not to approve the payment. If you think the payment was actually approved in the web flow then that would be an issue to look into further.
Can you provide the debugId and approximate time (with timezone, or GMT) of a 500 internal server error response, and a 400 if you believe the payment was actually approved by user.
I'm trying to send an apprequest from my Windows Phone 7.5 application to a Facebook friend to invite that friend to play a gameround.
According to Facebooks official documentation, a request should be performed via dialogs:
https://developers.facebook.com/docs/reference/dialogs/requests/
Unfortunately I cannot get this to work/show on Windows Phone.
Is there another way to send an apprequest to a known facebook user (I only need to send it to one user)?
I have tested to do it by invoking the following code:
FacebookClient fb = new FacebookClient(_appAccessTooken);
var arguments = new Dictionary<string, object>();
arguments["appId"] = Consts.FaceBookAppID;
arguments["title"] = "Play a gameround!";
arguments["message"] = "Would you like to play with me?";
fb.PostAsync("/user-id/apprequests", arguments);
This works, but:
1) The user will not get a proper notification, it will only be visible from the Applicationcenter notices.
2) The request will be sent from the application name, not from me (the user)
Does anybody know how to get this working?
II'm using the Facebook SDK for .NET (http://facebooksdk.net/)
Thanks in advance.