Paypal Checkout with extra info - php

First of all, good job on the community for being so helpfull :D
So i have a webshop, with easy paypal checkout:
echo
"<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='business' value='MYMAILYEAH'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='itemdesc' value='".$row['Description']."' />
<input type='hidden' name='item_name' value='".$row['name']."'>
<input type='hidden' name='amount' value='".$pricee."'>
<input type='hidden' name='currency_code' value='EUR'>
<input type='hidden' name='quantity' value='".$_POST['iamount']."'>
<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'>
<input type='hidden' name='address_override' value='1'>
<input type='hidden' name='first_name' value='".$_SESSION['username']."'>
</form>";
At the moment, when someone buys anything it shows only the price and the name of the object, is it also possible to send any extra notes/item description with it? Because i found out that alot of people didnt have their invoice adres set correctly in paypal...
A huge thanks in advance!
EDIT:
I found a part of the problem and solution:
I am getting an error at the CITY input;
<input type='hidden' name='first_name' value='".$_SESSION['username']."'>
<input type='hidden' name='last_name' value='".$_SESSION['username']."'>
<input type='hidden' name='country' value='NL'>
<input type='hidden' name='city' value='Arnhem'>
What the error says is:
There is a problem with the sendingadres. We marked this RED (the white arrow)
Change the adress and continue paying with paypal.
And under that it says:
This webshop told us to use the sendingadres input from the webshop, and theres a problem with this adres, go back to the webshop to change it.

First of all don't use a post variable directly in your code since the user sets it and can therefore easily manipulate the form.
It doesn't seem to work with the simple form. Here you can find all possible variables.

Solution was;
adding
<input type='hidden' name='address_override' value='1'>
<input type='hidden' name='first_name' value='".$_SESSION['username']."'>
<input type='hidden' name='last_name' value='".$_SESSION['username']."'>
<input type='hidden' name='country' value='NL'>
<input type='hidden' name='city' value='Arnhem'>
To override the paypal sendingadres.

Related

php: Unable to return to my site after Paypal payment

First I created test accounts for sandbox which were generated as following by Paypal:
1- me#mail.com
2- me-facilitator#mail.com
2- me-buyer#mail.com
Now I turned Auto Return to ON on my MAIN account I am using for Paypal that is me#mail.com. My form looks like:
<form action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post' id="frmPayPal" name='frmPayPal'>
<input type='hidden' name='business' value='me-facilitator#mail.com'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='item_name' value='Awesome Stuff'>
<input type='hidden' name='item_number' value='0002'>
<input type='hidden' name='amount' value='0.99'>
<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="rm" value="2">
<input type='hidden' name='return_method' value='2' />
<input type='hidden' name='cancel_return' value='http://296c6e7b.ngrok.io/clients/ryan/pay.php'>
<input type='hidden' name='return' value='http://296c6e7b.ngrok.io/clients/ryan/pay.php'>
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Now I can make successful purchase but it does not return to the URL.
I am submitting form via jQuery
You need to login your me-facilitator#mail.com and enable the Auto Return for Website Payments just like how you did in your me#mail.com.
How i figured it out? because of this:
<input type='hidden' name='business' value='me-facilitator#mail.com'>

Sagepay form submit parameters in PHP

How many parameters I need to pass the in form ULR ,It can interact with sagepay payment gateway. Following parameters are I have passed in the form url but I ma getting the following error:
Error:
Error number:
5068
Error message:
The encryption method is not supported by this protocol version.
I am unable to connect the sagepay server payment.I am completly new about the configuration of sagepay payment.
Some one can please tell me how many parameter I need to pass and What are they are?
How to encrypt the values and then pass the values?
Code:
<form name='sagepay' action='{$pm_sagepay_url}' method='post' onsubmit='this.submit.disabled=true;return true;'>
<input type='hidden' name='VPSProtocol' value='3.00'>
<input type='hidden' name='TxType' value= 'PAYMENT'>
<input type='hidden' name='Vendor' value= 'protxross'>
<input type='hidden' name='Crypt' value= 'TPjs72eMz5qBnaTa'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='{$this->pm_sagepay_business}'>
<input type='hidden' name='item_name' value='".$order->order_description()."'>
<input type='hidden' name='amount' value='".sprintf("%01.2F", ($order->order_total_price-$order->order_fee))."'>
<input type='hidden' name='handling' value='".($order->order_fee)."'>
<input type='hidden' name='return' value='".$_SHOP->root_secured. 'checkout_accept.php?'.$order->EncodeSecureCode()."'>
<input type='hidden' name='notify_url' value='".$_SHOP->root_secured. 'checkout_notify.php?'.$order->EncodeSecureCode()."&setlang={$_SHOP->lang}'>
<input type='hidden' name='cancel_return' value='".$_SHOP->root_secured. 'checkout_cancel.php?'.$order->EncodeSecureCode()."'>
<input type='hidden' name='currency_code' value='{$_SHOP->organizer_currency}'>
<input type='hidden' name='undefined_quantity' value='0'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='no_note' value='1'>
<input type='hidden' name='rm' value='2'>
<input type='hidden' name='invoice' value='{$order->order_id}'>
<div align='right'>
<input type='submit' value='{!pay!}' name='submit2' alt='{!sagepay_pay!}' >
</div>
</form>";
The info added to the form needs to be encrypted you be better off using the guide found here:
http://www.sagepay.co.uk/file/12241/download-document/FORM_Integration_and_Protocol_Guidelines_010814.pdf?token=gMABp5MzTV1BevfFpoTFkrofFWwHXySRM5tzGIdKj3Q
Also this guy has made a basic script for the form i got the main form to send it was the success page i could not get to work but i have now so if you get stuck give me a shout..
https://github.com/tolzhabayev/sagepayForm-php

Why is Paypal displaying SUCCESS and $_POST variables Paypal's site instead of returning to my return_url

Please help me. I'm at a total loss. After more than 2 days of Googling everything I can think of, I still have no answers. This DID work in the Sandbox. My code for sending the tx and token to Paypal.
<form name='verification' action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='at' value='$atoken' />
<input type='hidden' name='tx' value='$tx' />
<input type='hidden' name='rm' value='2' />
<input type='hidden' name='cmd' value='_notify-synch' />");
print("<input type='hidden' name='return' value='$returnUrl' />");
print("<input type='submit' name='submit' value='PDT'>");
print("</form>");
The variable for return url is return_url not return. It should also be an account in your Paypal account.
your amount and tax variables are not being parsed
<input type='hidden' name='at' value='<?=$atoken?>' />
<input type='hidden' name='tx' value='<?=$tx?>' />

Paypal IPN status "autochange"?

i have a question about Paypal IPN (or other methods) to buy in a webpage.
Actually I use the IPN "background" method setting a form like this:
<form id="TPVFORM" name='formTpv' method='post' action='https://www.sandbox.paypal.com/cgi-bin/webscr'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='xxxxxx#gmail.com'>
<input type='hidden' name='item_name' value='MORE THINGS'>
<input type='hidden' name='item_number' value='99.00'>
<input type='hidden' name='amount' value='23.00'>
<input type='hidden' name='page_style' value='paypal'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='return' value='http://www.xxxx.com/web/payOrder'>
<input type='hidden' name='cancel_return' value='http://www.xxxx.com/web/payFail'>
<input type='hidden' name='rm' value='2'>
<input type='hidden' name='no_note' value='1'>
<input type='hidden' name='currency_code' value='EUR'>
<input type='hidden' name='cn' value='PP-BuyNowBF'>
<input type='hidden' name='custom' value=''>
<input type='hidden' name='lc' value='es'>
<input type='hidden' name='country' value='ES'>
<input type="submit" />
</form>
And configure in my Paypal account the address of the IPN check .PHP file.
OK, to this point, all work correctly, but one question break me: Paypal have more "payment" status, "completed", "pending", "in revision".
If the pay status its "completed", I verify the other params, and SAVE the order in my DB, but if the status is, for example "pending", i DONT SAVE the order, if Paypal send a notificacion via IPN when the status is "pending", and "later" send other when the status is "completed" I no have problem, but if ONLY send the first status "pending" or "whaiting" or other think, ¿how i can check the payment status? ¿Paypal send one IPN call to my script when the status change?
Im lost..
YES. Paypal will make a call to your IPN script when the payment is Completed, even if at the initial time of purchase, it is Pending or similar.
Question asked in the PayPal Developer Network

