MercadoPago custom checkout throughs ""customer not found " error - javascript

I am working with mercadoPago Api of custom checkout. Firstly, i created a customer on mercado Api against my access token, then created a card token from the information user enter i.e card_number, security code etc, and finally i send a post request on mercadoPago payment Api by using customer email and card token but return error of "customer not found".
My request
{
"transaction_amount": 100,
"token": "2fe6477a6b238e2e90b055f5ad1f3735",
"description": "Title of what you are paying for",
"installments":1,
"payment_method_id": "visa",
"payer": {
"email" : "test#test.com"
}
}
and the response is
{
"message": "Customer not found",
"error": "bad_request",
"status": 400,
"cause": [
{
"code": 2002,
"description": "Customer not found",
"data": null
}
]
}
the url is
https://api.mercadopago.com/v1/payments?access_token=my_access_token

Related

Whatsapp message api not support interactive single product message

i've created online facebook store and catalog but for some reason I'm unable sending single product interactive message.
Anyone can help me understand what am i missing?
endpoint https://graph.facebook.com/v13.0/MY_ID/messages
request:
{
"messaging_product": "whatsapp",
"to": "xxxxxxx",
"recipient_type": "individual",
"type": "interactive",
"interactive": {
"type": "product",
"body": {
"text": "text-body-content"
},
"footer": {
"text": "text-footer-content"
},
"action": {
"catalog_id": "zzzzzz",
"product_retailer_id": "wwww"
}
}
}
response:
{
"error": {
"message": "(#131009) Parameter value is not valid",
"type": "OAuthException",
"code": 131009,
"error_data": {
"messaging_product": "whatsapp",
"details": "Interactive Message type, 'product' not supported. Supported types ['button', 'list']"
},
"error_subcode": 2494010,
"fbtrace_id": "AFhn57y_es2_yWcQpsm6c2S"
}
}

How to send FB custom payload from webhook to dialogflow v2 then to FB server?

