what is sender_batch_id and sender_item_id in Paypal payout api?

Mohit10
Contributor
Contributor

https://developer.paypal.com/docs/api/payments.payouts-batch/v1/

We are using the above api documentation for integrating payout api with our laravel web app.

Can't seem to figure out what values need to be passed on following variables:

 

1. sender_batch_id

2. sender_item_id

Login to Me Too
4 REPLIES 4

alloy_bacon
Contributor
Contributor

sender_item_id I use the same number for each transaction really, 🙂 

 

sender_item_id": "15240864065560"

 

sender_batch_id is a number in your rest api link, such as 100
"https://api.paypal.com/v1/payments/payouts?sender_batch_id=100

If I already sent a payment with batch_id of 100, I can not rego to the payout url expecting it to send a payment again unless I switch the new batch_id to 101, it is good to always store the batch_id in a cookie to have a proper payout for your next server/desktop session. So basically for whatever use, a batch_id can not be used twice and should be remembered, and you should not have random useage of the number or else some payments may not happen.

 

example:

 

single_payout.html

 

<!DOCTYPE html>
<html>
<body>

<h2>Using the XMLHttpRequest Object</h2>

<div id="demo">
<button type="button">Change Content</button>
</div>

<script>
var batch_id='2000000000000'
var email='%email%'
var data = '{'+'\n'+ '"sender_batch_header": {'  +'\n'+' "sender_batch_id": "'+batch_id+'",'+'\n'+'"email_subject": "This email is related to simulation"'+'\n'+'},'+'\n'+'"items": ['+'\n'+'{'+'\n'+'"recipient_type": "EMAIL",'+'\n'+'"receiver": "'+email+'",'+'\n'+'"note": "POSPYO001",'+'\n'+'"sender_item_id": "15240864065560",'+'\n'+'"amount": {'+'\n'+'"currency": "USD",'+'\n'+'"value": "0.01"'+'\n'+'}'+'\n'+'}'+'\n'+']'+'\n'+'}'
//window.location="complete"

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {

if (this.readyState == 4) {
document.getElementById("demo").innerHTML =this.responseText;
window.location="complete"
}
};

xhttp.open("POST", "https://api.paypal.com/v1/payments/payouts", true);//http://127.0.0.1:845   //https://api.sandbox.paypal.com/v1/payments/payouts
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.setRequestHeader("cache-control", "no-cache");
xhttp.setRequestHeader("Authorization", "Basic lVjNKSDVsZXRJMmxKNmdqTnZ=");
//xhttp.setRequestHeader("Postman-Token", "bf41afcb-0e17-4f7c-bde9-c3ae8855a88f");
xhttp.send(data);
setTimeout(never_loaded,2000);
function never_loaded(){
window.location="complete"
}

</script>

</body>
</html>

 

 

 

 

 

I develop, if that helped donate: here

Login to Me Too

theTman323
New Community Member

How does paypal know which account to charge this payout? i don't see any detail in the request which tells that.

Login to Me Too

janat08
Contributor
Contributor
receiver
required
string <= 127 characters

The receiver of the payment. Corresponds to the recipient_type value in the request.

recipient_type
string

The ID type that identifies the payment receiver.

Enum: Description
EMAIL

An unencrypted email. Value is a string of up to 127 single-byte characters.

PHONE

An unencrypted phone number.

PAYPAL_ID

An encrypted PayPal account number.

Ask users for their PayPal email, and pass that email into receiver field, along with email in recipient_type.

Login to Me Too

janat08
Contributor
Contributor

So you can use the same sender_item_id, but what does it actually do?

I think I'll just pass my userId into that field, however much it may not be safe.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.