sandbox paypal La transaction a expire - paypal-sandbox

Here's the correct translation for this question, which was originally asked in french. Note that I have taken liberty to translate the comments in the code.
My procedure worked correctly during tests in my sandbox. When I put it into operational mode, it still worked correctly. Then I added a check in my code to prevent access to the sandbox version by copy/pasting the URL. Now my website works correctly in operational mode, but my sandbox vresion doesn't work anymore.
Link to operational mode.
Link to sandbox mode.
The procedure:
//
// VENDOR PARAMETERS FOR SANDBOX VERSION
//
if ($proctest == "1")
{
$url_nvp = 'https://api-3t.sandbox.paypal.com/nvp'; // Sandbox version
$version = 64.0; // Version
$iduser = 'f-facilitator_api1.x.fr'; // User
$passwrd = '0123456789'; // Password
// Signature
$signature = 'AFcWxV21C7fd0v3bYYYRCpSSRl31ALWKEzeddmFHrClYoc6tJpZiawjH';
}
//
// VENDOR PARAMETERS FOR OPERATIONAL VERSION
//
else
{
$url_nvp = 'https://api-3t.paypal.com/nvp'; // Operational website
$version = 64.0; // Version
$iduser = 'f_api1.x.fr'; // User
$passwrd = '0123456789'; // Password
// Signature
$signature = 'Apekq0Tf.isqMqkIsEX7RsjIFTVCA8EehX5M263oELbE40NBWWYxhtW1';
}
//
// BUILDING THE STRING
//
$api_paypal= $url_nvp.'?VERSION=' .$version // Builds the URL
.'&USER=' .$iduser
.'&PWD=' .$passwrd
.'&SIGNATURE=' .$signature;
return $api_paypal; // Returns the string
}
Then:
//
// TEST ENVIRONMENT FOR NVP'S API
//
if ($proctest == "1")
{
header("Location: https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=".$liste_param_paypal['TOKEN']);
}
//
// OPERATIONAL ENVIRONMENT FOR NVP'S API
//
else
{
header("Location: https://www.paypal.com/webscr&cmd=_express-checkout&token=".$liste_param_paypal['TOKEN']);
}
I can't find what prevents the sandbox version from running correctly.

Related

Symfony3 add locale in deeplink

I create a new site in symfony3 following the getting started section in the official symfony documentation in https://symfony.com/doc/current/setup.html
Everything is working ok.. if I put mydomain.com as the URL, the framework add /en or the correct local.
My question is if there is a way that if the user do a deeplink to mydomain.com/blog the framework found that the local is not present so it can add and transform the url to mydomain.com/en/blog
I'm not adding the code as it is the default one. Let me know if you need it.
There are multiple ways to do this. Probably the easiest is to have an EventSubscriber or -Listener that catches request without a locale and then handles adding that information. Since you based your project on the demo application you might want to look at their solution: https://github.com/symfony/demo/blob/master/src/EventSubscriber/RedirectToPreferredLocaleSubscriber.php
The steps to perform in your event handler are roughly these:
Listen to kernel.request event
Return early based on some criteria, e.g. homepage, a cookie with the language is set, or something else
Detect the language either by getting the default locale or determining from your available locales and the browser header which language fits best (see: https://github.com/willdurand/Negotiation#language-negotiation)
Redirect, add the locale as attribute to request, write the currently set language to a cookie, or whatever else you need to do to change the route
Thanks to #dbrumann I get to this solution... For sure it can be improve to use less code but it just did the trick.
I updated the onKernelRequest method in RedirectToPreferredLocaleSubscriber class
public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
$path = explode('/',$request->getPathInfo());
$hasLocale = false;
foreach ($this->locales as $key => $l) {
if($l == $path[1]){
$hasLocale = true;
}
}
if(!$hasLocale){
// Ignore sub-requests and all URLs but the homepage
if (!$event->isMasterRequest() || '/' !== $request->getPathInfo()) {
$preferredLanguage = $request->getPreferredLanguage($this->locales);
if ($preferredLanguage !== $this->defaultLocale) {
$url = "";
foreach ($path as $key => $p) {
if($key > 0){
$url .= "/" . $p;
}
}
//print_r('/' . $preferredLanguage . $url);exit;
$response = new RedirectResponse('/' . $preferredLanguage . $url);
$event->setResponse($response);
}
}
else{
// Ignore requests from referrers with the same HTTP host in order to prevent
// changing language for users who possibly already selected it for this application.
if (0 === mb_stripos($request->headers->get('referer'), $request->getSchemeAndHttpHost())) {
return;
}
$preferredLanguage = $request->getPreferredLanguage($this->locales);
if ($preferredLanguage !== $this->defaultLocale) {
$response = new RedirectResponse($this->urlGenerator->generate('homepage', ['_locale' => $preferredLanguage]));
$event->setResponse($response);
}
}
}
}

