This is not a duplicate of this post.
I quote from the linked post:
As of June 29, 2017 I see this not working. Paypal has again changed its rules, and I don't think it any longer accepts hidden HTML fields in the form submission: they must be set in the button editor at Paypal.
Paypal documentation is a mess. Half of the links are broken and the other half of the links point to the documentation index.
Does any brain out there know how to achieve a Paypal Payment Button where I can set the price dynamically?
PayPal button Changes the background color of the button and adjusts the wordmark color to be visible. The default value is gold , but you can also set it to: black , blue , silver , or white . Overrides the shape of the button. The default value is softEdges , but you can also set it to hardEdges or rounded .
PayPal recommended to use Express checkout client side integration and you can send the amount dynamically from your website to PayPal code.
Refer the following links for PayPal Express checkout client side integration:
https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/client-side-REST-integration/
https://developer.paypal.com/demo/checkout/#/pattern/client
Otheriwse, please try with the below PayPal HTML button code.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="[email protected]"> <!-- Add your PayPal Seller/Business email address Required-->
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value=""> <!-- Add Description e.g your room type Required-->
<input type="hidden" name="amount" value=""> <!-- Dynamically add Total Amount Required-->
<input type="hidden" name="currency_code" value=""> <!-- Update to your currency -->
<input id="invoice" type="hidden" value="" name="invoice"> <!-- Add Unique invoice for each transaction -->
<input type="hidden" name="notify_url" value="www.yourwebsite.com/ipn.php"> <!-- Please add IPN URL You can use this service to automate back-office and administrative functions, including fulfilling orders, tracking customers, and providing status and other information related to transactions. -->
<input type='hidden' name='cancel_return' value='' /> <!-- Take customers to this URL when they cancel their checkout -->
<input type='hidden' name='return' value='' /> <!-- Take customers to this URL when they finish their checkout -->
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
</form>
HTML Variables - https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
Buy Now button - https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/buy_now_step_1/
IPN - https://developer.paypal.com/docs/classic/ipn/gs_IPN/
IPN - https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/
IPN Sample: https://github.com/paypal/ipn-code-samples
<form name="_xclick" method="post" action= "https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="XXXX">
<input type="hidden" name="notify_url" value="http://XXXXXXX.com/ipn.php" />
<input type="hidden" id="buybuttonid" name="custom" value="XXXXX" />
<input type="hidden" name="amount" value="amount that you want to send">
<input type="submit" value="Buy Now">
</form>
Please use this button and don't pass the item number and quantity then it will not set amount dynamically.
Just create simple buy now button and make price/amount value blank at time of creation of button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With