How to send FB custom payload from webhook to dialogflow v2 then to FB server?
I want to send below FB response JSON object from webhook to dialogflow server then it will send to FB server. But unable to find build in method of dialogflow v2 to send response object from webhook to dialogflow then to FB messenger user.
Response Object :-
{
"fulfillmentText": "displayed&spoken response",
"fulfillmentMessages": [
{
"text": [
"text response"
]
}
],
"source": "example.com",
"payload": {
"facebook": {
"text": "Hello, Facebook!"
}
},
"outputContexts": [
{
"name": "projects/${PROJECT_ID}/agent/sessions/${SESSION_ID}/contexts/context name",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"followupEventInput": {
"name": "event name",
"languageCode": "en-US",
"parameters": {
"param": "param value"
}
}
}
the above FB response object taken from dialogflow v2 documentation but unable to find build in method to send that response object from webhook to dialogflow then to FB messenger.

Recurring payments through Paypal's Express Checkout REST API

My goal is to set up recurring 6 and 12 month subscriptions using "paypal" as the payment method for our SaaS. I'm using the rest API, and the one thing I can't find is a working implementation for how to take a one time sale and re-work my code into a recurring payment using PayPal's rest API (which I've read is now possible). Here's where we are at:
I have a working advanced server integration for making payments with Paypal's Express Checkout REST API.
I created the one time sale by following the code examples as explained at the above link as well as what's shown in this example from paypal. I've tried to switch out the two step process to instead include the billing-agreement creation and execution calls, but light window that opens up to have users sign in to paypal is stopping short with the error message "Things don't appear to be working at the moment. Please try again later". Here's my javascript code, which is almost exactly the same as the working example, but with different routes.
paypal.Button.render({
// Set your environment
env: 'sandbox', // sandbox | production
// Wait for the PayPal button to be clicked
payment: function(resolve, reject) {
// Make a call to the merchant server to set up the payment
console.log("button clicked")
return paypal.request.post('/payment/paypal/subscription', {amount: '0.02'})
.then(function(res) {
resolve(res.payToken); #--WHERE I'M GOING WRONG
})
.catch(function(err) { reject(err); });
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data) {
// Make a call to the merchant server to execute the payment
return paypal.request.post('/payment/paypal/execute', {
data: data,
paymentID: data.paymentID,
payerID: data.payerID
}).then(function (res) {
if (res.state == "active") {
document.querySelector('#paypal-button-container-server').innerText = 'Payment Complete!';
} else {
console.log(res);
alert("Payment could not be approved, please try again.")
}
});
}
}, '#paypal-button-container-server');
I can tell that I'm going wrong in the payment function, namely on the line with resolve(res.payToken). I don't know what piece of data from the v1/payments/billing-agreements response I should be passing to this function, but have tried both the profile_id and the approval_url (the actual href - "href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXXXXXXXX").
Where am I going wrong? If this is possible, I feel like I'm one working example away from making this work, but I'd like to know if it's not capable the way I'm doing it (in which case it might need to be done via Payflow?).
Note: I fully understand billing agreements and billing profiles, and my problems are not with the REST API. In addition to the working one-time sale implementation, I can make all necessary billing profile/agreements (verified through Postman).
Below is the response from a v1/payments/billing-agreements sandbox call in the event anyone can point out the right piece of data inside of it.
{
"name": "Magazine Subscription",
"description": "Monthly subscription with a regular monthly payment definition and two-month trial payment definition.",
"plan": {
"id": "P-XXXXXXXXXXXXXXXXXXX",
"state": "ACTIVE",
"name": "1 Month Recurring",
"description": "A recurring payment plan for customers who sign a 1-month contract",
"type": "FIXED",
"payment_definitions": [
{
"id": "PD-924GIUJ3MWQ32E22348G0018",
"name": "Regular Payment Definition",
"type": "REGULAR",
"frequency": "Month",
"amount": {
"currency": "USD",
"value": "150"
},
"cycles": "1",
"charge_models": [
{
"id": "CHM-940183BIUJ3MWQ5VK14226VH",
"type": "TAX",
"amount": {
"currency": "USD",
"value": "10"
}
}
],
"frequency_interval": "1"
},
{
"id": "PD-5604RIUJ3MWQ4Y4221782C61",
"name": "Trial Payment Definition",
"type": "TRIAL",
"frequency": "Month",
"amount": {
"currency": "USD",
"value": "120"
},
"cycles": "1",
"charge_models": [
{
"id": "CHM-640401IUJ3MWQ64W07759LB2",
"type": "TAX",
"amount": {
"currency": "USD",
"value": "10"
}
}
],
"frequency_interval": "1"
}
],
"merchant_preferences": {
"setup_fee": {
"currency": "USD",
"value": "0"
},
"max_fail_attempts": "3",
"return_url": "http://localhost:8000/payment/success",
"cancel_url": "http://localhost:8000/payment/new",
"auto_bill_amount": "NO",
"initial_fail_amount_action": "CONTINUE"
}
},
"links": [
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXXXXXXXXX",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-XXXXXXXXXXXXX/agreement-execute",
"rel": "execute",
"method": "POST"
}
],
"start_date": "2017-12-22T09:13:49Z"
}
The REST API's still pass back the express checkout URL's but in order to use it with the checkout.js front end integration you need to pass back the token found within the approval URL. You can either parse this URL and get the token section on the server and return it back or pass it before you call resolve method.
i.e.
approval_url = {
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXXXXXXXXX"
}
var token = "EC-XXXXXXXXXXXXX";
resolve(token);

Node ARI Client | Connect method not firing callback?

