How do I test Paypal subscription buttons with sandbox?
Asked Answered
T

7

30

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:

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfpKnMxcF_AZVLQamyA/AVuTz.png

Thanks in Advance, Phillip

Terce answered 30/12, 2011 at 19:57 Comment(1)
Did you generate the code using button generator at paypal.com/uk/cgi-bin/… ?Pereira
M
36

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.

Manvil answered 31/12, 2011 at 14:14 Comment(8)
So it's impossible to test a hosted button? I just have to hope that everything's working, or put a real payment through?Depositary
In my case I had to delete all history (cookies, sessions, etc), otherwise the sandbox.paypal.com website redirected me elsewhere.Jameejamel
Does anyone have idea how can I generate hosted_button_id in my server applicationStereotype
You would need to call the BMCreatebutton API for this.Manvil
There is an error on the sandbox subdomain, that, when you click the "Create Button" link, it takes you back to the live www.paypal.com domain, rather than the www.sandbox.paypal.com subdomain. Here is the proper link for a sandbox button generator: sandbox.paypal.com/webapps/mpp/standard-integrationMarie
Same problem with the My Saved Buttons Management link, it takes you to the normal PayPal.com domain. Here's the working link to Manage Your Saved Buttons: sandbox.paypal.com/us/cgi-bin/webscr?cmd=_button-managementMarie
@Manvil Hi, Am getting a message "Sorry, this feature is not available at this time" When tried to signup for recurring payment using automatic billing . How can i solve this? Also the auto billing button is not displayed in dropdown when tried to create new paypal button in sandbox.Rese
@Manvil you rock! Your answer is it!Notus
G
11

Just a short add how to make the hosted button in the sandbox:

  1. Create and log in to your sandbox account on https://developer.paypal.com/
  2. Choose "Test Accounts".
  3. 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.
  4. Click the yellow button "Enter Sandbox Test Site".
  5. My Account >> Profile >> Selling Preferences >> My Saved Buttons
  6. 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 :)

Glyoxaline answered 29/6, 2012 at 1:55 Comment(5)
Thank you, I kept getting redirected through the normal way.Fronniah
Where is "Test Accounts" on your step 2 @Paul?Feverroot
there's no "yellow" button, and the "enter sendbox" link is redirected to merchant.paypal.com. See screenshot: tinypic.com/r/11v6651/5Jameejamel
For anyone running into this now, I tried to click on the "create buttons" image while in sandbox, and it redirected to the normal site. I added sandbox back into the url as the subdomain, and it loaded the sandbox version.Foretopsail
I cannot locate "Test Accounts".Stratification
P
2

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

Pereira answered 30/12, 2011 at 20:40 Comment(0)
P
2

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.

Plight answered 29/12, 2016 at 18:44 Comment(0)
S
1

Yes, you can test also on sandbox with following steps:

  1. Create a new sandbox business account.
  2. Login to the business account.
  3. Go with profile > My setting tools.
  4. Click on Paypal buttons > Update.
  5. Click on "Create new button".
  6. Fill up all following details you required.
  7. At last, you can get the form code with "hosted_id".
  8. You can paste the code in your website and you can test it.

Hope, These steps are useful to you.

Sungod answered 9/8, 2017 at 12:9 Comment(1)
This should be the real solution for 2020Exhume
E
1

This is now:

  1. Create a new sandbox business account.
  2. Login to the sandbox business account using https://www.sandbox.paypal.com/.
  3. Click on "pay and get paid" then "PayPal buttons".
  4. Choose "Buy Now" for the simple PayPal button which does not use an API call.

It is possible this button is now deprecated because the developer site does not seem to have it anymore.

Extensometer answered 14/11, 2021 at 5:33 Comment(0)
E
0
  1. Navigate to https://developer.paypal.com/dashboard/applications/sandbox
  2. From REST API apps click your desired APP
  3. Copy your Sandbox Account & Client ID
  4. Navigate to https://developer.paypal.com/dashboard/accounts
  5. Locate the same Sandbox Account and click Manage (3 Dots) then View/Edit Account
  6. Copy your System Generated Password or Change Password
  7. Navigate to https://www.sandbox.paypal.com/
  8. Login using your Sandbox Account + System Generated Password
  9. Navigate to https://www.sandbox.paypal.com/billing/plans and create the same plans as before
  10. Copy your plan ID, for example: P-2BPE0RQ33UO7KJ5A8GV0AE08
  11. Add this script tag and replace $clientId with your Client ID from (3)
<script src='https://www.paypal.com/sdk/js?client-id=$clientId&vault=true&intent=subscription' data-sdk-integration-source='button-factory'></script>
  1. Render your PayPal Button using the following JS code:
/**/
var params = {
    /**/
    style: {
        /**/
        shape: "rect",
        /**/
        color: "blue",
        /**/
        layout: "vertical",
        /**/
        label: "subscribe"
        /**/
    },
    /**/
    createSubscription: function(data, actions){ return actions.subscription.create({ plan_id: "P-2BPE0RQ33UO7KJ5A8GV0AE08" }); },
    /**/
    onApprove: function(data, actions){
        /**/
        alert("Subscribed!");
        /**/
    }
};
/**/
paypal.Buttons(params).render("#paypal-button-container");
/**/
  1. Navigate to https://developer.paypal.com/dashboard/accounts again

  2. This time locate your Personal Account, not the Business Account

  3. Copy the email address

  4. Click Manage (3 Dots) then View/Edit Account

  5. Copy your System Generated Password or Change Password

  6. Test your button using this Personal Account

  7. If everything goes well you will get a Subscribed alert

Enaenable answered 23/9, 2022 at 21:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.