ADFS Single sign on is not working with session state mode "UserUri"

Our asp.net website was working fine with ADFS SSO since we made a change in the session state cookie settings from "Use Cookies" to "USE URI". After making this change, fam.IsSignInResponse(request) is always false in the below code so that it redirects back to the ADFS login screen recursively.
public List<ClaimEntity> GetClaims()
{
logger.Info("Started executing GetClaims()");
List<ClaimEntity> claims = new List<ClaimEntity>();
// sam is configured in web.config
var sam = FederatedAuthentication.SessionAuthenticationModule;
logger.Info("Declaring sam");
// fam is not
var fam = new WSFederationAuthenticationModule();
logger.Info("Declaring fam");
//fam.FederationConfiguration = FederatedAuthentication.FederationConfiguration;
fam.ServiceConfiguration = FederatedAuthentication.ServiceConfiguration;
logger.Info("Assigning ServiceConfiguration to fam");
var request = thisContext.Request;
// is this the response from the STS
if (!fam.IsSignInResponse(request))
{
// no
logger.Info("fam.IsSignInResponse => No");
// the STS
fam.Issuer = _IssuerSTSSpec.Issuer;
logger.Info("IssuerUrl= " + _IssuerSTSSpec.Issuer);
// the return address
fam.Realm = thisContext.Request.Url.AbsoluteUri;
logger.Info("Assigning fam.Realm= " + thisContext.Request.Url.AbsoluteUri);
logger.Info("Creating SignInRequest...");
var req = fam.CreateSignInRequest(string.Empty, null, false);
logger.Info("Redirecting to the issuer...");
logger.Info("Request to STS: "+ req.WriteQueryString().ToString());
// go to STS
thisContext.Response.Redirect(req.WriteQueryString());
}
else
{
// yes
-----------
-----------
}
logger.Info("Returning the claims");
return claims;
}
Is "USE URI" session cookie mode is not supported with ADFS integrated application or any changes required in my code?
It would help understand better if you add the example code of "Use URI".
Is there really a need to use this method?
Using cookies will keep the URL clean and it is more manageable. And if it is already working for you, you can go with it unless there is really need to use URI

Wordpress - Facebook SDK - Comments Plugin Loads in Staging but not in Production

We are trying to use the Facebook SDK to engage users. We have a simple Facebook App on our blog that allows users to "sign in" with Facebook as well as "Comment" on articles etc. On our staging site, loading the Facebook SDK asynchronously, we have this functionality working normally, users can sign in with Facebook and Comment on posts. However, on the production site which is using the exact same Wordpress theme files and Wordpress App ID, the Comments only load SOMETIMES (1/10 times). Here is the code in "Header.php" that I am using to access the Facebook SDK in both the staging and production. Much of my code was taken from the Facebook SDK "Sign in with Facebook" Instructions. As you can see, I have already tried using FB.XFBML.parse(); to reload the XFBML but it doesn't make any differnce. Any help anyone can give me as to why the Comments plugin loads in Staging and Production would be much appreciated.
<script>window.isSigned = 0;
////////////FB LOGIN STUFF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response.status);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// You are logged into your app and Facebook.
document.getElementById('fbinfoz').innerHTML = '1'
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('fbinfoz').innerHTML = '0'
/*document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';*/
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('fbinfoz').innerHTML = '0'
/*document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';*/
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXXXXXXX',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.8' // use graph api version 2.8
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
jQuery(document).ready(function(){
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=id,name,first_name,last_name,email,age_range,birthday,gender,locale,timezone,picture', function(response) {
console.log('Successful login for: ' + response.name);
var fbname = response.name;
console.log('First Name: ' + response.first_name);
var fbfname = response.first_name;
console.log('Last Name: ' + response.last_name);
var fblname = response.last_name;
console.log('Email: ' + response.email);
var fbemail = response.email;
console.log('FB ID: ' + response.id);
var fbid = response.id;
console.log('Age Range Min: ' + response.age_range.min);
var fbagerange = response.age_range.min;
console.log('Birthday: ' + response.birthday);
console.log('Gender: ' + response.gender);
var fbgender = response.gender;
console.log('Locale: ' + response.locale);
var fblocale = response.locale;
console.log('Timezone: ' + response.timezone);
var fbtimezone = response.timezone;
console.log('Picture: http://graph.facebook.com/' + response.id +'/picture?type=large');
var fbpicture = 'Picture: http://graph.facebook.com/' + response.id +'/picture?type=large';
/* document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';*/
});
});
}
</script>
And the Comments Section:
<script>
FB.XFBML.parse();
</script>
<div id="facebookCommentz" style="" class="fb-comments" data-width="100%" data-href="<?php echo get_permalink(); ?>" data-numposts="5"></div>
Thanks for your help!
I thought I would share what ultimately fixed this problem. Our Staging site and Production site were both using the same Facebook App ID. The Staging site was set up with a .htaccess redirect that forwards all other IPs except ours to the Production site. We were testing the Facebook Comments plugin on the Staging site by adding Comments to staging pages, but those same live pages on the Production site would not gain the comments. I simply created a new Facebook App with a new App ID and everything works normally.
So, I guess the answer is: It's best to have two different Facebook App ID's for Staging and Production.

