Does paypal generate any event after clicking pay now button? - php

I've a shopping cart implemented in PHP and the checkout process is handled by PayPal. When the customer presses pay now button in PayPal, does it generate any events so that i may process that information and based on the stock levels in my database decide whether to accept the payment or not?

No, but you can do that after payment with PayPal IPN, it sends all the data about purchase back ..

You could use javascript to query your server about stock levels on-click, and submit the form if everything looks OK.

Related

Paypal shopping cart - Setting database value when successfully completed transaction

I've got a question about the PayPal transaction system. I try to implement a paypal shopping cart in my website. But what I want to do is I want to have like "PrePaid credits" on my website. So when the transaction successfully processed. A database value will change given the credits the user wanted to buy.
I dont have a idea on what to search for. I only know standard php. Not any modification such as paypal. So can anyone give me a code/website where I can find some usefull code?
Thank you!
PS: If you have any suggestions on the post to make it even clearer please comment.
You would use the PayPal IPN (Instant Payment Notification), so a user would click 'Purchase x credits' on your site (you would have a custom field with the user's ID, it would then take them to PayPal via custom form you put together, that form has a return URL which after the payment has been successfully made, would return them to that URL, and you would make that success return URL update your database with the details.
So on a successful return from PayPal, your page would update the database with the custom value (User ID) we initially passed in the form along with the amount of credits they purchase (this can be passed via custom value OR you could just use PayPal's callback information returned with the query (it'll be posted to your page from PayPal I believe).
PayPal Sample Code
Getting Started with the PayPal IPN
Nettuts - Using PayPal's Instant Payment Notification

Paypal - Dynamically change HTML variable for "Buy Now" button?

I'm new to Paypal integration. I need to dynamically change the HTML variable to the Buy Now button since I need to calculate discount_rate and shipping.
At first I use the hosted button, but then realized that I can't add new variables.
So I found this alternative way which is creating our own button. But then the customer can simply "Inspect Element" and change the value of the input.
Is there better and more secure way to implement dynamic pricing for Paypal?
Can I submit the payment through backend script like PHP?
Thanks
You can use the PayPal express checkout API to create a purchase in the background then send the user to PayPal with a token linked to this purchase.
if you do go down this route, I recommend using this class as it is very simple, yet powerful;
https://github.com/thenbrent/paypal-digital-goods/
On the other hand you can continue what you are doing with the non-hosted buttons and simply check the gross amount paid by the user against what they should have paid in your notify script.

Receive form only if Paypal payment is complete

I'm looking for a way to receive a form result by email only if the payment has been completed on Paypal.
I have a form next to my shopping cart.
I want people to fill the form, then they can browse in the shopping cart.
Once they click on "Checkout" in the shopping cart, they are redirected on Paypal.
The form I talked before is still on hold...not sent yet.
When the guy fills his credit card information, click Proceed on Paypal, and THEN...
When the payment is complete, the form he filled on my website will be submited.
But if he decide to close the paypal window and stop shopping, I won't receive it.
I need your help guys/girls.
I'm not sure what language I need to make this work.
I'm guessing PHP and Javascript.
Thanks a lot,
This function is very important for us.
Check out the IPN (Instant Payment Notification).
https://www.paypal.com/ipn/
It will send a message to your server after a payment has been made, sounds like what you are looking for. You can write the listener in PHP and they provide example code.

How to Integrate Paypal IPN for Custom Shopping Cart without using Buy Now Buttons

I'm having some trouble understanding how I can send my shopping cart items to PayPal using the IPN service without using the 'Buy Now' buttons which many tutorials seem to demonstrate.
So my shopping cart details are stored within $_SESSION['cart'] as a multidimensional array.
e.g:
$_SESSION['cart'][0]['item_price']
$_SESSION['cart'][0]['item_name']
$_SESSION['cart'][0]['item_description']
$_SESSION['cart'][1]['item_price'] ...
I know that a listener is involved for the rest of the process however I cannot see how I can send the item details such as name and cost to paypal for payment processing.
Is cURL involved in anyway. Any information would be very helpful!
IPN stands for Instant Payment Notification. IPN itself is a POST from PayPal's servers to a page on your site to let you know that a transaction has completed (or failed).
To send a shopping cart to PayPal without using the simple button method you need to use the PayPal API. Check out the SetExpressCheckout method, which initialises a cart/checkout on the PayPal site. This will give you an ID/URL you can use to redirect your customer to at a later time.
See:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout

click pay now in paypal page update my database too

I have a table to store my credit from user has been paid.
credit
+id
+amount
My goal is when you user click on button pay now in paypal page I have abiltity to update my table the amount field.
Anybody know the ways to do this,
thanks
EDIT: look at this code
http://www.micahcarrick.com/04-19-2005/php-paypal-ipn-integration-class.html
If the button goes off to PayPal, you'll need to intercept the request first, either with AJAX, or send to a PHP script, and then send on through to PayPal.
PayPal's Instant Payment Notification protocol is usually what's used to do this.

Categories