after 5 hours of research and reading outdated paypal documentation I finally give up!
I need to test a simple paypal subscription button with the paypal sandbox.
Button Code:
<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="34CXHXVU2J8BY">
<input type="image"
src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif"
border="0" name="submit"
alt="PayPal — The safer, easier way to pay online."
style="border:none;padding:0;height:auto;width:auto">
<img alt="" border="0"
src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif"
width="1" height="1">
</form>
But when I try to send the form, I get this error on the paypal website:
Thanks in Advance, Phillip
The problem is that you've generated a 'hosted' PayPal button in the live PayPal website, but you're sending this data to the Sandbox.
Since the hosted_button_id
isn't recognized in the Sandbox, it returns an error.
You'd need to either:
- Create a non-hosted button, and change the 'action' and 'business' parameters to match Sandbox details
- Create a new 'hosted' button in Sandbox via
www.sandbox.paypal.com > Profile > PayPal Buttons.
TL;DR: Sandbox is 100% separated from the Live PayPal website. A hosted button generated in Live, doesn't work in Sandbox.
Just a short add how to make the hosted button in the sandbox:
- Create and log in to your sandbox account on https://developer.paypal.com/
- Choose "Test Accounts".
- Create a "Preconfigured" test account for a seller, make sure you remember the password, and make sure the password contain numbers or you will not be able to log in with it.
- Click the yellow button "Enter Sandbox Test Site".
- My Account >> Profile >> Selling Preferences >> My Saved Buttons
- Edit your button. (There are 3 "saved" pre-made buttons there.) Make sure you dont dwell too long, it logged me out without telling me so and I got a blank code field first time I fiddled with my button.
Hopefully this saved you some time :)
Perhaps this will help: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ButtonMgrAPIIntro
Not all merchants in every country can use all the buttons that can be created. For example, German merchants cannot use Subscribe buttons even though they can be created through the API
Yes, it's true, PayPal actually thinks creating another button in a separate sandbox system is equivalent to "testing". Erm, no, the point of testing, PayPal, is to test the actual thing, not a copy of the thing you make from scratch in another system. What if something is done differently (by mistake, which is the point of testing) or goes wrong when setting it up in the other system? This is not testing. This is doing a trial.
So in answer to the question, you can't test a PayPal button with sandbox, you can only do trials. The only way to actually test a PayPal button, is to reduce the price to something small while testing, like a cent, or just pay for it and then refund.
Yes, you can test also on sandbox with following steps:
- Create a new sandbox business account.
- Login to the business account.
- Go with profile > My setting tools.
- Click on Paypal buttons > Update.
- Click on "Create new button".
- Fill up all following details you required.
- At last, you can get the form code with "hosted_id".
- You can paste the code in your website and you can test it.
Hope, These steps are useful to you.
来源:https://stackoverflow.com/questions/8683483/how-do-i-test-paypal-subscription-buttons-with-sandbox