Distriqt Push Notification Extension: How to know if user has not allowed PNs on first application run?

I'm using Distriqt Push Notifications Extension and I can't get it working correctly if the user does not allow PNs on first run: the application ends registering the user because it states that PNs are enabled and available.
I do the following:
if (PushNotifications.isSupported()) {
registerPushNotifications();
}
private function registerPushNotifications():void {
PushNotifications.service.addEventListener(PushNotificationEvent.REGISTER_SUCCESS, onPushNotificationToken);
PushNotifications.service.register(MODEL.Configuration.GCM_SENDER_ID);
}
private function onPushNotificationToken(event:PushNotificationEvent):void {
if (PushNotifications.service.isEnabled) { registerDevice(); }
}
Does not PushNotifications.service.isEnabled supposed to be false if the user disallows it? When does it become false? How am I supposed to handle this case scenario?
I've found what was happening in my application:
I'm handling activate/deactivate events to enable and disable background execution: NativeApplication.nativeApplication.executeInBackground = true;. This makes your application able to run on background, ignoring the UI which asks for user permission and it happens that PushNotifications.service.isEnabled is true on first run after installation.
What I've done is delaying adding activation and deactivation listeners till one of this things happen first:
The device does not support push notifications PushNotifications.isEnabled == false
When the device receive a push token
When the device fails receiving a push token
I hope this helps someone.
Just posting this here for anyone else who has issues with the isEnabled flag:
var hasRequestedPermissionsOnce:Boolean = false;
// You should load hasRequestedPermissionsOnce from some persistent storage, defaulting to false
...
PushNotifications.init( APP_KEY );
if (PushNotifications.isSupported)
{
if (PushNotifications.service.isEnabled)
{
// Notifications have been enabled by the user
// You are free to register and expect a registration success
register();
}
else if (!hasRequestedPermissionsOnce)
{
// You should implement hasRequestedPermissionsOnce somewhere to check if this is the first run of the app
// If we haven't called register once yet the isEnabled flag may be false as we haven't requested permissions
// You can just register here to request permissions or use a dialog to delay the request
register();
}
else
{
// The user has disabled notifications
// Advise your user of the lack of notifications as you see fit
}
}
...
private function register():void
{
// You should save hasRequestedPermissionsOnce to a shared object, file or other persistent storage
hasRequestedPermissionsOnce = true;
PushNotifications.service.addEventListener( PushNotificationEvent.REGISTER_SUCCESS, registerSuccessHandler );
PushNotifications.service.addEventListener( PushNotificationEvent.REGISTER_FAILED, registerFailedHandler );
PushNotifications.service.register( GCM_SENDER_ID );
}
Original source here: https://gist.github.com/marchbold/fb0438cf326a44cea0cf#file-distriqt-extensions-pushnotifications-isenabled-as

facebook sdk (php) can't get access token

