create buynow button for sandbox account

12,952

Solution 1

The link in the sandbox is broken and redirects you to the live site. When this happens, sometimes you can just add sandbox into the URL to correct the issue. So if you click the button and it takes you to https://www.paypal.com/button/blah_blah, you would just need to change it to https://www.sandbox.paypal.com/button/blah_blah. Another option would be to create a non hosted clear text button from your live paypal account and then just modify the URL to point to the sandbox instead of the live site. So instewad of the following:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">

You woudl just change it to

<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">

And then you would update the business variable to reflect the email address of your test sandbox seller account.

The last option for creating a button, would be not to log into your account but use the BMCreateButtom API call. Keep in mind this could be a little bit more work then you may want to do if you are only familar with HTML.

Solution 2

I faced the same problem..

when i click the "create payment buttons for your website" it redirects to this link www.paypal.com/us/webapps/mpp/standard-integration which is live paypal site. your test account does not exist there so you can not do the rest with the sandbox test account..

i solved it the follwing way..

after redirect to above link... you can edit the link.

put "sandbox." in the link. The edited link will be www.sandbox.paypal.com/us/webapps/mpp/standard-integration

now you can create your customize button.. the generated HTML will be something like this

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
      <input type="hidden" name="cmd" value="_s-xclick">
      <input type="hidden" name="hosted_button_id" value="5GW6UJKLK47R6">
      <input type="image"   src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
      <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Solution 3

I can't comment because my reputation isn't high enough, but I thought it was important to add this element to Sadid Khan's correct answer. When trying to change the address to the sandbox you need to add the 'www' in front of the subdomain.

sandbox.paypal.com will redirect to the frontpage/homepage for the sandbox. www.sandbox.paypal.com will properly run the purchase emulation

Solution 4

You can set data-env="sandbox" to create a button which will redirect you to sandbox website.

<script type="text/javascript" charset="utf-8" 
src="/assets/paypal-button.min.js?merchant={merchant-email}"
    data-button="buynow"
    data-name="My product"
    data-amount="1.00"
    data-env="sandbox"
></script>

Solution 5

In your sandbox account:

  1. Click the Gear icon (Profile) on top right.
  2. Then choose 'Business Setup',
  3. Then 'On your website'
  4. Then Option B to add a payment payment button.

You can choose between 'Buy Now' and 'Pay Now' in the advanced setting of the button.

Share:
12,952
STUART GRAY
Author by

STUART GRAY

Updated on July 23, 2022

Comments

  • STUART GRAY
    STUART GRAY almost 2 years

    I'm new to paypal development and am trying to create a BuyNow button in the sandbox to enable me to test my application in a non production environment. If I create a button from my normal account it directs me to the live paypal site but if I try to create a button in the sandbox, the button creation page is always on the live box and I can't find anyway of creating a button in the sandbox using sandox test accounts, that then allows me to make test payments in the sandbox. Please help.

  • Mike Cole
    Mike Cole over 10 years
    Any idea how to do the same for recurring buttons? You need a business level account to do that and I need to find the right combination of of inputs.
  • Mike Cole
    Mike Cole over 10 years
    Also, any plan to actually fix the link?
  • Kato
    Kato almost 9 years
    The correct answer! No hacky changing URLs. Just add the right params to the generator.
  • Ahmed Bahtity
    Ahmed Bahtity almost 5 years
    Not working. could you please elaborate more about this solution ?