Passing php variables with Paypal buttons - paypal

I have a problem passing a variable to the Paypal button so that the IPN sent by Paypal can send the data in the variable back to me.
However, when I tested the button, I get the error 'Data does not match input character set or default encoding. For more information, please contact the merchant.'
Can anyone help?

This might be related to the encoding that you have set in your PayPal account for IPN and other things . You can try to change the encoding as "UTF-8" from your PayPal account . Visit the below url to change the encoding settings in your PayPal account .
https://www.sandbox.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-language-encoding
Once you visit the above url , click on the link which says "MOre Options "

Related

Has anybody gotten PAYMENTREQUEST_0_DESC to work in the PayPal API?

I am passing my PayPal API call like this:
&METHOD=SetExpressCheckout
&RETURNURL=''
&CANCELURL=''
&PAYMENTREQUEST_0_PAYMENTACTION='SALE'
&PAYMENTREQUEST_0_NOTIFYURL=''
&BRANDNAME=''
&NOSHIPPING=0
&PAYMENTREQUEST_0_CURRENCYCODE=''
&LOCALECODE=US
&LOGOIMG=''
&CARTBORDERCOLOR=''
&ALLOWNOTE=0';
&PAYMENTREQUEST_0_CUSTOM=''
&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=''
&L_PAYMENTREQUEST_0_NAME1=''
&L_PAYMENTREQUEST_0_AMT1=''
'&L_PAYMENTREQUEST_0_QTY1=''
&PAYMENTREQUEST_0_ITEMAMT=''
&PAYMENTREQUEST_0_SHIPPINGAMT=''
&PAYMENTREQUEST_0_AMT=''
and obviously I am including the:
'&PAYMENTREQUEST_0_DESC='.urlencode($desc).
where $desc = "Payment made from My Website";
But it's not showing anywhere in the confirmation emails that PayPal sends. Neither in the sandbox nor in the live version.
Has anyone gotten this to work successfully?
If you don't include items information, this parameter will show on PayPal checkout page.
I found a way to do it.
It's with: '&PAYMENTREQUEST_0_NOTETEXT='.urlencode($desc).

Connecting to Paypal Rest Api to obtain users consent

