Reputation: 2281
I've got an application using Paypal's IPN interface, pointing at the sandbox site while it's in development.
I've got it handling the success cases correctly, along with the failure cases I accidentally generated during account setup ;-) What I can't find though is how to simulate a transaction being denied, refunded or reversed (other than producing an entirely fake IPN through the test tool, but that won't tie up with transactions at my end so isn't a great test). I've tried enabling the negative testing but that didn't seem to do anything different.
Are these outcomes possible to test using the sandbox and if so, what do I need to set up to create them? Thanks :-)
EDIT: Here's the form code that's submitted for a test transaction.
<form id="payForm" method="post"
action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business"
value="[email protected]" />
<input type="hidden" name="item_number" value="1_25_2013-03-2221:02:02.063" />
<input type="hidden" name="item_name"
value="ISM Print Subscription - One Year" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return"
value="http://ism.gregwebb.co.uk/?p=PaymentReceived" />
<input type="hidden" name="rm" value="" />
<input type="hidden" name="notify_url"
value="http://ism.gregwebb.co.uk/Payment/Paypal/IPNRecv.aspx" />
<input type="hidden" name="cancel_return"
value="http://ism.gregwebb.co.uk/?p=PaymentCancelled" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="custom" value="1_25_2013-03-2221:02:02.063" />
</form>
Upvotes: 2
Views: 2244
Reputation: 7329
You can enable payment review on your test account to allow you to test this. You can also use specific values to trigger specific conditions when processing transactions. You would need to use Negative Testing. You can find more on sandbox and negative testing here.
By default, the Sandbox mimics the live PayPal site as closely as possible. This means means an error condition can be replicated only by creating the exact conditions and sequences of events to raise the error. The Sandbox is a positive test environment in that it's well-suited for testing your program logic as it follows an error-free path. However, you can also do negative testing with the Sandbox, meaning you can force flows through the different error conditions you expect to encounter.
Use negative testing to test against the following kinds of errors:
Errors that result from calling a PayPal API.
Address verification and credit card validation errors that occur through Virtual Terminal, or by calling DoDirectPayment.
NOTE: Negative testing is only available for Version 2.4 and later of the Classic PayPal APIs.
You raise error conditions by setting erroneous values in the fields you pass to an API operation. By setting different input values to erroneous states, you can trigger the API to respond to specific error conditions. Negative testing is available only in the Sandbox; you cannot force or simulate error conditions on the live PayPal site.
To enable negative testing:
Navigate to the Profile > Settings page of your test merchant's Business account.
Set Negative Testing to On.
This sets the Sandbox into the negative testing state for transactions that include the merchant. Without this configuration, the Sandbox does not raise error conditions, unless the error would be raised in the default positive test environment.
Upvotes: 1