Check PayPal Payment Is completed - php

I have problems to make my PayPal system payment.
1. User add on cart the elements him want. (In this example, user select 3 items: PDF - HTML, PDF -JS and PDF -JS)
2. In page when appear that 3 items and button to pay (shoppingCart.php), have the next code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="myEmail#domain.com">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="item_name_1" value="PDF - HTML">
<input type="hidden" name="amount_1" value="5">
<input type="hidden" name="item_name_2" value="PDF - JS">
<input type="hidden" name="amount_1" value="7">
<input type="hidden" name="item_name_3" value="PDF - CSS">
<input type="hidden" name="amount_1" value="10">
<input type="hidden" name="return" value="PaymentCompleted.php">
<input class="btn btn-primary mt-2 m-b-20 " type="submit" value="PayNow">
<form>
3. When user completes payment, on PayPal windows, click to "Return to Shop" and go to page "PaymentCompleted.php".
4. On "PaymentCompleted.php" have a SQL script who add that 3 items on clientArea payments.
Problem I have, are the next:
If user add that 3 items, and go to PaymentCompleted.php, SQL Script add to it ClientArea without do payment.
How I can check if PayPal payment has been completed and else, prevent SQL Script add that items to clientArea?
Have a good day

Related

Unable to pass amount in paypal using _xclick

I am trying to create simple PayPal button who pass amount and quantity details to PayPal. I am unable to pass hardcore amount in PayPal. I am expecting to show result like this:
Expected output
Problem is that my amount is not transferring to PayPal. Please support to resolve. Here is my code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" amount="1.0">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="hmmdmlk#gmail.com">
<input type="hidden" name="item_name_1" value="Item #1">
<input type="hidden" name="amount_1" value="1.00">
<input type="submit" value="PayPal">
</form>
When using _xclick, which is for operations on a single item, you want:
<input type="hidden" name="item_name" value="The item name.">
<input type="hidden" name="amount" value="1.00">
The multi-item parameters you were using would be for _cart with upload=1, not _xclick
Documentation: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx-websitestandard-htmlvariables/

how to use paypal subscription form for multiple subscriptions?

I am trying to use paypal subscription form for multiple product, but its not working.
Here is my form which i used.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="archirayan9#gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="item_name" value="Baseball Hat Monthly - test2 " />
<input type="hidden" name="item_number" value="asd">
<input type="hidden" name="a3" value="10.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
</form>
This form is for 1 product subscription. I want to make it for multiple products with different item_id.
I cant found any thing that help me to setup multiple product subscription using this form.
Anyone have solution how to do?

How can i send multiple items through buy now button of Paypal

I desperately need some help, I cannot find the answer anywhere.
What I need to build is a "buy now" form (or button) where it send multiple items. I am selling tickets for an event, which has different prices for Adult and Child tickets. I have already used the "Add to cart" buttons individually, but my older customers are stuggling with this, especially mobile users. Also, this is really not the most professional way of doing it in my case.
Just as an example, here is a form which is similar to what I need: http://lowfestival.es/abonos/ (I know this is not a paypal form, nor the same, but im sure you understand.
I just need 2 items (Adult and Child) with 2 quantity boxes and the Pay Now button.
If this is not possible for some reason, can anyone recommend a free 3rd party cart which could do the job?
Many many many thanks in advance for any help.
Kindest Regards
The Cart Upload command will do this for you: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/cart_upload/
For example:
<form action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="youremailaddress#yourdomain.com">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="item_name_1" value="First item name">
<!-- Change this to the price of the first item -->
<input type="hidden" name="amount_1" value="15.00">
Quantity of first item:
<input type="number" name="quantity_1" size="2" min="1" max="99" required="required"><br>
<input type="hidden" name="item_name_2" value="Second item name">
<!-- Change this to the price of the second item -->
<input type="hidden" name="amount_2" value="20.00">
Quantity of second item:
<input type="number" name="quantity_2" size="2" min="1" max="99" required="required"><br>
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/btn/btn_buynow_cc_171x47.png">
</form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="youremail#mail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name_1" value="beach ball">
<input type="hidden" name="amount_1" value="42">
<input type="hidden" name="item_name_2" value="towel">
<input type="hidden" name="amount_2" value="13">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" name="submit">
</form>

paypal notify_url not working and tx ID variable not pass to thank you page

Here is my paypal buy now html code:
<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="alex#xumanii.com">
<input type="hidden" name="item_name" value="Bewolf Shooping Cart">
<input type="hidden" name="amount" value="<? echo $grandtotal2;?>">
<input type="hidden" name="add" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="member_id" value="<? echo $info['member_id'];?>">
<input type="hidden" name="return" value="http://www.bewolfclothing.com/thankyou.php">
<input type="hidden" name="notify_url" value="http://www.bewolfclothing.com/notify_paypal2.php">
<input type="hidden" name="cancel_return" value="http://www.bewolfclothing.com/mycart.php">
<input type="hidden" name="undefined_quantity" value="0">
<div class="submit-container"><input class="submit-button" type="submit" name="submit" value="CHECK OUT" /></div>
</form>
In my paypal account, under profile, my selling tools, I have set the AUTO RETURN to ON and I put the thankyou page in there.
After the purchase, it goes to the thankyou page, but the $_REQUEST['tx'] for the paypal transaction ID is not working and the notify_url NEVER gets called.
I searched online and saw that lots of people seem to have trouble with that, but I couldn't find a solution.
notify_url is used to Instant Payment Notification and the url should always be a live URL.
To get the tx ID, you need to
-Auto Return is set to ON
-Valid Return URL
-Payment Data Transfer is set to ON
and in your "http://www.bewolfclothing.com/thankyou.php"
$tx_id = $_GET['tx']; //gives you tx id

