Paypal Sandbox Test Tool IPN Simulator in Localhost - paypal-ipn

How to use Instant Payment Notification Simulator in local machine? What will be provided in IPN handler URL? I don't have access to our router.
Thanks

You can test on localhost using ngrok.
Simply run ngrok locally then paste test url that ngrok gives you (something like http://1bc7d09d.ngrok.com/)
It provides a tunnel to your localhost.

Paypal's IPN simulator will not work with localhost. However, you can simulate the simulator :-). To do this you need to install a browser plugin/extension such as poster for firefox or Advanced Rest Client for google chrome.
Open the app and put in your url you are listening on for IPN responses:
http://localhost/ipn
Put the following as your POST data and submit the request:
residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&mc_fee=0.44&txn_id=421462822&receiver_email=seller%40paypalsandbox.com&custom=xyz123+CUSTOMHASH&payment_date=12%3A40%3A25+27+Aug+2013+PDT&address_country_code=US&address_zip=95131&item_name1=something&mc_handling=2.06&mc_handling1=1.67&tax=2.02&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com&notify_version=2.4&txn_type=cart&test_ipn=1&payer_status=unverified&mc_currency=USD&mc_gross=12.34&mc_shipping=3.02&mc_shipping1=1.02&item_number1=AK-1234&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street
UPDATE: I just started using another option that is easier, https://localtunnel.me. To install and run the module do the following. It will show your public URL. All requests to that public URL will be forwarded to your localhost.
npm install -g localtunnel
lt --port 80

You cannot test IPN on your localhost, as IPN is all about PayPal's server initiating a server-side POST to a URL you define.
As a result, your IPN script must be accessible by the outside world (or you can use a tunnel such as ngrok.me/localtunnel.me).

You can simulate PayPal's IPN post by running the script below I made on your localhost (you'll need curl installed). As long as your listener is pointed to the sandbox it should validate. Change your listener to the live paypal and it should fail to validate.
<?php
// SIMULATE PAYPAL IPN LOCALLY
//
// Sometimes you need to test on your local host and this can be difficult due
// to IP routing issues. Use this code on your local machine to simulate the
// same process that the sandbox IPN simulator does when posting to your URL.
//
// Run this code in command line or via the browser. It will post IPN data just
// like Paypal would. If the code you've written to process your IPN data
// posts back to the sandbox, it should come back as valid.
// Put the full url to test in $paypal_url, include file extensions if necessary
$paypal_url = 'http://localhost/paypal_ipn/process'; // IPN listener to test
//example posted data from paypal IPN
$test = 'residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&mc_fee=0.44&txn_id=421462822&receiver_email=seller%40paypalsandbox.com&custom=xyz123+CUSTOMHASH&payment_date=12%3A40%3A25+27+Aug+2013+PDT&address_country_code=US&address_zip=95131&item_name1=something&mc_handling=2.06&mc_handling1=1.67&tax=2.02&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com&notify_version=2.4&txn_type=cart&test_ipn=1&payer_status=unverified&mc_currency=USD&mc_gross=12.34&mc_shipping=3.02&mc_shipping1=1.02&item_number1=AK-1234&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street';
/*
* More detailed breakout of the raw data
_POST EXAMPLE ARRAY FROM PAYPAL:
Array
(
[residence_country] => US
[invoice] => abc1234
[address_city] => San Jose
[first_name] => John
[payer_id] => TESTBUYERID01
[mc_fee] => 0.44
[txn_id] => 421462822
[receiver_email] => seller#paypalsandbox.com
[custom] => xyz123 CUSTOMHASH
[payment_date] => 12:40:25 27 Aug 2013 PDT
[address_country_code] => US
[address_zip] => 95131
[item_name1] => something
[mc_handling] => 2.06
[mc_handling1] => 1.67
[tax] => 2.02
[address_name] => John Smith
[last_name] => Smith
[receiver_id] => seller#paypalsandbox.com
[verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx
[address_country] => United States
[payment_status] => Completed
[address_status] => confirmed
[business] => seller#paypalsandbox.com
[payer_email] => buyer#paypalsandbox.com
[notify_version] => 2.4
[txn_type] => cart
[test_ipn] => 1
[payer_status] => unverified
[mc_currency] => USD
[mc_gross] => 12.34
[mc_shipping] => 3.02
[mc_shipping1] => 1.02
[item_number1] => AK-1234
[address_state] => CA
[mc_gross1] => 9.34
[payment_type] => instant
[address_street] => 123, any street
)
*/
//#
// PayPal IPN processor in PHP
// fake paypal post to test scripts
//#
//----------------------------------------------------------
// Create FAKE post from PayPal.
//----------------------------------------------------------
$req = $test; // use test data
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $paypal_url);
curl_setopt($ch,CURLOPT_POST, substr_count($req,'&')+1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $req);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
?>

