问题
I am testing the environment within a development environment which is protected with simple HTTP authentication. I do not want to expose the environment without authentication. Can Paypal/Paypal-sandbox send IPN to my development server with simple HTTP authentication, e.g. https://username:password@mydomain.com/ipn ? Thanks.
回答1:
IIRC After Googling, I doesn't look like you can. We use PayPal and basically, you can pass in a custom variable to the IPN process when the user clicks you PayPal button(s). This variable is then carried across through the entire transaction, and will be sent to your controller that handles the IPN notifications.
It's then down to you to validate the request and ensure it looks credible.
For example, you could use a user ID in the custom variable, compare the PayPal email address with your address on file and (with tracking on your server) see that they have clicked the button recently.
See the PayPal IPN docs for more info.
回答2:
Although Paypal lets you set your IPN URL to something like https://username:password@mydomain.com/ipn it seems that it doesn't send the username and password.
All requests were constantly marked as failed in my IPN history until I removed authentication on my server. Note that you can alternatively create a .htaccess file to let requests from paypal in (I haven't done it so I don't know the exact syntax, you should google it).
回答3:
I'm also developing a website which accepts payments with paypal. Just like you, I had a hard time trying to figure out what to do with IPN as well as how to test it. To be able to set up IPN, edit your button and go to the Advanced Options. There you will find the text area to include other variables. Just copy the 2 sample variable on the right (notify_url and (address_overide=1)?). Change the notify_url value then save.
回答4:
As for now it is not possible, but if you are asking about real-world scenario usually you have proxy-server in front of/as your web-server which handles simple HTTP auth and you can set up exclusion rules for your paypal IPN urls. For example if you use nginx directives will look like:
server {
listen 80;
server_name example.com;
location /paypal/ipn {
try_files $uri @proxy_to_app;
}
location / {
auth_basic "Restricted";
auth_basic_user_file /example/.htpasswd;
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
if (!-f $request_filename) {
proxy_pass http://localhost;
break;
}
}}
来源:https://stackoverflow.com/questions/10478293/how-do-i-make-paypal-to-send-ipn-to-my-server-with-simple-http-authentication