I m trying to add a Paypal Add to cart button in my application. For that i create code from paypal sanbox. This is my form,
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="EGZD52TPWUERY">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Fees">
<input type="hidden" name="item_number" value="255">
<input type="hidden" name="amount" value="85.00">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:" />
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="my-application/paypal/success">
<input type="hidden" name="tax_rate" value="0.000">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="item_id_<?php echo $res_1->id; ?>" value="<?php echo $res_1->id; ?>" />
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="image" src="https://www.sandbox.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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
The payment transaction is completed successfully and the redirect is done perfectly to my application. But the problem is i didn't get any response in that page. I tried var_dump($_POST). It retruns null. Don't know why i didn't get any response. Any help is appreciated.
Check the following link and update your paypal account.The response is in $_GET
https://developer.paypal.com/webapps/developer/docs/classic/products/payment-data-transfer/
Related
I was working with paypal recurring payment subscription form and using sandbox account for testing
here is my form:
<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="testacc#email.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Standard Pack">
<input type="hidden" id="item_number" name="item_number" value="1233434-23213">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="user_id" value="13692">
<input type="hidden" id="package_id" name="package_id" value="<?php echo $package_type; ?>">
<input type="hidden" name="a1" value="0">
<input type="hidden" name="p1" value="1">
<input type="hidden" id="t1" name="t1" value="M">
<input type="hidden" id="a3" name="a3" value="10">
<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="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input name="return" type="hidden" value="<?php echo base_url();?>package/new_payment_success" />
<input name="notify_url" type="hidden" value="<?php echo base_url();?>package/new_payment_notify" />
<input name="cancel_return" type="hidden" value="<?php echo base_url();?>package/new_payment_cancel" />
<div class="paypal-btn">
<input type="image" src="pay-with-paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style='width: 125px'>
</div>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
and it's working totally fine and sends a success information to notify_url url
now for security purpose im checking HTTP_USER_AGENT from $_SERVER variable but this can be modified too.
so how can i make sure that transection is done successfully before i update my database?
I think that you can verify the whole POST content by appending cmd=_notify-validate and sending it to PayPal. They will answer you with a Verified or Not verified response.
Please, check the link below for more information:
https://developer.paypal.com/docs/classic/ipn/gs_IPN/
This is my code in PHP for paypal payment integration.Payments are being done successfully. The response URL should be http://codaty.com/success.php?tx=83437E384950D&st=Completed&amt=10.00&cc=USD&cm=&item_number=1 .But I am getting the URL as http://codaty.com/success.php. I am not getting any parameters in return. Is this the right method for integration. Can I get a sample code for reference.
$paypal_url='https://www.paypal.com/cgi-bin/webscr';
$paypal_id='codaty#outlook.com';
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="QR Code">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="credits" value="510">
<input type="hidden" name="userid" value="<?=$session_userid?>">
<input type="hidden" name="amount" value="0.10">
<input type="hidden" name="cpp_header_image" value="http://codaty.com/images/logo.png">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="handling" value="0">
<input type="hidden" name="cancel_return" value="http://codaty.com/cancel.php">
<input type="hidden" name="return" value="http://codaty.com/success.php">
<input type="image" src="images/card03.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" class="img-responsive">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Add addition Return method input hidden field <input type="hidden" name="rm" value="2">
1 — the buyer's browser is redirected to the return URL by using the GET method, but no payment variables are included.
2 — the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included.
And then in success.php :
echo "<pre>";
print_r($_POST);
More details : HTML Variables for PayPal Payments Standard
I have the following form code in my website however when I click on the Paypal subscription button the price of the subscription shows $0.00 on the paypal checkout page. Is there something wrong with my form parameters?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="registrations-facilitator#invent2win.com">
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="a3" value="5.55"> <!--Cost-->
<input type="hidden" name="t3" value="1"> <!--Monthly subscription-->
<input type="hidden" name="p3" value="M"> <!--Monthly subscription-->
<input type="hidden" name="src" value="1"> <!--YES, make it reoccurring-->
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="item_name" value="Economy Sandbox">
<input type="hidden" name="item_number" value="$usernum" />
<input type="hidden" name="return" value="http://www.example.com/purchasecomplete&email=$email?num=$usernum" />
<input type="hidden" name="cancel_return" value="http://www.example.com/cancel" />
<input type="hidden" name="notify_url" value="http://www.example.com/purchasecomplete&email=$email?num=$usernum">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_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>
This should work for you:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="registrations-facilitator#invent2win.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="a3" value="5.55">
<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">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="item_name" value="Economy Sandbox">
<input type="hidden" name="item_number" value="4" />
<input type="hidden" name="return" value="http://www.example.com/purchasecomplete&email=$email?num=$usernum" />
<input type="hidden" name="cancel_return" value="http://www.example.com/cancel" />
<input type="hidden" name="notify_url" value="http://www.example.com/purchasecomplete&email=$email?num=$usernum">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_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>
My add to cart button is having this code.
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="ajith-facilitator#pavanathara.com">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="item_name" value="<?= #$row['prod_name'] ?>">
<input type="hidden" name="item_number" value="<?= #$row['prod_id'] ?>">
<input type="hidden" name="amount" value="<?= #$row['prod_price'] ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="https://paypalipn.my.phpcloud.com/payment-successful.php">
<input type="hidden" name="cancel_return" value="https://paypalipn.my.phpcloud.com/payment-cancelled.php">
<input type="hidden" name="tax_rate" value="<?= #$settings[0]['pbreakup_value'] ?>">
<input type="hidden" name="shipping" value="<?= #$settings[1]['pbreakup_value'] ?>">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="hidden" name="prod_id" value="<?= #$row['prod_id'] ?>">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" 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">
</form>
But on https://paypalipn.my.phpcloud.com/payment-successful.php I am not receiving any response from paypal.
I have a displaycart.php page where it displays all items I have in a shopping cart, each item has an ItemUnitPrice field where it shows the unit price of the item.
If I have say 6 items in the cart then I want to add up the total ItemUnitPrice fields and set that amount to be paid with PayPal.
I have checked out PayPals button features which they allow and you can only set a given price for the user to pay for when you create the button.
Is there a way I can link the PayPal button to my database so it shows the total of all the ItemUnitPrice fields.
The variable which holds the total ItemUnitPrice:
<?php
$Total = $Quantity * $ItemUnitPrice;
?>
The PayPal 'Pay Now' Button:
<html>
<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="KAMQ5PVWVDYYN">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynow_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_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</html>
Edit:
Yeah I've done something stupidly wrong!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_BLANK">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="info#asianweddingservices.org" />
<input type="hidden" name="item_name" value="<? $ItemDesc ?>" />
<input type="hidden" name="item_number" value="<?$ItemCode ?>" />
<input type="hidden" name="amount" value="<?$Total ?>" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="lc" value="GB" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input src="paypal/purchase.png" name="Submit" type="image" value="purchase" alt="Purchase" />
</form>
Yes. Change the set value to your total.
Show your code and I can edit the answer to fix it for you.
Add this:
<input type="hidden" name="amount" value="<? echo $Total; ?>" />
If that doesn't work:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_BLANK">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="PAYPAL EMAIL" />
<input type="hidden" name="item_name" value="ITEM NAME" />
<input type="hidden" name="custom" value="CUSTOM VALUE" />
<input type="hidden" name="item_number" value="ITEM NUMBER" />
<input type="hidden" name="amount" value="TOTAL" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="lc" value="GB" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input src="paypal/purchase.png" name="Submit" type="image" value="pruchase" alt="Purchase" />
</form>
Replacing the values to yours of-course.