PayPal integration in custom php cart - php

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.

Related

Send existing price to PayPal

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>

PHP Paypal Subscription Parameters

dear experts,
I'd like to add a VIP option on my website through subscription. Like an already existing member pay a monthly fee to gain features.
So I tried to use the paypal subscribtion button but I don't get how I can pass parameters like the account id to give him access.
I added variables but in the code they gave me, there is not way to change it :
<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="DUFC7HMH4RRJU">
<input type="image"src="https://www.paypalobjects.com/en_GB/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
Also I'm not familiar with the Paypal API, is there a way to do what I want easily ?
Thanks in advance.
You won't be able to with a hosted button. You'll need to go into the button editor and disable the option to save the button at PayPal. This will give you back button code with the parameters actually embedded in the code.
Then you can include the "custom" parameter and populate it with the value of your record ID that you need to track. That same value will back in the custom parameter of IPN so you can update your database accordingly.
A better, more secure option would be to go with the Express Checkout API. This will require some actual programming, though. If you're working with PHP I'd recommend taking a look at my class library for PayPal. It'll make that very simple for you.
If you decide to give that a try I can answer any other questions you have about it.

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.

Which user subscribed to my site via PayPal?

I have been developing a website with PHP in which users will subscribe and pay their subscription fees monthly to resume their memberships. To do this, I created a Subscribe button from PayPal and tested it with sandbox, I can receive the payment. However, I couldn't find a way to determine which user have subscribed.
Here is the HTML code for the PayPal button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BUTTONID">
<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">
</form>
As you can guess all users have unique IDs, I want to pass this unique ID to the PayPal page where payment is done then PayPal will pass this ID to me again, therefore the users account will be activated.
I have been searching for this for a very long time. There are many tutorials to do it with IPN but I can't see where to send the user id as an IPN parameter. I haven't managed to use PayPal APIs since their documentation is totally crap.
Maybe someone can give a link with a complete tutorial for this, or tell me what I understood wrongly?
Thanks
As far as I know, you can add up to 255 bytes of data to field labeled CUSTOM in just about every request to PayPal. PayPal returns this field in its responses and IPN's.
For something like subscriptions, I would recommend you to checkout the recurring payment mechanism offered by PayPal via NVP and SOAP. It is not that easy as just generating a button and placing it on your website but since you already wrote an entire website in PHP, you will not have any problems coding it. Recurring payments should provide everything you need to let your users subscribe and pay a monthly fee, including the ability to track who is who.

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