How do I edit the input fields of paypal sandbox? - php

<form action="https://www.sandbox.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="QHHYRZWR44QMY">
<table>
<tr><td><input type="hidden" name="on0" value="WeBoss - Downpayment">WeBoss - Downpayment</td></tr>
<tr><td><select name="os0">
<option value="Combat">Combat P1,000.00 PHP</option>
<option value="Battlefield">Battlefield P1,500.00 PHP</option>
<option value="Warfield">Warfield P2,100.00 PHP</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="PHP">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
Cancel
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
i would like to edit the price, how would i do that? and also i tried in "BUY NOW" button and change amount but still it wont change the price.
is there a way to edit the paypal sandbox page?

With a hosted buttons, you cannot dynamically change the amount in the code.
To be able to change the amount in the code, use a non-hosted button instead. To create a non-hosted button, log in to your paypal.com account to re-create the button again, but this time, click on Step 2 and un-check the option to save button at PayPal. After clicking on 'create button' click on 'remove code protection' to get a clear-text button code.
NB. However, using a clear-text button code is un-secure as someone can change the values in the code prior to submission of the button.
So instead, you can use 'BMCreateButton API' to dynamically create hosted or encrypted buttons.
https://developer.paypal.com/webapps/developer/docs/classic/api/button-manager/BMCreateButton_API_Operation_NVP/
Samples http://paypal.github.io/sample-apps/ [Classic API Samples]

Related

How to add specific amount in PayPal Donation

I'm trying to add a donation page with paypal integration. It works perfectly fine. But what I want to add is to first sign the form from my site and then send it to paypal as well as the selected amount of donation. I've also trid to put this code <input type="hidden" name="amount" value="<?php echo $total; ?>"> as per my research. But it's still not working. Please see my code below for your review/reference.
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="hosted_button_id" value="QWEVB36VTJYEG">
<input type="hidden" name="amount" value="88.00">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_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>
The result would be just like this: (Blank Value) (The value must be 88.00)
As far as I know, donations on Paypal can't be restricted to one single value. The amount input is ignored, to be sure that people who will donate are not being manipulated and forced to pay a price they did not choose.
However, if you want to propose some fixed prices, here is a Paypal Community code which will help you doing that.
EDIT: Here is a StackOverflow answer which is pretty clear and confirms my thoughts.

PayPal simple upload cart using one button - why is shopping cart empty?

I'm trying to upload a cart with the following code, but when the user hits the "buy now" button, then instead of showing PayPal's order summary page where the user can sign in to pay, I get an error that says Your shopping cart is empty.
This is my code, what's wrong with it?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<a href='cart.php?type=current' class='buttonlink previous'>Edit Order</a> <a href='checkout4_confirm.php' class='buttonlink next'>Submit Order</a>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="hosted_button_id" value="JRECLRTYAJDKY">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="XXX#XXX.XXX">
<input type="hidden" name="item_name_1" value="<?php echo $order_number; ?>">
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="quantity_1" value="1">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.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>
This is most likely being caused by the fact that you are creating a hosted button from your account, but then you are making modifications to the code. If you are going to do this, you need to create a clear text, non hosted button.
When creating the button from within your account, uncheck the option on step 2 to save button at PayPal. Then once the code is generated, click the link to remove code protection. This will create a clear text non hosted button. Then you should be able to modify the button.

Adding item total to PayPal's order summary, for full aggregate cart payment