Integrate third party tax table into paypal using php/mysql

I am using Website Payments Standard and have numerous zip codes I'd like to apply for tax rates (more than I can manually input one at a time into Paypal's standard tax rules). Is there a way for the checkout solution to connect to my database (a mysql database) where I have the zip codes + tax rates? Is it possible for all this to happen in the shopping cart experience?
Yes, you can use the PayPal Instant Update API.
In a nutshell; you'll need to set up a script on your server which accepts a POST with shipping address data from PayPal, and requires you to return an appropriate response as output including the tax/shipping amount. This will then be used during checkout as the shipping/tax amount.
Have a look at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables#id09CA80W0Z5Z and https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_CallbackAPI
For Website Payments Standard, base a button off of the following form code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="paypal">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="name#test.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="https://link-to-your-return-script.php">
<!--item 1 -->
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="item_name_1" value="Gladiator - Extended">
<input type="hidden" name="item_number_1" value="3425654">
<input type="hidden" name="amount_1" value="10">
<!--item 2 -->
<input type="hidden" name="quantity_2" value="1">
<input type="hidden" name="item_name_2" value="Casino - Extended ">
<input type="hidden" name="item_number_2" value="4354567754">
<input type="hidden" name="amount_2" value="2">
<!--CALLBACK PARAMETERS -->
<input type="hidden" name="callback_url" value="https://link-to-your-callback-script.php">
<input type="hidden" name="callback_timeout" value="4">
<input type="hidden" name="callback_version" value="61"> <!--Required! -->
<input type="hidden" name="fallback_shipping_option_name_0" value="Option 1">
<input type="hidden" name="fallback_shipping_option_amount_0" value="1">
<input type="hidden" name="fallback_shipping_option_is_default_0" value="1">
<input type="hidden" name="fallback_shipping_option_name_1" value="Option 2">
<input type="hidden" name="fallback_shipping_option_amount_1" value="3">
<input type="hidden" name="fallback_shipping_option_is_default_1" value="0">
<input type="hidden" name="fallback_insurance_option_offered" value="0">
<!--CALLBACK PARAMETERS END-->
<input type="submit" value="Upload cart">
</form>
Whenever a buyer checks out, you will receive a POST with data on https://link-to-your-callback-script.php
The following is an example POST payload which you may receive:
CallbackRequest:
METHOD=CallbackRequest
CALLBACKVERSION=57
TOKEN=EC-7TF47275R51235219
LOCALECODE=en_US
CURRENCYCODE=USD
L_NAME0=Item name
L_NUMBER0=0123456789
L_DESC0=Description of item goes here
L_AMT0=1.00
L_QTY0=1
L_ITEMWEIGHTUNIT0=
L_ITEMWEIGHTVALUE0=0
L_ITEMHEIGHTUNIT0=
L_ITEMHEIGHTVALUE0=0
L_ITEMWIDTHUNIT0=
L_ITEMWIDTHVALUE0=0
L_ITEMLENGTHUNIT0=
L_ITEMLENGTHVALUE0=0
SHIPTOSTREET=1 Main St
SHIPTOCITY=San Jose
SHIPTOSTATE=CA
SHIPTOCOUNTRY=US
SHIPTOZIP=95131
SHIPTOSTREET2=
After which you must calculate the appropriate tax / shipping amounts, and return a proper CallBackResponse message.
For example;
CallBackResponse:
METHOD=CallbackResponse&
OFFERINSURANCEOPTION=true&
L_SHIPPINGOPTIONLABEL0=UPS Next Day Air TEST5&
L_SHIPPINGOPTIONAMOUNT0=1.00&
L_TAXAMT0=0.00&
L_INSURANCEAMOUNT0=0.00&
L_SHIPPINGOPTIONISDEFAULT0=false&
L_SHIPPINGOPTIONLABEL1=UPS Express 2 Days TEST4&
L_SHIPPINGOPTIONAMOUNT1=1.50&
L_TAXAMT1=0.00&
L_INSURANCEAMOUNT1=0.0&
L_SHIPPINGOPTIONISDEFAULT1=true&
L_SHIPPINGOPTIONLABEL2=UPS Ground2 to 7 Days TEST3&
L_SHIPPINGOPTIONAMOUNT2=1.50&
L_TAXAMT2=0.00&
L_INSURANCEAMOUNT2=0.00&
L_SHIPPINGOPTIONISDEFAULT2=false
Once PayPal has received this information, it will update the shipping/tax charges automatically.
For more information, see https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECInstantUpdateAPI

Categories