Pass additional parameter to paypal button url - paypal

I created a paypal button to manage my subscriptions and I´m planning to use it with my own link. Im not using the javascript SDK
Pay now
I was able to find that you can pass the &custom=123 parameter
but when I fetch a single subscription with
https://api-m.paypal.com/v1/billing/subscriptions/123
I don´t see the value of custom but I do see it in the POST request to my IPN endpoint. that means Paypal is sending it.
how can I see this custom value in the subscription itself? thank you!

Either: change to using a JavaScript SDK subscribe button and provide your value in the createSubscription's custom_id field
Or: continue using the legacy Subscribe button/link and try querying a v1/payments sale or v2/payments capture using a completed transaction ID for the subscription (not a profile ID), which might map to containing that legacy Subscribe transaction's custom value

Try this
<button onclick="pay()">Pay now</button>
<script>
function pay() {
$.ajax({
url: "https://www.paypal.com/cgi-bin/webscr",
type: "get",
data: {
cmd: _s-xclick,
hosted_button_id: 0000,
custom: 123
},
success: function(response) {
//Do Something
},
error: function(xhr) {
//Do Something to handle error
}
});
}
</script>

Related

Zapier Rest Hook Subscription - How to get target options?

I am writing my first API integration with Zapier. I have created a trigger using a REST hook, and the trigger is firing correctly, but I am not sure how to determine what trigger option the user selected in Zapier. Specifically I allow them to choose a landing page, and unless I know WHICH landing page they want to activate the trigger I don't know how to handle it, but all I get back from Zapier on the subscription is this:
{
"subscription_url": "https://hooks.zapier.com/hooks/standard/102653/94703dc5c31247c4acb8b82977fd08dc/",
"target_url": "https://hooks.zapier.com/hooks/standard/102653/94703dc5c31247c4acb8b82977fd08dc/",
"event": "landing_page_submitted"
}
I know I am probably missing something. Should I expect to find the option selected in the trigger dropdown somewhere? Or do I need to configure something on the Zapier side to handle it?
David here, from the Zapier Platform team.
If I'm understanding you correctly, you just need to pass the data in from inputData.
In your hook subscription, there's a place to pass data (such as "event" above). You can add something like landing_page: bundle.inputData.landing_page. There's a more complete example here:
const subscribeHook = (z, bundle) => {
// bundle.targetUrl has the Hook URL this app should call when a recipe is created.
const data = {
url: bundle.targetUrl,
style: bundle.inputData.style
};
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: 'http://57b20fb546b57d1100a3c405.mockapi.io/api/hooks',
method: 'POST',
body: JSON.stringify(data)
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options)
.then((response) => JSON.parse(response.content));
};

How to access response from Paypal Express Checkout?

I am integrating PayPal Express Checkout as shown here.
https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/basic-integration/
I am processing the payment successfully, when the transaction has been authorized I am using actions.payment.get(); to get the information about the transaction.
This returns an object called SyncPromise with all the data I want to use.
console screenshot here
I have tried:
var response = actions.payment.get();
response.value
But I get undefined.
Does anyone how can I access the object element?
You need to call like so:
actions.payment.get().then(function(data) {
console.log(data);
});

New facebook payment flow "App not allowed to use new flow."

I've been attempting to implement the new facebook payment flow for local currency as per their documentation (https://developers.facebook.com/docs/howtos/payments/)
Have the company set up, have the product set up, have the payment FB.ui call set up, have the payments callback set up as required for it.
The issue I have is as soon as I call the FB.ui method to invoke a pay dialogue I get the error "Your Action Could Not Be Processed" on screen. Then once I hit ok my javascript callback gets the error message "App not allowed to use new flow." error code "1383005". I can't seem to find any help about this error message or error code (the error code is listed as "PermissionDenied - Facebook system issue" in the Error codes section). My question is am I missing something? There is nothing I can see in the docs that tells me how to allow my app to use the new flow or even telling me that I have to.
My payment dialogue code just in case:
var purchaseProduct = function (productUrl, callback) {
var obj = {
method: 'pay',
action: 'purchaseitem',
product: productUrl
};
FB.ui(obj, function(response) {
callback(response);
});
};
(The quantity and request_id parameters are optional)
Thanks

Facebook UI, how to check if a user can send facebook message to another user

I want to follow up this question. I use FB.ui to send link and got exactly the same error for some users. Is there anyway to check it and decide whether to display the ui to the user ?
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Viewer cannot message specified recipients.
<a href='#' onClick="
FB.ui({
method: 'send',
link: 'http://www.xxxxxxxxxxx.com',
to: ###########,
});
">Send a message</a>
Even when I use the url send method, some user does not work. For example:
Error User : https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=100000104626944
Normal User: https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=1311251197
(this is the share link example taken from https://developers.facebook.com/docs/reference/dialogs/send/)
bug reported to facebook: https://developers.facebook.com/bugs/538638372825668
Edit: in fact, everyone should be reachable through messages now. It's only there are new "filtering preferences". I guess this can_message field is now useless because it should always return true. I think it is going to be deprecated in a while.
In the user FQL table, you have a field that must verify what you need:
can_message (boolean): whether the user can send a message to another user
Source: https://developers.facebook.com/docs/reference/fql/user
select can_message from user where uid=USER_ID
USER_ID being the person that your app user want to send a message to.
You can use the FB api;
I use something like:
FB.api('/me/permissions', function (response)
{
//check contents of response for required permissions here
fb_publish_perm = response.data[0]['publish_stream'] ? response.data[0]['publish_stream'] : false;
if (fb_publish_perm)
{
// it permissions exist
}
else
{
// permissions dont exist launch the ui to request.
}
});
Please treat the above as psedo code, as it came straight off the top of my head!

Is it possible to get the number of users messaged by the send dialog

I'm wondering if its possible to retrieve the number of people/friends messaged by a user when they use the 'send dialog' to send specific friends a messages (just a number is ok). I've been looking through the documentation for the send dialog but it doesn't seem to have any information regarding this.(https://developers.facebook.com/docs/reference/dialogs/send/).
An alternative I can think of at this stage would be to use the graph API, but then I'd need to know the messageID of the message the user just sent.
yes you can get the count
first :you should know when user sent a message Check the link below
here is a sample for you
to test it :
http://www.fbrell.com/saved/d002a25a351e6b01b0526b2606b48750
<script>
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
},
function(response) {
if (response) {
alert('message sent.');
} else {
alert('not sent');
}
}
);
</script>
second:use jQuery & via jquery load ($().load('page.php');
you can save who sent message with uid & of course you can get count every time you want