Last active
October 19, 2017 09:04
-
-
Save weverson83/5b367d20f56a55e3598f0be3d6539f93 to your computer and use it in GitHub Desktop.
Simulates paypal Ipn request for a local Magento store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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://dev.yourstore.com/paypal/ipn'; // IPN listener to test | |
$params = [ | |
'residence_country' => 'US', | |
'invoice' => '101800247', | |
'address_city' => 'San+Jose', | |
'first_name' => 'John', | |
'payer_id' => 'XMM22F3BKZWKS', | |
'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' => '[email protected]', // Put a valid email receiver | |
'verify_sign' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5KKKj2aP4j1jOIrjuGx', | |
'address_country' => 'United+States', | |
'payment_status' => 'Completed', | |
'address_status' => 'confirmed', | |
'business' => '[email protected], | |
'payer_email' => 'buyer%40paypalsandbox.com', | |
'notify_version' => '2.4', | |
'txn_type' => 'cart', | |
'test_ipn' => '1', | |
'payer_status' => 'unverified', | |
'mc_currency' => 'USD', | |
'mc_gross' => '12.94', | |
'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', | |
]; | |
$ch = curl_init(); | |
curl_setopt($ch,CURLOPT_URL, $paypal_url); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, $params); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment