I am trying to integrate payu payment gateway and I have included all the mandatory fields but it's showing me an error after redirecting to payu's official site.
Error. We are sorry we are unable to process your payment.
Checksum Failed. Please contact your merchant.
I have included following fields:
<input type="hidden" name="key" value="key here" />
<input type="hidden" name="txnid" value="67c778f0eed" />
<input type="hidden" name="hash" value="sdfdsfsdfsdfgsdrgsdf"/>
<input type="hidden" class="user2" name="firstname" value="sunil">
<input type="hidden" name="surl" value="abc.com" size="64" />
<input type="hidden" name="furl" value="abc.com" size="64" /></td>
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input id="pay_amoumt" type="hidden" name="amount" value="10">
<input id="pay_amoumt" type="hidden" name="productinfo" value="general">
I have assigned a static string to hash key. Is this a problem? Or is there anything else I have to do?
Your checksum is not exact check variable that all are compulsory. Formula for checksum before transaction:
sha512 (key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||<SALT>)
SALT will be provided by PayUMoney. The algorithm used is SHA2 which is globally well known algorithm. Use Google to find the desired function library for your implementation. Some example code is also mentioned below:
Example code for PHP:
$output = hash("sha512", $text);
http://softbuiltsolutions.com/uploads/readme/sZuRrXnkRVQXqv47f3hgy4LCmekcry-1443511890.pdf
Not sure if this was fixed , but could not find the answer anywhere, so thought will share what worked for me.
Please make sure the amount is a float like 10.00 .
This worked for me.
Thanks
The POST must include the following keys compulsorily
"key" "txnid" "amount" "productinfo" "firstname" "email" "phone" "surl" "furl" "hash" "service_provider"
This information is in the documentation.
check your frontend and backend field name of object are matching to each other.if its not matching it will give error while generating hash code.
Related
I have created a non-hosted PayPal-Button with a text input to let users define an amount to pay. It's a subscription button.
Now the problem is that there must be a minimum amount to pay, say 101 (CHF - Swiss francs).
According to the docs of PayPal HTML-Variables I have the possibility to add the following vars in hidden inputs to my form to get it to work.
set_customer_limit with a value of max_limit_own
min_amount with a value of 101
The set_customer_limit is working but not the min_amount. Any amount is accepted.
I opened a ticket at the technical support, but no reply till now.
Here's my form:
<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="cancel_return" value="mydomain.com/cancel">
<input type="hidden" name="return" value="mydomain.com/paid">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="hidden" name="src" value="1">
<input type="text" name="a3" value="101.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="Y">
<input type="hidden" name="currency_code" value="CHF">
<input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHostedGuest">
<!-- the concerned inputs -->
<input type="hidden" name="set_customer_limit" value="max_limit_own">
<input type="hidden" name="min_amount" value="101">
<!-- ---- -->
<input type="image" src="https://www.paypalobjects.com/de_DE/CH/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal.">
<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
</form>
As for the moment, I just validate the minimum amount with JavaScript, which isn't really secure...
EDIT
As an idea, I could implement another form (submit it by AJAX, onchange, onkeyup, whatever), which sets the minimum amount given by the user before the PayPal-form and put it into the PayPal-input then (set to hidden again):
<input type="hidden" name="a3" value="<?php echo $_POST['pre_min_amount'] ?>">
That way I could validate the minimum amount with PhP, before submitting the PayPal-form. But that doesn't seem a clean way to me. Really Glad if anybody could give me a hint!
The answer of the PayPal technical support is: No it is not possible!
(Date of answering was 05/02/2015) Hopefully, this will be possible in the future. If so please post your answer!
I'd really suggest using the PayPal API for this kind of thing (including creating a developer account, byting thru the docs, etc).
So this "solution" is a quick & dirty workaround.
First, add a small form (I call it the min_amount -form for now) to the page (telling the user, he has to set the amount first):
<form id="min_amount" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="text" id="pre_min_amount" name="pre_min_amount" value="101">
<input type="submit" value="Set min. Amount">
</form>
Then, add the whole PayPal form to a PHP variable with NowDoc and add the posted value from the min_amount-form to the a3 input:
$min_amount = 0;
$payPalForm = <<<SOME
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<!-- //... -->
<input type="hidden" name="a3" value="$min_amount">
</form>
SOME;
After submitting, check if the minimum amount is true and then only show the PayPal-form:
if (isset($_POST['pre_min_amount']) && is_numeric($_POST['pre_min_amount']) && floatval($_POST['pre_min_amount']) >= 101) {
$min_amount = htmlspecialchars($_POST['pre_min_amount']);
echo $payPalForm;
}
As I said, it's quick and dirty (no more time for this project), but you ensure to validate the minimum amount on the server-side, not just with Javascript. You could also submit the min_amount-form with an AJAX call, but then the return of this call is on the client-side, which isn't really secure either. (Sure you may also)
BTW, I am not proud of this solution at all, but sometimes, a programmers life is hard and I'm sure all you coders out there had to do some q&d code somehow, somewhere ;-)...
Update: 08/05/2015
All depends on the country in which the concerning account is registered. Full services guaranted by PayPal only in the USA and Canada
I'm have an issue with Paypal, i'm using a simple form :
<html>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="boukhersya#gmail.com">
<input type="hidden" name="item_name" value="DEMANDE D ETUDE PERSONNALISEE">
<input type='hidden' name='rm' value='2'>
<input type="hidden" name="amount" id=val value="79">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="notify_url" value= "http://<?php echo $_SERVER['SERVER_NAME'];?>/etude-gratuite.php" >
<input type="hidden" name="cancel_return" value="http://<?php echo $_SERVER['SERVER_NAME'];?>/etude-personalisee/test.php">
<input type="hidden" name="return" value="http://<?php echo $_SERVER['SERVER_NAME'];?>/etude-personalisee/paimentconfirme.php">
<input type="submit" value="Payer votre commande">
</form>
I want to return the email used in the payment, so i can know which user has paid
so i can get the email in the page test.php, can i do that with PDT ??
You can pass the field "custom" to pyapal and it will pass it back to you when the transaction is completed. You may want to use your user ID rather than an email address though.
<input type="hidden" name="custom" value="email#address.com">
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
The way it works is: you use these hidden input values on for your paypal button. When the user is transferred to paypal all of these values are sent with it. One of the values you use is name="notify_url" when the user completes checkout paypal posts the checkout information to that url. In the case of php you do something like this:
$useremail = $_POST['custom']
Any custom information you want to have returned to you needs to go in the custom field. I use some kind of delimiter if I want more pieces of information returned, like this:
<input type="hidden" name="custom" value="user#email.com-firstname-userID">
Then you just explode the data:
$paypalvars = explode("-", $_POST['custom']);
$email = $paypalvars[0];
$firstName = $paypalvars[1];
$userID = $paypalvars[2];
Whatever value is in the custom filed will be posted back to your notify_url exactly the same way you give it to paypal.
You could use the Paypal IPN API to handle this.
Simply set up IPN within your Paypal account and then create a file which will manage the data that gets sent back upon payment.
This includes their email address too!
Note that the <input type="hidden" name="notify_url"> should be the input used to direct to test.php because at the moment, the information that will get passed back to you will be sent to the etude-gratuite.php
i am using Virtual Merchant online payment.
i have one demo account :
https://demo.myvirtualmerchant.com/VirtualMerchantDemo/login.do
Account ID: 002549
User ID : 002549
Password : Abcd.1234gd
the submitting form code:
<form action="https://demo.myvirtualmerchant.com/VirtualMerchantDemo/process.do" method="POST">
<input type="hidden" name="ssl_amount" value="75.00">
<input type="hidden" name="ssl_merchant_id" value="002549">
<input type="hidden" name="ssl_user_id" value="002549">
<input type="hidden" name="ssl_pin" value="2R56WU">
<input type="hidden" name="ssl_transaction_type" value="ccsale">
<input type="hidden" name="ssl_show_form" value="true">
<input type="hidden" name="ssl_cvv2cvc2_indicator" value="1">
<input type="hidden" name="ssl_invoice_number" value="20131226">
<input type="hidden" name="ssl_customer_code" value="test demo">
<input type="hidden" name="ssl_email" value="demo#gmail.com">
<input type="submit" value="Pay Now" class="button1">
i got one test credit card number: 4005550000000019 from http://www.infomerchant.net/creditcardprocessing/credit_card_test_numbers.html
after submitting, the result is:
after clicking the process button, the result is :
the text is :
Error Code : 4000
Error Name : VID Not Supplied
Error Message : The VirtualMerchant ID was not supplied in the authorization request.
could you know how to fix it ? or any suggestion.
ssl_merchant_id: 002549
ssl_user_id: 002549
ssl_pin: 2R56WU (it is from demo account under menu: user=>change pin)
I encountered a similar issue. The culprit turned up on my end, before my form POSTed data to VirtualMerchant. Make sure the data/string(s) are properly encoded, without any stray white space.
My problem is related to this specific error:
I'm doing a form to contain data that have to be passed to the server to obtain the token, but probably i haven't understood some concepts about doing this
Here is my form
<form method="post" action="https://api-3t.sandbox.paypal.com/nvp">
<input type="hidden" name="USER" value="Apiuser"/>
<input type="hidden" name="PWD" value="Apipass"/>
<input type="hidden" name="SIGNATURE" value="Apisignature"/>
<input type="hidden" name="VERSION" value="52.0"/>
<input type="hidden" name="PAYMENTACTION" value="Sale"/>
<input name="AMT" value="19.95"/>
<input type="hidden" name="RETURNURL" value="http://www.YourReturnURL.com"/>
<input type="hidden" name="CANCELURL" value="http://www.YourCancelURL.com"/>
<input type="image" name="METHOD" src="https://www.paypal.com/it_IT/IT/i/btn/btn_xpressCheckout.gif" value="SetExpressCheckout"/>
</form>
And here is my function
if (isset($_POST['METHOD'])) {
$API_UserName = urlencode("Apiuser");
$API_PassWord = urlencode("Apipass");
$API_Signature = urlencode("Apisignature");
$return_url = "http://www.myurl.com";
$cancel_url = "http://www.myurl.com";
$version = urlencode('52.0');
$nvpreq = "USER=$API_UserName&PWD=$API_PassWord&SIGNATURE=$API_Signature&VERSION=$version&PAYMENTACTION=Sale&AMT=19.95&RETURNURL=$return_url&CANCELURL=$cancel_url&METHOD=SetExpressCheckout";
}
Is seems that something is wrong, can you give me a tip please?
Thanks a lot
Have you checked that you are not encoding the parameters twice? Im my case that was happening though http_build_query() and some default setting which was unstable for some reason due to being changed somewhere during runtime.
Basically your final call should contain & and not &, for me the final curl call for some reason ended up with being encoded as &.
Make sure you are not encoding twize, and if using http_build_query() update your function so it will be explicit on the encoding part:
from: http_build_query($requestParameters)
to: http_build_query($requestParameters,'','&')
The difference is that the last version will explicitly use & as delimiter while the first will use the default, so be sure.
I am facing this problem from last month. First i was able to get value back from paypal.
Now I am not able to get back value from paypal.
I am using following code.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" style="padding: 0; margin: 0;">
<input type="hidden" name="cmd" value="_xclick/" />
<input type="hidden" name="business" value="my_bussiness_id" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="item_name" value="item" />
<input type="hidden" name="item_number" value="1" />
<input type="hidden" name="amount" value="item_price" />
<input type="hidden" name="shipping" value="0" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="notify_url" value="Your_notify_url">
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="rm" value="2" >
<input type="hidden" name="return" value="your return url">
<input type="image" border="0" name="paypal" src="images/btn_paypal_nl.gif" onClick="" />
</form>
Thanks in advance..
Kanji
There's actually two methods of getting the data back--a return URL that posts upon completion with return values (I've not been terribly lucky making that work) then a separate function that sends you a post upon completion of a transaction to a separate page on your site, where you can collect back all the variables you posted to the site. I suggest the latter because on a buy it now page there's a possibility of the user not being returned to the site because the return button UI is pretty weak on PayPal's end.
To set it up you'd log in to your PayPal account, click on myaccount > profile > website payment preferences. Enabling the "payment data transfer" will do the trick. Once you've got it setup correctly, upon completion of a transaction it'll send to the page of your choice a post of everything you sent it....remember, you can send in variables such as Name, Address, etc just by defining them properly in the form. All the variables available are found here
Don't forget to build a sandbox site to test! Good Luck.
What I have normally done is this:
You see where you got notify_url as a hidden tag, use that for paypal to send you information about the transaction.
The url you put down should be a file on your server that will then do some logic, i.e. update your database that everything was ok, send out notification email of order, etc, etc
When paypal talks to this page, altho cant see the process, everything is sent via $_POST.
What I do as a test is i loop thru the $_POST array and send myself an email so I know what values have been posted back to me.
//paypal variables
$message = "<h1>Paypal variables</h1>";
foreach($_POST as $key => $value)
{
$message.= $key . " - " . $value . "<br />";
}
Link below gives you more info.
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro