Paypal Integration with PHP - php

I am using this code to create my subscription for PayPal.
But it is not recognizing any of my input fields. Would you be able to shed some light on why not?
<form method="POST" name="gateway_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="EMAIL"/>
<input type="hidden" name="currency_code" value="CAD"/>
<input type="hidden" name="return" value="http://www.URL.com/payment/paypal_success.php"/>
<input type="hidden" name="cancel_return" value="http://www.URL.com/payment/paypal_failure.php"/>
<input type="hidden" name="notify_url" value="http://www.URL.com/payment/paypal_ipn.php"/>
<input type="hidden" name="item_name" value="Monthly Subscription"/>
<input type="hidden" name="discount_amount" value="0.00"/>
<input type="hidden" name="a3" value="49.00"/>
<input type="hidden" name="t3" value="M"/>
<input type="hidden" name="p3" value="30"/>
<input type="hidden" name="src" value="1"/>
<input type="hidden" name="sra" value="1"/>
<input type="hidden" name="srt" value="1"/>
<input type="submit" value="Click Here"></p>
</form>

You need to tell PayPal who is submitting the request by submitting the required URL parameters user, pwd, version, and (recommended but optional) signature, along with the other parameters you're sending in the POST request. See API Overview.

Take a look at this link:
Subscriptions and Recurring Payments Variables
https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside
Also, I suggest you use a hosted button. It makes the whole process very easy.

Well both you guys were right, but the issue that came about was because on my 3rd line there
<input type="hidden" name="cmd" value="_xclick"/>
needs to become
<input type="hidden" name="cmd" value="_xclick-subscriptions"/>
Thanks for your help!

Related

PayPal IPN - Changing from Sandbox to Live stops working

I am using the PayPal IPN System which works perfectly in sandbox mode. All the payments went through successfully and my site updated as required. So, being ready to go live, I change my sandbox links to live links:
$action = 'https://www.paypal.com/cgi-bin/webscr';
But now, whenever the payment form is posted to this address, it ends up at
https://www.paypal.com/webapps/hermes?token=...
which just shows a blank page. No error_log is created on my server.
Here is my form data before the link to PayPal is clicked.
<form name="frm_payment_method" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="business" value="payments#domain.com">
<input type="hidden" name="notify_url" value="http://domain.com/ipn.php">
<input type="hidden" name="cancel_return" value="http://domain.com/cancelled.php">
<input type="hidden" name="return" value="http://domain.com/success.php">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="lc" value="">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="page_style" value="paypal">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="item_name" value="1 Credit">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" name="amount" value="1.50">
<p><button type="submit" name="submit" class="btn btn-primary">Proceed to PayPal</button>
Cancel</p></form>
Of course, replacing domain.com with my own correct domains.

Paypal dynamic return url not working