EDITS: See this picture: http://trackauthoritymusic.com/wwwroot/images/fb-issue-bug.jpg.
For snapshots of the Network tab and all HTTPS headers from my page through FB's redirect.
The windows in the image above show the var_dump's in the code below:
For an access token I only get default the combined appId|secret.
When I var_dump $_REQUESTS at the first point of contact from Facebook, I get nothing so know codeigniter is not stripping the values, but i'm definitely not getting an "signed_request" post from Facebook!
I'm 85.1% sure my Facebook app settings are fine. I've made dozens of tweaks and resets while testing to no success.
And when I switch the settings to client-side approach with the access token in the browser hash, i DO get a valid token, but am desperately trying to avoid all that javascript on my page and will need the php integrated anyway.
All of this only happens once you've approved the app, and I can manually look up their membership in Insights, but know they can't access the app without seeing their token.
I had put this bug aside until now, since my ORIGINAL POST below April 24:....
It's been 3 days with trial-n-error and research:
My Environment: LAMP using facebook sdk 3 & CodeIgniter 2
Login Code:
$CI->load->library('facebook', array("appId"=>APP_ID, "secret"=>APP_SECRET));
$this->visitor['access_token'] = $CI->facebook->getAccessToken();
$fb_id = $CI->facebook->getUser();
var_dump($CI->facebook); // see picture above
var_dump($fb_id); // == 0
if ($fb_id && $fb_id > 0) {
$temp = $CI->users->getUserByFb($fb_id);
if (!$temp) {
$this->insertFBUser($fb_id);
$this->visitor['redirect'] = "?prompt=newfb";
} else {
$this->visitor = array_merge($this->visitor, $temp);
if (isset($this->visitor['user_allowed']) && $this->visitor['user_allowed'] == 0) {
$CI->users->updateUser(array("user_allowed" => 1), $this->visitor['user_id']);
}
}
} else {
array_push($this->errors, $CI->input->get_post("error_msg", false));
array_push($this->errors, $CI->input->get_post("error_code", false));
array_push($this->errors, $CI->input->get_post("error_reason", false));
array_push($this->errors, $CI->input->get_post("error", false));
array_push($this->errors, $CI->input->get_post("error_description", false));
if ($CI->input->get_post("autoclose", false) == true) {
array_push($this->errors, "javascript stackoverflow is encoding weird, but basically changes the hashtag of the pop-window, so the parent page automatically closes it");
}
var_dump($this->errors);
die("nada");
}
Research & Debugging:
This post describes my problem as well, but the solution did not work: stackoverflow.com/questions/8587098/suddenly-getuser-became-to-return-0-php-3-1-1-sdk with or without the trailing comma in the DROP_QUERY_PARAMS array on this page.
Facebook is sending me NO error messages in the url, post, or session and scraping my page fine
EVERYTHING worked fine a few days ago and i've changed very little around this code.
The login now fails whether i use http or https
The popup link opens at:
www.facebook.com/dialog/oauth?client_id=222912307731474&redirect_uri=https%3A%2F%2Ftrackauthoritymusic.com%2Fmanage%2Fusers%2Flogin%3Fautoclose%3Dtrue&state=4522cb9da5bf5107d690a22eee6c5a2e&scope=email&display=popup while redirecting successfully to my desired login url with both state and code parameters apparently valid: trackauthoritymusic.com/manage/users/login?autoclose=true&state=4522cb9da5bf5107d690a22eee6c5a2e&code=AQBfSkI4y_VxhCuF3coVvNmjetdGZjugyFv0UsLlKt5sR5MEGdY8KqpDXZKvqHTGaSHhzY4pHXuR_zmilkwmoQ5y6M9jh15GPI6DXz5E2fSBizAVlrlebriNGcNZb4DRaDFK8cxPJoa9xB2ERuimtuizmlZERNa8hwJxLXtztqkWWhkLFCaGjQvAyyf5jJRkuoztmvfKDIZz3W9lslM6fk_m
but at this point, the sdk cannot get any access token or facebook session data.
PLEASE HELP!
I fixed this by using codeigniter's input library within the Facebook SDK to get the code/token and all $_GET/$_POST/$_REQUEST globals.
See the git diff on the facebook sdk. I'm still not sure what i did to break thisthough. OAuth/Login WAS working consistently before a certain point. I'm sure this wasn't just some race condition on codeigniter occasionally clearing the globals
## -490,10 +490,11 ##
*/
public function getSignedRequest() {
if (!$this->signedRequest) {
- if (!empty($_REQUEST['signed_request'])) {
- $this->signedRequest = $this->parseSignedRequest(
- $_REQUEST['signed_request']);
- } elseif (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
+ $CI = & get_instance();
+ $signed_request = $CI->input->get_post("signed_request");
+ if (!empty($signed_request)) {
+ $this->signedRequest = $this->parseSignedRequest($signed_request);
+ } else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
$this->signedRequest = $this->parseSignedRequest(
$_COOKIE[$this->getSignedRequestCookieName()]);
}
## -691,15 +692,18 ##
protected function getCode() {
- if (isset($_REQUEST['code'])) {
- if ($this->state !== null &&
- isset($_REQUEST['state']) &&
- $this->state === $_REQUEST['state']) {
-
+ $CI = & get_instance();
+ $code = $CI->input->get_post("code");
+ if (!empty($code)) {
+ $state = $CI->input->get_post("state");
+ if ($this->state !== null && $state && $this->state === $state) {
// CSRF state has done its job, so clear it
$this->state = null;
$this->clearPersistentData('state');
- return $_REQUEST['code'];
+ return $code;
} else {
self::errorLog('CSRF state token does not match one provided.');
return false;
$params['access_token'] = $this->getAccessToken();
}

Resources