I am trying to connect to Paypal to get a users consent to access their paypal payment history. The end goal would be to download payments received at the end of the day and take the info and dump it into a local database.
https://developer.paypal.com/webapps/developer/docs/api/#obtain-users-consent
<Cfset returnlink="http://www.xxxxxx.com/paypal/paypalreturn.cfm">
<cfset paypalLink="https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize">
<Cfset paypallink="#paypallink#?client_id=#settingsLive.clientid#">
<Cfset paypallink="#paypallink#&redirect_uri=#urlencodedformat(returnlink)#">
<Cfset paypallink="#paypallink#&response_type=code">
<Cfset paypallink="#paypallink#&scope=profile+email+address+phone+https%3A%2F%2Furi.paypal.com%2Fservices%2Fpaypalattributes">
<cfset paypalLink="#paypallink#&nonce=#createUUID()#">
<cfset paypalLink="#paypallink#&state=create">
Login with paypal
Clicking on the link below returns:
Relying Party Validation error: redirect_uri provided in the request
does not match with the registered redirect_uri. Please check the
request.
I have logged into the Rest API, modified my app and made sure the redirect uri's for the test and live return link match that listed above. I have also made sure that the accept logins options are checked.
I have also tried the same code against their sandbox URL:
https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize
and instead of receiving the validation error, I get a page cannot be displayed.
I've tried every combination of things that I could think of
1) removing 1 cfset statement at a time to isolate a bad variable
2) making sure the return uri was a https vs http
3) switching to sandbox mode url and back
I've connected to other oauth2 api's in the past, but can't figure this one out.
This has changed a bit, and will presumably change again soon... but here's how you do this now.
Log into developer.paypal.com
Click on Dashboard (https://developer.paypal.com/developer/applications)
Click your app name under "Rest API Apps"
Scroll to the box at the bottom of the screen labeled "Sandbox (or Live) App Settings
Set the Return URL (Where users will be redirected after test transactions)
Click save
NOTE
This Return URL must exactly match the redirect_uri that you pass in via querystring (so it's confusing as to why you'd need to pass it in in the first place)
GOTCHA
At this point in time, the Return URL can seemingly never be updated. In my recent experience, if you don't type it correctly the first time you save it, you will have to create a new app.
The only time I have seen this error is when your redirect_uri does not match the one set in your applications profile.
You need to set this value inside of your app on the developer website.
Log into developer.paypal.com
Click Applications
Under My Rest Apps click your App name
Click Edit next to App redirect URLs
Set the return URLs for live or test
Save
I am also unable to get sandbox to work for my Log In with PayPal tests so it is not just you.
As of now (October 2015), the Dashboard Return URL should correspond to the redirect_uri. You can obtain the redirect_uri parameter in Firefox, by downloading the HTTPFox browser plugin. Then you start HTTPFox, point your browser to the OmniAuth login link, and view the scParams in the query string in the bottom-most link in the HTTPFox history to obtain the redirect_uri.
You have to literally make sure the Return URL is the exact same sequence of characters as the input redirect_uri. For example, if one points to "localhost" and the other to "127.0.0.1", it won't recognize the redirect_uri value as the same. It also won't recognize redirect_uri if only one of the redirect_uri values has a final slash.
Yes, the return URL was able to be updated in my experience.

Multiple option of payment on paypal

I did a button of 3 options for payment (Buy Now) on PayPal, and when I pasted the code on my website.
Everything looks ok until you click on Buy now, It's transfer to error code on PayPal.
This is the link for the website: http://compx.co.il/?page_id=43
The error code that I get is:
1.Can not process your request at this time. Return to CompX IT Services and try another option.
2. PayPal can not process this transaction because of a problem on the site of the seller. Contact the seller directly to resolve this issue.
Any suggestion?
Regards,
Dvir
It's probably a character set issue. The default character set doesn't recognize them so you can fix this problem by changing the text of your option values or by changing the "charset" you're posting to PayPal.
You can follow these steps to modify the character set within your PayPal account:
- Log into your PayPal account at https://www.paypal.com
- Click the Profile link
- Click the 'Language Encoding' link under the Selling Preferences column
- Click the gray 'More Options' button
- Choose the same encoding you are using for your data off your site
- Select 'Yes' for 'Do you want to use the same encoding for data sent from PayPal to you (e.g., IPN, downloadable logs, emails)?'
- Click 'Save'
You can also define the charset value in the button code to match the charact values you have set in your options.

Payment validation got VERIFIED for web_accept transaction type but not for subscr_signup

We have been using "Post to return page" (rm = 2) as the way of receiving payment data for regular one time purchase (web_accept) and we have been getting "VERIFIED" fine when doing the validation. Recently we want to add a subscription-based product so I have been testing in the paypal sandbox and I am really baffled about what I did wrong for always getting INVALID when validating subscriptions (subscr_signup). The regular purchases returned VERIFIED in the sandbox just fine but not the subscriptions. It is the exact same piece of code for posting the validation, the same merchant/buyer combination...etc. Did I miss anything? Below is the common classic ASP code snippets which I have used. Please advise. Thanks
' read post from PayPal system and add 'cmd'
str = Request.Form & "&cmd=_notify-validate"
' post back to PayPal system to validate
'set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
There are some IPN issues that are currently effecting the live site. This issue that you are reporting sounds like it may be related to the issues. I would suggest opening up a ticket with PayPal's Merchant Technical Support team. This way we can look into the issue further and also notify you once the issue is resolved.

Display users's email after purchase with Paypal Website Payments Standard

I have a simple button created with Paypal's Website Payments Standard, and I'm using the feature "Take customers to this URL when they finish checkout".
On that page which users are being redirected to when the purchase is successful (on my site) I'd like to simply display the email associated with their paypal purchase, telling them something like "an invoice will be sent to this email address: xxx".
Is that possible without using the API or IPN (which I'd rather avoid because it seems like I can't set different IPN urls for deifferent buttons/products.)
Ended up using PDT, there's a great example of how to simply do this here:
http://www.geekality.net/2010/10/19/php-tutorial-paypal-payment-data-transfers-pdt/
Thanks PP_MTS_Chad, I wouldn't have found it if it wasn't for you pointing out that option.
You could use 1 of 2 ways to get information back to your return URL, without having to use IPN or an API. You could use PDT to return information back to your site, or you could use the return method which uses the variable "rm". You can find more out about IPN here, and there are also some sample scripts you can use on that site as well.
If you want to use the return method, this is a little different from PDT. With the return method you do not have to post the information back to PayPal to verify it. If you wanted PayPal to post the information over to your return page you would just simply enable auto return in your account under your profile. Then you would just include the following lines of code in your button code.
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://www.mysite.com/return.php">
The variable "rm", controls how you want the information sent back to you. You can set it to be a GET or a POST.
Allowable values are:
0 – all shopping cart payments use the GET method
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
The default is 0.
Note: The rm variable takes effect only if the return variable is set.