Paypal single payout: TRANSACTION_LIMIT_EXCEEDED API Error - node.js

I'm trying to make a singe payout with the REST API of PayPal with Node.js and get this error:
//...
"errors": {
"name": "TRANSACTION_LIMIT_EXCEEDED",
"message": "Either the sender or receiver exceeded the transaction limit",
}
//...
What I do:
I use this example Code:
var paypal = require('paypal-rest-sdk');
module.exports = {
payMe: function (req, res,next) {
var mail = req.param('mail'); //this email comes from the paypal sandbox
paypal.configure({
'mode': 'sandbox',
'client_id': 'mycliendID',
'client_secret': 'myClientSecret'
});
var sender_batch_id = Math.random().toString(36).substring(9);
var create_payout_json = {
"sender_batch_header": {
"sender_batch_id": sender_batch_id,
"email_subject": "You have a payment"
},
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": 0.90,
"currency": "CHF" //changed from Dollar to CHF
},
"receiver": mail,
"note": "Thank you.",
"sender_item_id": "item_3"
}
]
};
var sync_mode = 'true'; //for single payout
paypal.payout.create(create_payout_json, sync_mode, function (error, payout) {
if (error) {
console.log(error.response);
res.json(error.response);
throw error;
} else {
console.log("Create Single Payout Response");
console.log(payout);
payout.status= "You are in the else";
res.json(payout);
}
});
}
}
=>The Email-Address comes from my sandbox account - the Balance of this User is set to 900.00 CHF! (Much more than the 0.90 CHF which I want to payout)
=>I created under My Apps and Credentials a new REST API App and select the previous created User (with 900.00CHF balance). Those credentials are used in the above code snipped in paypal.configure()
"Either the sender or receiver exceeded the transaction limit"
Where can I change the transaction limit for the App and User in the sandbox?

OK Solved.
I logged in with the sandbox email address - there you can see all transactions.
Under "Denied" I saw the 0.90CHF - With a popup: "The receiver decided to deny the payment"
Then I realised that I used the same E-Mail Address for the Receiver and the Sender. That accused the Error. - The error-message is not very clear.
Maybe someone else is also doing the same mistake, so I let this here.

Related

Node.js Paypal Payout api error in Live enviornment

I am using a PayPal payout API to transfer money, its working perfect in sandbox environment but when I changed it to live environment it is throwing some error:
text: '{"name":"VALIDATION_ERROR","message":"Invalid request - see details","debug_id":"a641429b40e07","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors","details":[{"field":"items[0].receiver","location":"body","issue":"may not be null"}],"links":[]}'
This is the code I am using to request a payout
let requestBody = {
"sender_batch_header": {
"recipient_type": "EMAIL",
"email_message": "SDK payouts test txn",
"note": "Enjoy your Payout!!",
"sender_batch_id": 'asd12432',
"email_subject": "This is a test transaction from SDK"
},
"items": [{
"note": "Your 5$ Payout!",
"amount": {
"currency": "USD",
"value": 20
},
"receiver": 'payment#reciever.com',
"sender_item_id": "Test_txn_1"
}]
}
// Construct a request object and set desired parameters
// Here, PayoutsPostRequest() creates a POST request to /v1/payments/payouts
let request = new paypal.payouts.PayoutsPostRequest();
request.requestBody(requestBody);
// Call API with your client and get a response for your call
let createPayouts = async function () {
let response = await client.execute(request);
console.log(`Response: ${JSON.stringify(response.statusCode)}`);
// If caladfl returns body in response, you can get the deserialized version from the result attribute of the response.
console.log(`Payouts Create Response: ${JSON.stringify(response.result)}`);
//res.redirect('/adam?payment=success');
res.redirect('/adam?payment=success');
}
createPayouts();

Stripe create Token bank account

I'm trying to add a token to create a bank account with stripe.
tokenAccount: async (req, res) => {
Serveur.findOne({ _id: req.user._id }, async (err, user) => {
try {
await stripe.tokens.create({
bank_account: {
country: req.body.country,
currency: req.body.currency,
account_number: req.body.account_number,
routing_number: req.body.routing_number,
},
});
} catch (error) {
return res.status("402").send({ error: { message: error.message } });
}
});
},
and when i test the back end with postman with a "test" bank details from stripe i have this error :
{
"error": {
"message": "You cannot use a live bank account number when making transfers or debits in test mode"
}
}
Which is weird because i used the test stripe's bank details. Do you have any idea what the problem could be ???
Each Stripe account offers both live and test keys. When you use their fake test accounts (for banks, MasterCards, and the like) you must also use their test keys. Don't try to use the live keys for testing; and, honestly, be happy they caught this for you.

actions-on-google Account Linking Signin status is "ERROR" always