I am trying to make a paypal payment and I have a problem when returning to my page after the payment is completed.
I want to do it dynamically (so I do not want to set it in the paypal's account option, as I may use this account for other things). This is the form I send to paypal:
<form id="paypalForm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="notify_url" value="http://zopomobile.es/pruebas/modules/rmaforsat/ipn_paypal.php">
<input type="hidden" name="item_name_1" value="Pago de su orden a Zopomobile.">
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="amount_1" value="259.12">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="custom" value="152">
<input type="hidden" name="business" value="admin-facilitator#zopomovil.es">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="return" value="http://zopomobile.es/pruebas">
<input type="hidden" name="cancel" value="http://zopomobile.es/pruebas/NO">
<input type="hidden" name="rm" value="2">
</form>
I have tried changing the "return" variable to "return_url", still not working.
If you want to automatically re-direct to "http://www.zopomobile.es/pruebas/"
then you need to turn on "Auto Return" on your PayPal profile.
Right now, Auto Return is "OFF" in your profile.
The return parameter is return
https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-payments
Check above link to turn on the "Auto Return" feature.

PayPal Checkout with Multiple Items with Quantuty - Unknown Error

I am trying send a PayPal multiple items with quantity and amount in a shopping cart. When i try to send the following i get a unknown error. i dont know why
<form name="check_out_form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="sales#ss.com"/>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="item_number_1" value="1"/>
<input type="hidden" name="item_name_1" value="Featured: 3"/>
<input type="hidden" name="amount_1" value="9.95"/>
<input type="hidden" name="quantity_1" value="3"/>
<input type="hidden" name="item_number_2" value="2"/>
<input type="hidden" name="item_name_2" value="Standard: 2"/>
<input type="hidden" name="amount_2" value="2.95"/>
<input type="hidden" name="quantity_2" value="2"/>
<input type="hidden" name="page_style" value="Career"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="no_shipping" value="1"/>
<input type="hidden" name="return" value="http://www.sss.com/welcome.php?id=success"/>
<input type="hidden" name="return_cancel" value="http://www.sss.com/welcome.php"/>
<input type="hidden" name="custom" value="id|1-custom|1-fea|9.95|3|29.85-std|2.95|2|5.9-total|"/>
<input type="hidden" name="notify_url" value="http://www.sss.com/ipn.php"/>
<input type="hidden" name="cbt" value="Complete Upgrade">
<input type="submit" name="button" id="button" value="Pay now"/>
</form>
I cant figure out what i am doing wrong here i get error saying
"We have detected a problem with this shopping cart. If the problem persists, please contact the merchant. At this time, we are unable to process your request. Please return to xxl and try another option."
Add a new variable called "upload", so it might look like:
...
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
...
Tried it, worked with your code in my PP-Sandbox.

unable to get paypal post pramenters in the return url

I have one code for passing some custom variables to PayPal and these were collected in the return page, but when trying to get these values it is not working
I have a PayPal form like this :
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="submit.png" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="custom" value="IP"/>
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="business" value=""/>
<input type="hidden" name="item_name" value=""/>
<input type="hidden" name="item_number" value=""/>
<input type="hidden" name="amount" value=""/>
<input type="hidden" name="page_style" value=""/>
<input type="hidden" name="no_shipping" value="1"/>
<input type="hidden" name="return" value="index.php?action=success"/>
<input type="hidden" name="notify_url" value="index.php?action=ipn"/>
<input type="hidden" name="cancel_return" value=""/>
<input type="hidden" name="rm" value="2"/>
<input type="hidden" name="cn" value="Additional Information"/>
<input type="hidden" name="currency_code" value="AUD"/>
<input type="hidden" name="bn" value="PP-ShopCartBF"/>
</form>
I am successfully returning to the URL after payment. and there I am just trying to print the POST Variable for now and It is not giving me any values.I have tried by both enabling and disabling 'auto return'. In both case I don't get values. Please help me, thanks in advance.
The "notify_url" will be contacted by paypal asynchronously (directly), without you having anything to do with this transaction. So you will never see in your browser any results whatsoever. You should use some kind of logging in your script to see what is actually being sent. Check your web server's access log to see if paypal is actually contacting your script (and make sure it's not "localhost" you're trying from)
If I remember correctly only the transaction id is sent back to the return_url. The notify_url receives that id also. From there you should be able to communicate both pages to fill your needs.

PayPal with IPN enabled invoking error on cmd = "_cart"

I am using PayPal Website Payment Standard with IPN enabled.
Before I was setting cmd variable like this
<input type="hidden" name="cmd" value="_xclick">
but then I canged it to
<input type="hidden" name="cmd" value="_cart">
Also I changed some other variables inside my form
<input type="hidden" name="item_name_1" value="Item1">
<input type="hidden" name="amount_1" value="2">
<input type="hidden" name="item_name_2" value="Item2">
<input type="hidden" name="amount_2" value="2">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="quantity_2" value="2">
<input type="hidden" name="item_number_1" value="121">
<input type="hidden" name="item_number_2" value="122">
But when the form is Posted to PayPal I am getting this error.
Thanks in Advance...
did you add target="paypal" in the form opening tag?
could you show the entire form?
I think that you have to include the upload variable to identify the form as a cart:
<input type="hidden" name="upload" value="1">

Categories