[TYPO3-commerce] Server to Server communication for finishing the order
jcamp
jonathan at accentika.co.uk
Wed Jul 30 14:17:55 CEST 2008
In article
<mailman.1.1210092856.21008.typo3-project-commerce at lists.netfielders.de>
,
Josef Stich <j.stich at bee4me.net> wrote:
> Hi,
>
> for my payment provider I send the user to an external site to do the
> actual payment. The user is then sent back and the order is finished.
>
> My payment provider also calls my server in the background to tell if
> the payment was successful in case the user is not redirected back to my
> site.
>
> 1. User is redirected to the external site.
> 2. User finishes payment.
> 3. Payment provider calls my server in the background.
> 4. User gets redirected to my site.
>
> So if all steps work, the user comes back to my site, all session
> information is available (basket, addresses, etc.) and the order is
> finished in pi3.
>
> But when it only comes to step 3 I don't have the session information
> automatically.
>
> Is there a way in commerce to finish the order in step 3 or would I have
> to finish it manually (restoring the session, setting all objects
> (basket, products, articles, addresses), creating an entry in the orders
> table, sending out the mails,...)
>
> Thanks,
> Josef
Hi Josef
I had a similar problem (using worldpay) which redirects by pulling your
site page into its system so that the page actually comes from the
worldpay servers and all session info is lost. I needed to recreate the
session, recreate the basket and (sometimes) automatically log the user
in from the worldpay domain. Wrestled with this for a loooooooooooong
time. $GLOBALS["TSFE"]->initFEuser(); was the answer. Here is the code I
am using. It took me such trail and error to get it right, if you spot
any redundancy, please let me know. Hope this helps. Thank you.
Jonathan
//Add basket to session
$GLOBALS['TSFE']->fe_user->tx_commerce_basket =
t3lib_div::makeInstance('tx_commerce_basket');
$GLOBALS['TSFE']->fe_user->tx_commerce_basket->set_session_id($_POST['M_s
id']);
$GLOBALS['TSFE']->fe_user->tx_commerce_basket->load_data();
if (!is_array($GLOBALS['TSFE']->fe_user->user)){
$rSql =
$GLOBALS["TYPO3_DB"]->exec_SELECTquery("*","fe_users","uid='" .
$_POST['M_uid'] . "'");
unset($GLOBALS['TSFE']->fe_user->user);
if(($aUser = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($rSql)) !==
FALSE) {
$GLOBALS["TSFE"]->fe_user->createUserSession($aUser);
$GLOBALS["TSFE"]->fe_user->loginSessionStarted = TRUE;
$GLOBALS["TSFE"]->fe_user->user =
$GLOBALS["TSFE"]->fe_user->fetchUserSession();
$GLOBALS ["TSFE"] ->loginUser = 1;
$GLOBALS ["TSFE"] ->fe_user->start();
}
}
}
//Init a new FEUser session on new domain based on FE_SESSION_KEY;
$GLOBALS["TSFE"]->initFEuser();
More information about the TYPO3-project-commerce
mailing list