So, I've started playing with the Asterisk Restful Interface (ARI).
I have created a separate express app to do this.
I have a correctly configured instance of Asterisk 13 running. I know this because When I go to https://192.168.46.122:8088/ari/sounds in my browser, I am prompted for a username and password, which when entered, returns a valid JSON object back with the expected data...
[
{
"id": "conf-now-unmuted",
"text": "The conference is now unmuted.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-nomore",
"text": "No more messages.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-review",
"text": "press 1 to accept this recording press 2 to listen to it press 3 to rerecord your message",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "demo-echodone",
"text": "The echo test has been completed.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "confbridge-rest-talk-vol-out",
"text": "...to reset your speaking volume to the default level.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
}, ...... etc etc
In my app.js file I have included the following code...
...
var logger = require('morgan');
var client = require('ari-client');
var url = 'https://192.168.46.122:8088/ari/sounds';
var username = 'correct_username';
var password = 'correct_password';
client.connect(url, username, password, function (err, ari) {
console.log('HELLLLLLOOOOO!!');
});
...
The issue, is that the anon callback is never fired. I never see 'HELLLLLLOOOOO!!'
Can anyone shed any light on why/under what circumstances this could happen? Are there any known bugs with the module that could be causing this?
Please let me know if you need further information about config, environment etc.
Thanks guys
UPDATE
Following comments below... I have tried the following:
client.connect(url, username, password)
.then(function(ari) {
console.log('HELLLLLLOOOOO!!');
})
.catch(function(err){
console.log('ERR: ' + err);
});
AND
client.connect(url, username, password, function (err, ari) {
if(err) console.log(err);
console.log('HELLLLLLOOOOO!!');
});
No error and no 'HELLLLLOOOOOO!!' at any point :-(
UPDATE 2
Have just visited /ari/api-docs/resources.json and got the following response... so it looks like it is present.
{
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
"_author": "David M. Lee, II <dlee#digium.com>",
"_svn_revision": "$Revision: 430337 $",
"apiVersion": "1.7.0",
"swaggerVersion": "1.1",
"basePath": "http://192.168.46.122:8088/ari",
"apis": [
{
"path": "/api-docs/asterisk.{format}",
"description": "Asterisk resources"
},
{
"path": "/api-docs/endpoints.{format}",
"description": "Endpoint resources"
},
{
"path": "/api-docs/channels.{format}",
"description": "Channel resources"
},
{
"path": "/api-docs/bridges.{format}",
"description": "Bridge resources"
},
{
"path": "/api-docs/recordings.{format}",
"description": "Recording resources"
},
{
"path": "/api-docs/sounds.{format}",
"description": "Sound resources"
},
{
"path": "/api-docs/playbacks.{format}",
"description": "Playback control resources"
},
{
"path": "/api-docs/deviceStates.{format}",
"description": "Device state resources"
},
{
"path": "/api-docs/mailboxes.{format}",
"description": "Mailboxes resources"
},
{
"path": "/api-docs/events.{format}",
"description": "WebSocket resource"
},
{
"path": "/api-docs/applications.{format}",
"description": "Stasis application resources"
}
]
}
I'm now thinking it may be an SSL issue?!
Your connection is failing (for reasons outlined below), and because of an issue / upcoming-feature in node-ari-client, the failed connection is not logged.
The node-ari-client module uses Swagger, which expects to load a JSON schema describing an API. In the node-ari-client implementation, Swagger expects to find this JSON schema at %s//%s/ari/api-docs/resources.json.
So, the first thing to check is whether or not this exists / is accessible in your application:
https://192.168.46.122:8088/ari/api-docs/resources.json
There could be several reasons why this would not be available, but most likely the problem is authentication. You mention that when visiting your URL you are "prompted for a username and password". If your JSON schema (or any other files that need to be accessed without credentials) are behind authentication, you are going to need to rethink your application structure.
Currently, if there is a connection failure before Swagger has loaded the JSON schema, node-ari-client will fail silently. There is a Pull Request waiting which addresses this issue and would log the error, but in the meantime you should address the underlying issues which are preventing the connection.
If you can successfully access resources.json, there may be other issues with accessing resources. The URL you describe is accessing your service over https, but your resources.json file is telling Swagger to access it over regular http. To handle this, you could try:
Changing the basePath in your Swagger schema to use https:
"basePath": "https://192.168.46.122:8088/ari",
Adding a protocols field to your Swagger schema:
"protocols":["http", "https"]
Removing https
This is probably a good option in order to discover if https is the cause of the connection issue. Simply keep the Swagger schema exactly as is and try accessing / connecting to your services over http. Does this make a difference?

"Invalid project" error form Google API Javascript client

I am starting to play with Google Cloud DNS and I would like to hack a small Javascript project for listing/editing zones / resourceRecords.
I started on the "Getting Started" page which explains and offers some samples of the JS query/edit process. The thing is I got at some point where Google API responds with and "Invalid project" error for all supplied values of the 'project' parameter. I am using the clientID for the web application from the Google Developer Console for the oAuth part. The project name I am using is the string named PROJECT ID in google (the same one I am using successfully in the gcloud command-line tools or the on-line JS testground).
According to this: https://content.googleapis.com/discovery/v1/apis/dns/v1beta1/rpc the dns.resourceRecordsSets.list requires two parameters: managedZone and project. If I do a call without params I get this:
[
{
"error": {
"code": 400,
"message": "Required value: managedZone",
"data": [
{
"domain": "global",
"reason": "required",
"message": "Required value: managedZone"
},
{
"domain": "global",
"reason": "required",
"message": "Required value: project"
}
]
},
"id": "gapiRpc"
}
]
which is perfectly fine...
Next I add the project and the managedZone params and then I get this:
[
{
"error": {
"code": 400,
"message": "Invalid parameter: project",
"data": [
{
"domain": "global",
"reason": "invalidParameter",
"message": "Invalid parameter: project",
"locationType": "parameter",
"location": "project"
}
]
},
"id": "gapiRpc"
}
]
Here is my API call code.... I also tried checking the JS code from Google with no success in finding the "Invalid parameter" code...
gapi.client.load('dns', 'v1beta1', function() {
var request = gapi.client.dns.resourceRecordSets.list({
'project': 'lolName',
'managedZone': 'lolZone'
});
request.execute(function(resp) {
console.log(resp);
if (resp.code == 200) {
// do some displaying
}
else {
document.getElementById('content').appendChild(document.createTextNode('Error: ' + resp.message));
}
});

Categories