How can I get multiple forms to use the same inputs in php

I have 15 identical PayPal "Buy Now" buttons each driven by its own form on a single php page. Each button has about 20 input variables but only 2 are unique to each item (item_name & item_number). Is there a way to clean up my code and have all the forms use the same input array? Not just the data, the whole string.
Thanks, Wayne
Example:
<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='cmd' value='_cart'>
<input type='hidden' name='business' value='myemail#mydomain.com'>
<input type='hidden' name='lc' value='US'>
<input type='hidden' name='item_name' value='Modern Art Print'>
<input type='hidden' name='item_number' value='MA024'>*
<input type='hidden' name='button_subtype' value='products'>
<input type='hidden' name='no_note' value='0'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='add' value='1'>
<input type='hidden' name='bn' value='PP-ShopCartBF:btn_cart_SM.gif:NonHostedGuest'>
<input type='hidden' name='on0' value='Select Size'>Buy Print
<select name='os0'>
<option value='11 x 14'>11 x 14 $30.00</option>
<option value='8 x 10'>8 x 10 $20.00</option>
</select>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='option_select0' value='11 x 14'>
<input type='hidden' name='option_amount0' value='30.00'>
<input type='hidden' name='option_select1' value='8 x 10'>
<input type='hidden' name='option_amount1' value='20.00'>
<input type='hidden' name='option_index' value='0'>
<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_cart_SM.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>
</form>
Create a function that builds the form. Example:
function paypalForm( $item_name, $item_number ) {
?>
<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='cmd' value='_cart'>
<input type='hidden' name='business' value='myemail#mydomain.com'>
<input type='hidden' name='lc' value='US'>
<input type='hidden' name='item_name' value='<?=$item_name?>'>
<input type='hidden' name='item_number' value='<?=$item_number?>'>*
<input type='hidden' name='button_subtype' value='products'>
<input type='hidden' name='no_note' value='0'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='add' value='1'>
<input type='hidden' name='bn' value='PP-ShopCartBF:btn_cart_SM.gif:NonHostedGuest'>
<input type='hidden' name='on0' value='Select Size'>Buy Print
<select name='os0'>
<option value='11 x 14'>11 x 14 $30.00</option>
<option value='8 x 10'>8 x 10 $20.00</option>
</select>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='option_select0' value='11 x 14'>
<input type='hidden' name='option_amount0' value='30.00'>
<input type='hidden' name='option_select1' value='8 x 10'>
<input type='hidden' name='option_amount1' value='20.00'>
<input type='hidden' name='option_index' value='0'>
<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_cart_SM.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>
</form>
<?
}
Assuming you are talking about cleaning the HTML markup, rather than generating the forms at the server side...
You could do it with Javascript, but it is not a good idea to rely on Javascript for your core site functionality, because it can be disabled by the user, and may break in a way you have not predicted in some browser or other.
I think that, since you are submitting the data directly to Paypal and therefore have no control over the server side, the answer to this is probably NO.
If you are talking about cleaning up the PHP code, Rijk van Wel's answer may help.
Please refer to this article: http://www.chami.com/tips/internet/042599i.html
You can create a single form with multiple submit buttons and assign both item_name & item_number as button's value. This way the inputs aren't repeated in the code and you can easily distinguish between submitted forms.
Note: the server-side code in the article is written in ASP, but in PHP it's the same. Just refer to $_POST['buttonNameHere']

Categories