I do test on localhost. You can use a service like dyn.com or noip.com or point a subdomain to your local address if it's static.

/ngrok http -host-header=yourwebsite.com 80
will tunnel to localhost with the right host header

Related

PayPal Sandbox 500 Proxy Error- PayPal Adaptive

We are aware that PayPal rolling out upgrades to make use of SSL/TLS SHA256 for security purposes. Today i met with strange issue on PayPal Sandbox mode for my PayPal Adaptive Application even though my site follows HTTPS. To add further, same application works fine in Production(not sandbox).Please enlighten me, was this an issue in Application or Rollout issues? same issue reported in PayPal community but no response https://www.paypal-community.com/t5/About-Payments/Adaptive-payment-api-is-sending-Proxy-error/m-p/1091510
The proxy server could not handle the request AdaptivePayments/Pay Reason: Error during SSL
Handshake with remote server
07-27-2016 # 13:43:35 - Error in generate payment key: Array
[headers] => Array
[date] => Wed, 27 Jul 2016 13:43:35 GMT
[server] => Apache
[connection] => close
[http_x_pp_az_locator] => sandbox.slc
[paypal-debug-id] => 8913861a40cd4
[set-cookie] => Array
(
[0] => X-PP-SILOVER=name%3DSANDBOX3.APIT.1%26silo_version%3D1880%26app%3Dadaptivepaymentspartaweb_api3t%26TIME%3D2277152855%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Wed, 27 Jul 2016 14:13:35 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
[1] => X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
[response] => Array
(
[code] => 500
[message] => Proxy Error
)
[cookies] => Array
(
[0] => WP_Http_Cookie Object
(
[name] => X-PP-SILOVER
[value] => name=SANDBOX3.APIT.1&silo_version=1880&app=adaptivepaymentspartaweb_api3t&TIME=2277152855&HTTP_X_PP_AZ_LOCATOR=sandbox.slc
[expires] => 1469628815
[path] => /
[domain] => .paypal.com
[secure] =>
[httponly] =>
)
[1] => WP_Http_Cookie Object
(
[name] => X-PP-SILOVER
[value] =>
[expires] => 1
[path] => /AdaptivePayments/
[domain] => svcs.sandbox.paypal.com
Edit July 28th, 9:50am EDT: It appears the teams were able to track down what they believe to be the issue overnight, and released a code fix. Can you please verify that the problem has been fixed? I'll report back if that's not the case. Thanks.
We've had a few reports about failed requests on sandbox. I'm working with the sandbox and support teams internally in PayPal to figure out what's going on. Right now it looks like they're seeing the error responses and have teams on it to diagnose the problem. Just to note, this does look like it's restricted to sandbox and not any of the production servers. I'll post back when I hear more.

PayPal Rest API Curl SSL : unable to get local issuer certificate

I am working on PayPal Express checkout restapi service.
I complated successfully at sandbox mode but when trying go online curl returns "unable to get local issuer certificate" error. At sandbox i dont get this error.
What i tried!
I tried bind cert file (Latest one from mozilla) in php.ini and curl parameter but nothing change.
Currently my code like this
//Building our NVP string
$request = http_build_query($requestParams + $params);
//cURL settings
$curlOptions = array (
CURLOPT_URL => https://api-3t.paypal.com/nvp,
CURLOPT_VERBOSE => 1,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO =>'certs/cacert.pem', //CA cert file
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $request
);
$ch = curl_init();
curl_setopt_array($ch,$curlOptions);
Where i am failing ?
Note: I already got API Signature for LIVE from
https://www.paypal.com/us/cgi-bin/webscr?cmd=_get-api-signature
I fixed problem.
Mozilla's certs is failing on live edition.
When i used Facebook's cert it fixed.

Website Paypal Connection with Php

Im trying to connect my website with paypal and i have the index page where i am getting the order price,
the order name and then i refer them to the process.php using get for processing.Howevever,on running the process.php file i am getting this error
Error : Security header is not valid
Array
(
[TIMESTAMP] => 2014%2d10%2d07T17%3a22%3a00Z
[CORRELATIONID] => 37359d983e7a
[ACK] => Failure
[VERSION] => 109%2e0
[BUILD] => 13243702
[L_ERRORCODE0] => 10002
[L_SHORTMESSAGE0] => Security%20error
[L_LONGMESSAGE0] => Security%20header%20is%20not%20valid
[L_SEVERITYCODE0] => Error
)
How can i solve this error.Please Assist
This error comes in when :
You are using the wrong credentials ( make sure you have not copied any white spaces in apiusername. password and the signature .
You are using the wrong endpoints . Meaning you are using test credentials in live mode or vice versa .

Cake Email Times Out During Send

I'm trying to use CakeEmail in a web application, but I keep running into a timeout error. All my Googling and Stacking only give me the idea that something is not configured correctly, but I can't seem to find what config option I'm missing or filling incorrectly. I'm trying to send using my Gmail account.
Gmail Config:
public $gmail = array(
'host' => 'ssl://66.249.93.111',
'port' => 465,
'timeout' => 30,
'username' => 'my_gmail_account_name',
'password' => 'my_gmail_account_password',
'transport' => 'Smtp'
);
in app/Config/email.php
Email code:
$Email = new CakeEmail('gmail');
$Email->from(array('my_gmail_account_name' => 'Dev'));
$Email->to('my_gmail_account_name');
$Email->subject('Export Email Test');
$Email->send('This is a test email for ExportJobs.');
(As an additional note, the code that runs here is as part of a Cake Console program, so these methods are called when I run Console/cake file_name from the command line; also, that IP is the Gmail SMTP IP. When I try using the name, I get some DNS issue).
Does anyone happen to see what I'm missing?
Thanks for your time!
I found the problem I was having; it's a pretty silly error.
I completely forgot that to use the gmail domain for SMTP, I have to preface the domain name as "smtp.gmail.com". Once I did that it used SMTP and worked just fine.

ERRORCODE0: 10501 while connecting to paypal do direct

How does one resolve the following error when trying to connect to the paypal sandbox account
[TIMESTAMP] => 2013-05-03T15:13:47Z
[CORRELATIONID] => c51f05505c8b5
[ACK] => Failure
[VERSION] => 76.0
[BUILD] => 5715372
[L_ERRORCODE0] => 10501
[L_SHORTMESSAGE0] => Invalid Configuration
[L_LONGMESSAGE0] => This transaction cannot be processed due to an invalid merchant configuration.
[L_SEVERITYCODE0] => Error
[AMT] => 200.00
[CURRENCYCODE] => USD
As far as I can tell from reading all the other issues here, the only possible solution is to post on stackoverflow and wait for someone to magically fix it for you.
The 10501 error happens when you are trying to use an API call that you do not have permission on.
If you are using the facilitator account in the sandbox, it probably doesn't have the PayPal API access enabled on it.
Make a different business sandbox account, and use the API credentials generated from that account, and you should be good to go.