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.
Related
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.
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
Hi i am tried to solve my problem. Unable to solve that so i need your help.
I have download the the PayPal script from http://code.google.com/p/paypal-ipn-class-php/downloads/list
I got 2 files there are paypal_class.php and other file is paypal.php
I have copied and paste the paypal_class.php file to Vendor/Paypal/paypal_class.php.
I have calling the paypal_class.php file in my paypal action. The App::import('Vendor', 'Paypal/paypal_class'); is working fine in my UsersController.php file.
Please check my code:
test.ctp
<form name="paypal" id="paypal" method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="chinmay235-facilitator#gmail.com" />
<input type="hidden" name="item_name" value="Purchase Gold Coin" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" id="amount" value="50" />
<input type="hidden" name="image_url" value="http://dev.raddyx.com/finalgame7/img/logo.png" />
<input type="hidden" name="return" value="http://dev.raddyx.com/finalgame7/users/mycoin" />
<input type="hidden" name="cancel_return" value="http://dev.raddyx.com/finalgame7/users/mycoin" />
<input type="hidden" name="notify_url" id="notify_url" value="http://dev.raddyx.com/finalgame7/users/paypal" />
</form>
UserController.php
public function paypal(){
App::import('Vendor', 'Paypal/paypal_class');
$p = new paypal_class();
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch($_GET['action'])
{
case 'process':
//Process email here...
break;
case 'success':
//Success email here...
break;
case 'cancel':
//Cancel email here...
break;
case 'ipn':
if($p->validate_ipn())
{
//Payment Success complete email here...
}
exit;
}
}
Above i have used 4 test email but i did not get any email..
The best way that I know to debug and test remote server notification is to make good use of Logs.
So your paypal() function should be full of log statements, tracking the code path that is being followed and dumping various variable values so you get a sense of what is going on in your code.
You can manually trigger the IPN call by vising this link:
(http://dev.raddyx.com/finalgame7/users/paypal)
This will just show you if your controller is working or not. Then you need to use the PayPal IPN tester (it's somewhere in PayPal's developer center).
Once you have your logs and you have an idea of what is going on come back with a more specific question, if things are still not working.
Good luck! :)
I think you forgot to add the file name in "notify_url"
Currently it is:
input type="hidden" name="notify_url" id="notify_url" value="http://dev.raddyx.com/finalgame7/users/paypal" />
But It should be like:
input type="hidden" name="notify_url" id="notify_url" value="http://dev.raddyx.com/finalgame7/users/paypal/notifying_filename.php" />
I created a working clientside upload script for cloudinary. The important part of the upload:
<?php
$cloudName = "...";
$apiKey = "...";
$time = time();
$apiSecret = "...";
$fileName = "...";
?>
<form action="https://api.cloudinary.com/v1_1/<?php echo $cloudName;?>/image/upload" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="hidden" name="signature" value="<?php echo sha1('public_id='.$fileName.'×tamp='.$time.$apiSecret);?>" />
<input type="hidden" name="api_key" value="<?php echo $apiKey; ?>"/>
<input type="hidden" name="timestamp" value="<?php echo $time; ?>" />
<input type="hidden" name="public_id" value="<?php echo $fileName; ?>" />
<input type="submit" name="submit" value="Submit">
</form>
Now I want to add a transformation to the upload, so the uploads are transformed before they are stored (to save storage space).
I tried adding the following code (where resize is a transformation I created in my cloudinary account).
<input type="hidden" name="transformation" value="resize" />
But a request with a transformation field results in a 401 unauthorized error. I suppose I have to do something with the signature, but what?
You can use the cl_form_tag from the cloudinary PHP client library to build the form with all the input tags. However, you might want to use the jQuery direct upload which gives you better control and is more customizable UI-wise. See here. If you can't use the PHP client library for some reason there are two issues in the code:
A named transformation can be used by prefixing it by t_. So the value of the transformation field should be t_resize.
The transformation parameter needs to be added to the signature. Note that the parameter names need to be in alphabetical order when signed.
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