0

I'm creating a PayPal buy now button which is not hosted (I've unchecked "Save button at PayPal") and changed the amount using the HTML form but it does not change here's the code

<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="encrypted" value="-----BEGIN PKCS7-----ENCRYPTION CODE HERE-----END PKCS7-----">
<input type="hidden" name="item_name" value="subscription">
<input type="hidden" name="amount" value="100.95">
<input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">

and the test page url: http://mawk3y.net/pay.php when you click the buy now you will find out that the value is 0 so how can I change the amount value?

PHP User
  • 2,350
  • 6
  • 46
  • 87

1 Answers1

2

_s_xclick is the secure (or saved) xclick command to which you submit an encrypted (or saved) button. But you cannot have plaintext fields in an encrypted button; you can only do that in a plain button (that's the point of encrypted buttons). You are mixing the two.

Either encrypt the button with the price inside the encrypted blob and submit to _s_xclick, or make the whole button in plain text fields (no encryption) and submit to _xclick.

geewiz
  • 2,206
  • 1
  • 10
  • 16
  • Removed Encryption and added the code of the amount and now it's working thanks a lot for your help. Just a question: does the return URL (the page that user will be redirected to after the payment) receive all sent hidden fields of the form like and I feth them using $_POST['custom'] is that correct? – PHP User Jan 03 '15 at 15:51
  • No, PayPal does NOT provide unlimited passthrough of your data. PayPal will send back only the documented return fields. Some of the input fields (such as custom and invoiceid) are also return fields so these do provide limited passthrough capabilities. But if you want more information to "connect" between your pre-payment and post-payment pages you will need to arrange that yourself using cookies or other mechanisms. – geewiz Jan 03 '15 at 16:37