I got this sample code from the docs of actions on google account linking with google account. The signin.status is always "ERROR". I have tried on actions console simulator, google assistant app on my phone and on a google home mini with personal results on. But the result is the same in all cases.
const express = require('express');
const bodyParser = require('body-parser');
const {actionssdk, SignIn} = require('actions-on-google');
const app = actionssdk({
// REPLACE THE PLACEHOLDER WITH THE CLIENT_ID OF YOUR ACTIONS PROJECT
clientId: <client_id>,
});
// Intent that starts the account linking flow.
app.intent('actions.intent.MAIN', (conv) => {
conv.ask(new SignIn('To get your account details'));
});
// Create an Actions SDK intent with the `actions_intent_SIGN_IN` event.
app.intent('actions.intent.SIGN_IN', (conv, params, signin) => {
console.log(signin)
if (signin.status === 'OK') {
const payload = conv.user.profile.payload;
conv.ask(`I got your account details, ${payload.name}. What do you want to do next?`);
} else {
conv.ask(`I won't be able to save your data, but what do you want to do next?`);
}
});
app.intent('actions.intent.TEXT', (conv) => {
conv.close("bye");
})
//Run server
const expressApp = express().use(bodyParser.json());
expressApp.post('/', function(req,res){
app(req,res);
});
expressApp.listen(8080,() => {console.log("listening")});
This is the signin object I'm being returned
{ '#type': 'type.googleapis.com/google.actions.v2.SignInValue',
status: 'ERROR' }
EDIT
My actions.json is as follows
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "fulfilment function"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"talk to Care Cat"
]
}
}
},
{
"description": "Everything Else Intent",
"name": "allElse",
"fulfillment": {
"conversationName": "fulfilment function"
},
"intent": {
"name": "actions.intent.TEXT"
}
}
],
"conversations": {
"fulfilment function": {
"name": "fulfilment function",
"url": <url>
}
},
"locale": "en"
}
Could it be because it is still a test app which is not published yet?
Can someone help me with this?
In your Google Cloud Platform Account, check your IAM settings and enable the Dialogflow API Admin
Documentation for more details: https://cloud.google.com/dialogflow/docs/access-control

Azure BotBuilder - How to get the user information of the OAuth Connection Settings

I've created a Azure Web App Bot and added a OAuth Connection Setting which takes the user to Salesforce. Everything works well, I'm able to authenticate the user through my bot and also, I can get the access token from Salesforce.
Problem
Can someone help me to get the user information from Salesforce? Because, I am able to get the access token alone and not sure, how to get the user id from Salesforce.
I've written the below code,
var salesforce = {};
salesforce.signin = (connector, session, callback) => {
builder.OAuthCard.create(connector,
session,
connectionName,
"Sign in to your Salesforce account",
"Sign in",
(createSignInErr, createSignInRes) => {
if (createSignInErr) {
callback({
status: 'failure',
data: createSignInErr.message
});
return;
}
callback({
status: 'success',
data: createSignInRes
});
});
};
salesforce.getUserToken = (connector, session, callback) => {
connector.getUserToken(session.message.address,
connectionName,
undefined,
(userTokenErr, userTokenResponse) => {
if (userTokenErr) {
callback({
status: 'failure',
data: userTokenErr.message
});
return;
}
callback({
status: 'success',
data: userTokenResponse
});
});
};
salesforce.accessToken = (connector, session, callback) => {
salesforce.getUserToken(connector, session, (userTokenResponse) => {
if (userTokenResponse.status == 'failure') {
// If the user token is failed, then trigger the sign in card to the user.
salesforce.signin(connector, session, (signinResponse) => {
// If the sign in is failed, then let the user know about it.
if (signinResponse.status == 'failure') {
session.send('Something went wrong, ', signinResponse.message);
return;
}
// If the sign in is success then get the user token and send it to the user.
salesforce.getUserToken(connector, session, (newUserTokenResponse) => {
if (newUserTokenResponse.status == 'failure') {
session.send('Something went wrong, ', newUserTokenResponse.message);
return;
}
callback(newUserTokenResponse);
return;
});
});
}
callback(userTokenResponse);
});
};
I can get the userTokenResponse here. But I need Salesforce user id so that I can start interacting with Salesforce behalf of the user.
If you have only OAuth access token you may query details about the user by invoking http GET against:
https://login.salesforce.com/services/oauth2/userinfo for PROD or
https://test.salesforce.com/services/oauth2/userinfo for sandbox
Add only Authorization: Bearer Y0UR0AUTHTOKEN to the header of the http GET request.
Based on my recent test the result returned from the server looks like:
{
"sub": "https://test.salesforce.com/id/[organizationid]/[userId]",
"user_id": "000",
"organization_id": "000",
"preferred_username": "me#mycompany.com",
"nickname": "myNick",
"name": "name lastname",
"urls": {
...
},
"active": true,
"user_type": "STANDARD",
...
}
You don't need a userId to get the user information where an accessToken is enough. I've installed jsforce and used the below code to get the identity information.
Solved by doing,
const jsforce = require('jsforce');
var connection = new jsforce.Connection({
instanceUrl: instanceUrl,
sessionId: accessToken
});
connection.identity((error, response) => {
if(error) {
callback({
status: 'failure',
message: error.message
});
return;
}
callback({
staus: 'success',
data: response
});
});

I don't get emails when sending by Mandrill NodeJS API

I have this function below which allows me to send a mail with mandrill nodeJS API :
var mandrill = require('mandrill-api/mandrill');
var mandrill_client = new mandrill.Mandrill(config.values.mandrill_api_key);
exports.sendMail = function(htmlContent, textContent, subject, from_email, from_name, to_email, to_name ,reply_to_email, callback) {
var message = {
"html": htmlContent,
"text": textContent,
"subject": subject,
"from_email": from_email,
"from_name": from_name,
"to": [{
"email": to_email,
"name": to_name,
"type": "to"
}],
"headers": {
"Reply-To": reply_to_email
},
"important": false
};
var async = false;
mandrill_client.messages.send({"message": message, "async": async}, function(result) {
console.log(result);
callback(result);
}, function(e) {
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
});
};
On the mandrill console (https://mandrillapp.com/activity) I can see that emails have been successfully sent (status: Delivered).
But I don't get it in my gmail box nor hotmail box.
How to resolve this problem ?
Thanks,
Be sure, you're not using a testing API Key.
You can use a test key to experiment with Mandrill's API. No mail is actually sent, but webhooks trigger normally and you can generate synthetic bounces and complaints without impacting your reputation.
The problem is solved.
I had to add special fields into my DNS zone : DKIM and SPF
http://help.mandrill.com/entries/22030056-how-do-i-add-dns-records-for-my-sending-domains

Resources