Send existing price to PayPal - php

Currently i have PayPal working on my website for booking venue's etc. I have the deposit (which is a set amount) being paid through PayPal and it works perfectly.
After the deposit is paid, the outstanding amount (the amount still to be paid) is saved into the database.
What i want to do is set the price of my PayPal button to be this outstanding amount when a customer wants to fully pay the outstanding amount.
However, I've looked around and can't find anything that specifically matches my description. I haven't even attempted this as i have no idea where to start.

You can retrieve the Saved amount(stored in database) and pass it to the paypal button code.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Test">
<input type="hidden" name="business" value="YOUR_PAYPAL_EMAIL">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="amount" value="STORED_DATABASE_AMOUNT">
<input type="image" src="https://www.paypal.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.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Related

How to secure Buy Now Paypal button?

I want to create a "Pay what you want" paypal button with minimum amount set.
I am adding the following code on my website
<form name="_xclick" action="https://www.paypal.com/us/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="YOUR EMAIL ADDRESS" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="item_name" value="YOUR_PRODUCT_NAME" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="address_override" value="1">
<input type="number" name="amount" value="5" placeholder="5" min="5"/>
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
Since this code is easily visible on the source code of my web page
1) Anyone can see my email
2) Anyone can change the code to start paying say EUR 0.01. Since I will be charged for each transaction 1.9% + EUR 0.35, someone can easily piss me off!
Please let me know is it safe!
Note :
1)I have no issue regarding payment with a changed price since I will first see the transaction and then deliver the product.
2)I don't want a hosted button because I need variable pricing and don't want to use donate button (as it is not for personal blog fundraising, I guess).
Thanks!
There isn't any way to do it with the standard buttons. A user could easily tamper the payment between your site and PayPal. The only way to do it would be with the encrypted website payments.
Read more here: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/encryptedwebpayments/#id08A3I0P017Q
You must be comfortable programming in scripts like PHP and ASP to use Encrypted Website Payments.
This will make your payment buttons tamper proof.

PayPal - after payment with php

I've set up a payment button on my website and users can choose what they want and make payments fine. What I am struggling with is working out how to give them what they paid for. So for example they paid $10 for a book, I want the book to be awarded to their account once the payment has gone through.
What I've found is that you need to use an IPN but for that you need an API, whatever these are. Is this the only way to do it in php? Looks very complicated for such a simple task and I'd rather get them to send payments to me and I will manually add what they paid for.
EDIT
Here's what I'm following: https://developer.paypal.com/webapps/developer/docs/classic/products/instant-payment-notification/
This is how I set up my paypal checkouts in my websites:
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="YOUR SANDBOX SELLER EMAIL">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Digital Download">
<input type="hidden" name="amount" value="9.99">
<input type="hidden" name="return" value="THIS URL">
<input type="hidden" name="notify_url" value="THE URL TO YOUR ipn.php SCRIPT">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"
border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Inside your ipn.php you can add a sql statement to change the user access to the book.
I have found this tutorial very useful when it comes to paypal forms:
http://www.micahcarrick.com/paypal-ipn-with-php.html
Paypal form API:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/formbasics/

PayPal integration in custom php cart

i had created a custom cart and i want to add pay pal button in it how should i integrate it with my cart. I got this form code for pay pal but i cant understand that where are we passing the papal's user account id and what is 'cmd' and 'hosted_button_id' for. I am really new to paypal i just want to add a button and send client purchase information to my paypal account.
<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="ZEFZFYBY2SZB8">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
If you're trying to tie PayPal into your custom cart you should probably look at the cart upload method.
If you're familiar with API's you could look at Express Checkout, too. My PHP class library would help you integrate Express Checkout pretty easily.

Dynamically generating PayPal buttons

What's the best way to dynamically generate an "Add to Cart" PayPal button in PHP? My idea is to take the basic HTML code and simply echo the required variable but I'm not sure if it's the most secure way...
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me#mybusiness.com">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="item_name" value="<?=$name?>">
<input type="hidden" name="amount" value="<?=$price?>">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
(Code above from PayPal's Advanced Techniques page)
Doing it that way isn't very secure because people can still view source and see the end-result on your page. Then they could take that, make changes to it, load it in their own browser and pay you for an item at a much lower price.
You can utilize IPN to help flag orders that don't look accurate by cross-references your pricing, but this can be a hassle.
You could use the Button Manager API to generate your buttons as hosted buttons on PayPal. This way people can't see the details in the source code and wouldn't be able to make changes.
Alternatively, you could use the Express Checkout API which is what I prefer and recommend if you know how to work with web service API's.

Integrating Automated Paypal shop system?

Hey guys for my website I am trying to figure out how to make an automated paypal shop, what I mean by that is when they purchase membership via paypal by clicking a paypal button on my website it will also change a value inside of my database for that specific user.
So in a timeline fashion:
User clicks buy button and purchases item.
After payment is complete, redirect to my php script which updates the users membership status.
Currently All I need help on is how to make it automatically redirect after the payment is complete. I followed some code but it still didn't work, here is what I'm using.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="MY EMAIL">
<!-- 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="return" value="MY URL TO REDIRECT TO">
<input type="hidden" name="item_name" value="Sponsored (1 Month)">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="currency_code" value="NZD">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
</form>
That code leaves you at the Paypal "payment complete" page, but I want it to automatically go to the return url on payment complete.
that's not how paypal works, you can't rely on the visitors return, you use the IPN (Instant Payment Notification) feature of paypal, read its docs on how this works.
Instant Payment Notification - PayPal
Is your return url really "MY URL TO REDIRECT TO" or is it something like "http://myURL.com/myPage.asp"? The first one wouldn't work, obviously.

Categories