Confused about merchantEmail and payerEmail on PayPal Invoicing API - paypal

Below is an example of payload to send to PayPal API to create payment to another merchant behalf. The example is taken from PayPal documentation page
# ** Payload **
{
"requestEnvelope":
{
"errorLanguage":"en_US" # Language of returned errors
},
"invoice":
{
"merchantEmail":"receiver#example.com", # Receiver/Merchant e-ddress
"payerEmail":"sender#example.com", # Sender/Buyer e-dress
"currencyCode":"USD",
"paymentTerms":"DueOnReceipt",
"itemList":
{
"item":[{
"name":"BananaPlant",
"quantity":"1",
"unitPrice":"38.95"
},
{
"name":"PeachTree",
"quantity":"2",
"unitPrice":"14.95"
}]
}
}
}
I am confused about the field merchantEmail and payerEmail. Which is what? Is the merchant email my email or for the party I am creating invoice for? in the comment #Receiver/Merchant e-address made me more confused. Is it for the email who will be receive and pay the invoice?
For the sake of conversion. Lets use following example for answers:
api_user#domain.com is the user who calling the api to create invoice for merchants behalf.
merchant#domain.com is the user whom behalf api_user#domain.com creating Invoices.
user#domain.com is the user who is being charged.
Can anyone clarify?

To Clarify for You
merchantEmail is the email of the account that will be receiving the invoice aka seller.
payerEmail is the email of the account that is sending payment/buying the good.
The api_user#domain.com is the account specifying the API Credential set. Usually referred to as the API Username.

Related

Paypal Missing Payer Address with Orders API V2 / Sandbox

I am setting up a payment integration with PayPal Checkout Buttons and Paypal Orders API V2, which I test in the sandbox environment (no fancy shop system in use).
When an order is paid and status is completed, the Paypal Orders API V2 returns a valid response, but I do not completely receive the payer address from my sandbox buyer account.
Payer looks like this:
"payer": {
"name": {
"given_name": "<given_name>",
"surname": "<surname>"
},
"email_address": "<email>",
"payer_id": "HEU6X43KU231",
"address": {
"country_code": "DE"
}
}
but the payer definition says that the payer should also contain:
address_line_1,
address_line_2,
admin_area_1,
postal code
I would like to use this information to send an invoice to the customer after payment is completed.
First, I thought, the address information is not available in my sandbox buyer account, because you do not find this information in the paypal dashboard (in the details of the respective sandbox account), but the address information is available at https://www.sandbox.paypal.com/businessprofile/settings/address
The whole thing would work with a shipping address, but this look like conceptual mismatch. My order item has the "category": 'DIGITAL_GOODS' and I've set the "shipping_preference": 'NO_SHIPPING', because I sell a digital product, which is automatically delivered after the payment process.
As a workaround I could also ask for the address information in the dialog in our part of the order process (in our GUI, before checkout), and prefill the paypal payment dialog with the userdata entered in our GUI, but in terms of user experience I would prefer to use the paypal data.
Does someone have a clue how to receive the payer address data?
Thanks a lot in advance
I will get the documentation clarified.
But to just answer your question, by default the address of the payer is not shared, just the country_code - to get the complete payer.address you will need to call your account manager or merchant support and they can enable it for your account if you meet their criteria.

How can a server know a payment was truly made via PayPal client side REST API?

I was looking the PayPal interactive integration demo link.
At some point after the user complete the payment flow, the client reach the code:
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
In a real scenario, instead of an alert, I would probably like to send the server a instruction to ship a product or update the user plan. And it would probably be done via an HTTP POST request.
How can the server know that indeed a payment was made and it was not a result of an hacker sending an http post request manually?
After actions.payment.execute() you can call your server and have it make a GET call to verify the payment has been completed: https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/advanced-payments-api/show-payment-details/
Your idea is correct, the server cannot know if the payment was really made. This client API is intended for things like donations, where no request to any servers is necessary. The client callback can then be used to display a "thank you" note or similar to the user.
For most cases (like online shops etc.) you will want to use the server API. That way, the PayPal server will send a request to your server, so you can validate that it really is a genuine payment confirmation.
1) generate a unique reference server side in your database that includes the payment details. For example:
My paypal references table
| Amount: $1.00 | Reference: ECHI5786786 |
2) Pass the payment reference in your transaction object before excuting the payment.
"transactions": [
{
"amount": {
"total": "1.99",
"currency": "USD"
},
"soft_descriptor": "ECHI5786786" //this is your unique reference
]
3) In your PayPal app configuration, on the developers site, set a webhook to your server for "payment sale completed". PayPal will call your url with the transaction details including the unique reference. Record the details in your database. For example
My paypal confirmed completed payments table
| Amount paid: $1.00 | Reference: ECHI5786786 |
4) When PayPal confirms the payment is complete client side, send a request to your server to confirm payment details
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
//ajax to your server here with "soft_descriptor"
//if ajax success, then all good
});
Serverside confirmation
Confirm that the reference is in both tables and that the amount matches

