1

I just can't find this simple thing.

exports.contentServer = functions.https.onRequest((request, response) => 

I am getting ipn from PayPal (POST), and i have to confirm that its actually comes from PayPal.

I am trying to get the url from the request but i can't. I only get the path:

request.url
request.path

both only show me the path which is /paid. I have to confirm it is actually a PayPal URL with this path.

How to check the url ?

   if(request.path === "paid"  &&  url base is paypal)
hkrlys
  • 361
  • 1
  • 13
  • 1
    I'm unclear what you're trying to do. If you're using Cloud Functions to receive a request from paypal, the URL of the function belongs to you, not paypal. The only way you could validate if the request came from them is if they send you some token that you can validate. – Doug Stevenson Oct 15 '19 at 15:09
  • belong to me ? what does it means ? (sorry i am new to it). i think it's reasonable to be able to simply know who is the server that send me this POST. Paypal advice to check that the server with the POST is them and not some hacker. – hkrlys Oct 15 '19 at 16:29
  • 1
    It sounds like you're looking for an IP address of the requestor, not a URL. Request don't come "from" a URL. – Doug Stevenson Oct 15 '19 at 16:35
  • As Doug explained in his first comment, you need to validate the request based on some values you receive in the header or the body of the request. As explained in the Paypal documentation for Notifications "Event headers for notification messages contain the PayPal-generated asymmetric signature and information that you can use to validate the signature". See https://developer.paypal.com/docs/integration/direct/webhooks/notification-messages/ – Renaud Tarnec Oct 16 '19 at 12:27

1 Answers1

1

You can try:

exports.helloWorld = functions.https.onRequest((req, res) => {

var fullUrl = req.protocol + '://' + req.get('Origin') + req.originalUrl;
res.status(200).send(fullUrl);

});

Please check this related question: link.

partyblanket
  • 3
  • 1
  • 4
marian.vladoi
  • 7,663
  • 1
  • 15
  • 29