I am trying get two different Paypal hosted buttons on my website to work: Add to Cart and Subscribe". The Add to Cart button works. The Subscribe button doesn't.
Possible hint: notice the first line of the working code – Add to Cart – the atribute action has the word sandbox in the url. The non working code – Subscribe – complains about my account: it says the email and password are not correct. The Subscribe button doesn't allow me to add that sandbox word to the action Url: if I add the sandbox word to the Url it throws an error like "something is wrong with the seller website".
Both buttons were created on a live account.
Any thoughts on why this is happening?
Here is a working JS fiddle: https://jsfiddle.net/joaoalvesmarrucho/h7ranpbu/1/
Here is my code on a snippet but code doesn't work here because: security
div {
display:inline-block;
color: white;
padding: 3px;
text-align: center;
font-family: sans-serif;
}
.notWorking {
background-color: red;
}
.working {
background-color: green;
}
h1 {
color: white;
font-size: 1rem;
}
<div class="notWorking">
<h1>
Nor working
</h1>
<form v-if="userIsLogged && plan.name=='Small Venue'" action="https://www.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="GFCVDZUFPDSPN">
<table>
<tr><td><input type="hidden" name="on0" value="Select No. of Sensors">Select No. of Sensors</td></tr><tr><td><select name="os0">
<option value="Up to 5">Up to 5 : £37.50 GBP - monthly</option>
<option value="Up to 10">Up to 10 : £75.00 GBP - monthly</option>
<option value="Up to 15">Up to 15 : £112.50 GBP - monthly</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="GBP">
<label>
<input type="image" class="cartinput" src="https://www.paypalobjects.com/en_GB/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
</label>
</form>
</div>
<div class="working">
<h1>
Working
</h1>
<form v-if="userIsLogged && product.name == 'Sensor W85/H200'" target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="PHXUV7YX2SZY6">
<table>
<tr><td><input type="hidden" name="on0" value="Select quantity">Select quantity</td></tr><tr><td><select name="os0">
<option value="1 Sensor">1 Sensor £31.90 GBP</option>
<option value="10 Sensors">10 Sensors £319.00 GBP</option>
<option value="100 Sensors">100 Sensors £3,190.00 GBP</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="GBP">
<input type="image" class="cartinput" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="Add to cart">
</form>
</div>
PS: Please use sandbox account to test if you can help. I'm using VueJs so please just ignore the vue directives as the html code works just as well without vue.
You are working with hosted buttons. A hosted button is directly related to the exact PayPal account that it was created in.
It sounds like what you are trying to do is take a button that was created in a live PayPal account, and simply switch the action so it works in the sandbox. This will not work, because that hosted button ID is not related to that sandbox account.
If you want to test hosted buttons in the sandbox you will need to create a separate hosted button from within that sandbox account to match what you did in the live account.