How do i connect a third party paypal account by using email id and send invoice on behalf

i am integrating Paypal with our platform for multiple merchants. Here a Merchant just need to enter his Paypal email Id, and here i just need to validate his First Name and Last Name to be matched with Paypal account and the entered names in our platform.
And then i should be able to send invoices On behalf of Merchant from our platform to their customers.
I am looking for below.
1) How do i validate Merchant email id with paypal
2) After validating how do i be able to send Invoices on behalf of
Merchants.
FYI, I just find similar setup functionality here. i would need something like this.
You can validate the merchant PayPal account using GetVerifiedStatus API:
requestEnvelope.errorLanguage = en_US&emailAddress = teatemail#test.com&&firstName = Firstname&lastName = Lastname&matchCriteria = NAME
After validation, you can get the API call permissions after that you can run the invoicing API for sending invoices.
After a long time analyzing, i was able to find that to have above functionality , i have to use AdaptivePayment method of Paypal for generating invoice from our side and sending a link for payment and invoice page to customer in mail.
But before doing this i have to validate email id of merchant using GetVerifiedStatus API as mentioned by PP_Punna.
So the following steps are needed to :
1) Validate merchant email Id with first name and last name using GetVerifiedStatus API.
2) Generate a PayKey using AdaptivePayment method (PAY) by mentioning the receiver email id as Merchant email id which was validated in first step and create url like
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=[PayKey]. and put it under paypal button.

How to use X-PAYPAL-AUTHORIZATION to handle payments on behalf of other users in PayPal with out knowing user's email address

We are developing a marketplace webapp which charges customers on behalf of sellers.
After reading through PayPal's API documentation, the only solution seems to be the Permissions service.
According to the documentation. After retrieving the access token and token secrete of a seller through the RequestPermissions call, we generated X-PAYPAL-AUTHORIZATION header to initiate an express checkout payment id. However, the payment id generated is associated with our PayPal account instead of the seller's, which is not the anticipated behavior.
Adding seller's email address in the SUBJECT field as noted in PayPal Name-Value Pair API Basics does work, but as we tested it, it has nothing to do with the access token and token secrete.
The problem with the SUBJECT field is that we cannot make sure the seller's email address with us is the one PayPal have on file.
The GetBasicPersonalData permission seems to be able to get a valid email address, but that needs to be pre-approved by PayPal. In fact, I have come across many websites that does not require this permission but able to initiate payment on behalf of other users. Is there a way to just get sellers' email or PayPal Id without GetBasicPersonalData permission? We don't actually need any other personal data except email or PayPal Id.

How can I check the sample email sent by PayPal Invoice API

I'm trying to check how the paypal invoice looks like when it send email to the payer, however, the api doesn't seem to send the email. In the api response, there's a Invoice Url, I was able to see it but it requires the payer to login. Does the API send an email to payer's email or not?
From the PayPal Invoice API docs:
To use the Invoicing API to request payment, you start by making one of the Invoicing API calls to PayPal. Your customer receives the invoice via email and clicks on an included link to view the invoice on PayPal's website. Customers who have a PayPal account can log into their PayPal accounts to pay the invoice. Customers can also pay using a check, debit, or credit card.
(https://developer.paypal.com/docs/classic/invoicing/gs_Invoicing/)
As long as the "ack" field in the JSON response from the API shows "success" as value, an email will be sent by the buyer. He or she has to click the link and login to complete the payment.
Example JSON response:
{
"responseEnvelope": {
"timestamp": "2011-06-16T:12:30.861-07:00",
"ack": "Success",
"correlationId": "78733df04b1f0",
"build": "1942837"
},
"invoiceID": "INV2-C4AK-UU3J-5SCL-9KZY",
"invoiceNumber": "1192",
"invoiceURL": "invoiceURL"
}
so the answer to your question is YES;
Try sending yourself (or another account you control) an invoice. This will give you an idea of what the invoice looks like.