I've got my own shopping cart and everything set up, I just need a "Pay Now" button for my website users, and I just intend to send the entire cart's total amount up to payPal, that's it, no other integration necessary. So the customers on my website have already reviewed their order, checked quantities and shipping charges etc for individual items, and now PayPal just needs to be given the total amount which they will confirm and pay.
My code for the "Pay Now" button is below ($overall_total has already been calculated somewhere above in my php code):
<form 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="JRECLRTYAJDKY">
<input type="hidden" name="amount" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_total" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_name" value="Your Shopping order">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.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>
The user submits this form when they hit "Pay Now", and they come to next page. But Even though I included the amount and item_total variables, the next page gives me an item_total of 0.00. Also, I don't want any Quantity or Item price to show since I am simply implementing an aggregate cart payment for customers, and they have already reviewed per item charges before coming to the payment. This is what I get:
How can I get rid of Quantity and Item price, and have the $overall_total value that I calculated inside the total price on the PayPal summary?
there is no item_total or any total, since every single button handles ONE item at once
$overall_total must be in the english format with "." as decimals separator
problem may be the cmd parameter.. use instead:
<input type="hidden" name="cmd" value="_xclick">
also you need to specify:
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
look at this for a more complete example:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="amount" value="10.10">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Item bought desc">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynow_SM.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.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>
also have a look at:
the documentation of cart parameters: HTML Form Basics for PayPal Payments Standard
the cart button builder: Create a PayPal payment button
about the "quantity" issue, sadly you can't hide it... if this is an important issue for you, you could try instead the ExpressCheckout (using php) which is very customizable and not that difficult to implement
hoping to be helpful
The most straightforward way to get around the Qty:1 issue of simple 'Pay Now' buttons is to implement 'Cart Upload' instead, which is how 99% of shopping carts implement Standard. See: PayPal's Cart Upload Documentation
If you are a programmer who can handle API calls, I instead recommend using Express Checkout (perhaps with SOLUTIONTYPE=Sole) rather than a Standard form post like Cart Upload. EC is a more robust interface to program against and essentially a free upgrade to Standard that's available to all PayPal seller accounts.

php script in paypal form

I am writing a php script in Paypal form. I am sending return url using $testUrl variable which will work after successful payment but it is not redirecting to that url.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<select name="amount">
<option value="10">10 SEK</option>
<option value="20">20 SEK</option>
<option value="30">30 SEK</option>
</select>
<?php $testUrl= "http://www.google.com"; ?>
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="3FWC3TJEYANK4" />
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_donate_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" />
<input type="hidden" name="notify_url" value="http://beeurban.ayond.com/wp-content/payment/ipn.php" />
<input type="hidden" name="currency_code" value="SEK" />
<input type="hidden" name="return" value="<?php echo $testUrl ; ?>" />
</form>
The auto return option need to be activate in your paypal account.
See here : Setting PayPal return URL and making it auto return?
Please look at #andrew's answer below : https://stackoverflow.com/a/13468873/1722914
Your problem is that you're using a hosted button. You can't add additional fields to the button code like this when you're using hosted buttons. Everything has to be configured within the button manager in your PayPal account. Your notify_url probably isn't working either, from what I'm seeing, because that would have to be setup in the button manager, too...unless you have the same notify URL setup in your profile under Instant Payment Notification Preferences. Then that would take effect, but what you're passing here would be ignored.
In the button manager, Step 3 - Customized Advanced Features, has an option for "Take customers to this URL when they finish checkout" that you need to enable and fill in your return URL there. You'll also see under "advanced variables" that you can add notify_url there.
Unfortunately, you can't use dynamic values like you're attempting to do with that PHP variable for the return URL. If the return URL is something that can change depending on the order you'll need to use a non-hosted button.
To do that, in Step 2 - Track Inventory, Profit & Loss, you'll need to uncheck the Save button at PayPal box. This will give you different HTML code that will have more fields included, and then you can add your own values for return, notify_url, etc.
http://jream.com/public/lab/paypal_ipn.class.php
this may be helpful in guiding you

PayPal Buy Now button: Add my own price?

I have a form that a user fills out prior to reaching the PayPal Buy Now button. The form contains information such as the users name and the amount they will be paying (in a hidden field).
I know there probably is a way to pass the name variable to PayPal using the Advanced Variables feature, but is there a way to alter the buttons price?
And can I do this using PHP variables?
Eg: item_name=<?php $myitem ?>
Any advice would be great! Thanks
EDIT: Form as requested
<form 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="XXXX">
<input type="image" src="https://www.paypalobjects.com/en_AU/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_AU/i/scr/pixel.gif" width="1" height="1">
</form>
If I understand correctly your question, you have to put the amount hidden field on paypal form.
e.g.
<input type="hidden" name="amount" value="100">
<input type="hidden" name="currency_code" value="USD">
This form will prompt paypal to ask $100 from buyer.
of course you can add your own var there e.g.
<input type="hidden" name="amount" value="<?php echo $amount;?>">
HTH
I cannot even get this working with an unhosted button. It seems Paypal never lets you change the amount. I see it like this :
hosted button : amount is set in the code pointed to by the 'hosted button id'
unhosted button : PayPal encrypts the information, of which amount is part of
so, in either case you cannot change it, or at least, I haven't been able to do this.
Having said that, there is a variable called 'amount' you can use. So, I'm very confused about this.

Categories