can't POST item price in paypal sandbox - paypal

<form 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="YYHZM9FTBZQGW">
<input type="hidden" name="amount" value="20.00">
<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>
this is a paypal sandbox button. all i want to do is to post the TOTAL price of all the product the user buy in my website.
I created a button with nothing to post because basically i want to post dynamically in the future using a php variable so I think I don't need to set up the item price, name, quantity in the sandbox create button features. how am i suppose to do that.
this is the output. I want the item price to be not editable same as with description and quantity

The reason you can't override the amount dynamically, is because you have a so-called 'PayPal hosted button'.
With a hosted button, the amount is stored on PayPal's side and can't be overwritten with the 'amount' variable.
You'll either want to use a non-hosted button, or use the BMUpdateButton API call to dynamically update the button's amount.
An example request for BMUpdateButton would look as follows:
USER=Your API username
PWD=Your API password
SIGNATURE=Your API signature
VERSION=82.0
HOSTEDUBTTONID=The value of <input type="hidden" name="hosted_button_id" value="">
BUTTONTYPE=The type of button. E.g. BUYNOW
BUTTONCODE=The type of code you want to get back. E.g. HOSTED
L_BUTTONVAR0=amount=The new amount with a period as separator
L_BUTTONVAR1=item_name=Optional: a new item name if you wish
Similary, you could also use the BMCreateButton API to create a new button, or use the BMButtonSearch API to search through a list of all your stored hosted buttons (to find the hosted_button_id of your button automatically, for example)
The reason to use a hosted button is because it's more secure. A non-hosted, unencrypted button would basically leave the amounts open to manipulation. Fraudulent transactions waiting to happen.

Related

How can I change Hidden Value in Paypal Button

We are creating a simple sales site for local pickup no shipping, so in keeping it simple, we decided to use Vb.net and SQL Server, creating a catalog page and detail page with buying it now Paypal button. In using SQL server it will fill out the details page but we like it to be able to change the "value" in the following line : . (the value is given when creating a button, but stored the value in SQL) Is there a simple solution
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="?????">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Thinking about this more, you're probably going around this the wrong way. There is no reason to store hosted button IDs in a database; such buttons exist for limited HTML-only websites.
Since your website is not limited to HTML, dispense with hosted buttons entirely and render buttons using a standard PayPal Checkout integration, which uses the JS SDK (and can optionally communicate with a backend to create and capture an order--see the full stack example in that guide, the backend routes of which can be implemented in whichever environment, .net in your case)

Paypal is not overriding the return URL?

I need to override the given default Auto return URL from the paypal button HTML code. I followed these steps:
Check the Auto return Url section and gave a default URL
Generate a Buy Now button and left the Return and Cancel URL options as it is.
Paste the button code
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="return" value="http://www.someURL.com"/>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="G3WQ*******">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/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_GB/i/scr/pixel.gif" width="1" height="1">
</form>
After successful payment on Sandbox PayPal is always redirecting me to the default URL.
Why isn't overriding it? Any help would be appreciable.
I saw a couple of similar unanswered question on PayPal community and StackOverflow as well:
https://www.paypal-community.com/t5/About-Payments-Archive/Auto-Return-Custom-URL-Not-Overriding-Auto-Return-Setting-URL/td-p/1038334
Paypal button auto-return url not overriding the default url
Setting PayPal return URL and making it auto return?
You won't be able to use the return field directly in the button when you're using a hosted button. That has to be set in the hosted button settings when creating the button (or editing it through the PayPal account.)
If you want to be able to set your own return URL on the fly then you'll have to use a non-hosted button.

Error Detected - Paypal

I can't understand why I get this annoying error message when I test out the paypal button in sandbox test site.
Error Detected
PayPal cannot process this transaction because of a problem with the seller's website. Please contact the seller directly to resolve this problem.
I've tried using different test accounts and I get the same thing.
Here are the codes for the paypal button:
echo 'form action="https://www.sandbox..../cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="FDN9DZRLVBQRL">
<input type="image" src="https://www.sandbox....scribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox....i/scr/pixel.gif" width="1" height="1">
</form>';
You're using a hosted button, so you need to make sure that it was created from (and still exists in) the account you're testing with.
If you're testing with the sandbox you need to create the button from that sandbox account in order for it to work.
Keep in mind that is only the case when working with hosted buttons.
Replace the form action with this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
You are pointing to Sandbox endpoint, where the hosted button belongs to LIVE account.

Paypal: trying to pass an amount with a Donation button

I have a Donate button set up for the user to enter the donation amount. I am trying to send an amount with the button. I can enter amount=1.00 in the Add Advanced Variables in the button setup - that works fine. However, I have had no success sending the amount as part of the URL. I have added the following line to the PayPal button form:
<input type="hidden" name="amount" value="9.99" />
but the amount field is blank when I get to PayPal. Any thoughts what I am doing wrong?
If you're creating a so called 'hosted button' (that is, a button where the button details are stored on the PayPal side), then the 'amount' POST parameter is ignored for requests to https://www.paypal.com/cgi-bin/webscr.
This is a security feature to prevent people from being able to manipulate the amount passed to PayPal for checkout.
You can identify whether you're using a hosted button by the following data;
Hosted buttons will have a value for cmd of _s-xclick and include the hosted_button_id parameter.
If this is the case, you cannot update the amount by passing in an extra amount POST parameter.
However, because you're dealing with donations and the amount is flexible by definition, you don't in fact need a 'hosted button'.
In the button creation form, turn off 'Host button with PayPal', or write your own to point to PayPal.
If you do this, you can set the amount via the amount POST parameter.
For example, the below works fine;
<form method="POST" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_donations">
<label for="amount">Amount: </label><input type="text" name="amount" value="">
<input type="submit" name="submit" value="Pay with PayPal">
</form>
Robert's solution is on the right track, however a non-hosted PayPal form will not work without the hidden "business" field (which should have a value of the email address associated with your PayPal account.)
Other fields should be included for thoroughness:
<input type="hidden" name="business" value="myemail#here.com">
<input type="hidden" name="item_name" value="Donation Description">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">

Amount is not displaying in paypal form

I am using the following paypal code but still the amount is not displayed in paypal form once the website redirect the page to paypal.
`<form 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="XXXX">
<input type="hidden" name="amount_1" value="200">
<input type="image" style="width: 70px !important; padding: 0px !important;" src="http://www.merlioncricket.com/Login/static/images/payment.png" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>`
Please let me know, why the amount is not displaying.
Thanks,
Gladiator
Finally I found the answer, & maybe it is useful to others, whenever you create the paypal button make sure in step 2 "Save Button At PayPal" is not clicked & second once you create the button, remove code protection & then select the code & copy the paypal generated code.
It will solve the problem.
Thanks....
When using a hosted button, you can not pass over an amount. The hosted buttons, prevents someone from directly modifying the code and passing over a different amount. If you are wanting a different amount, you would need to log into your account and edit the hosted button. If you want to dynamically populate the amount, then you would need to create a non hosted clear text button.