[TYPO3-commerce] ugly hack for payment gateway
Tomas Larsen
info at typo3support.cn
Sun Feb 25 00:50:14 CET 2007
Hi Stephan,
:-) remember to remove the md5secret and other sensitive information!
I have changed it in the gateway now, so don't worry.
Tomas
On 22/02/07 14:50, in article
mailman.1.1172152258.19174.typo3-project-commerce at lists.netfielders.de,
"Stephan Viftrup" <sviftrup at gmail.com> wrote:
> Hi
>
> I thought ill post my results in integrating a gateway payment where
> the user must be redirected to an url and then return to your website
> after payment has been done. This is the case mostly in denmark if you
> do not own a ssl certificate yourself.
>
> Perhaps someone can use it and maybe even integrate better as there are
> som complications.
>
> I have changed the following in class.tx_commerce.pi3.php
>
> // variables the gateway needs
> $language = "da";
> $autocapture = "0";
> // orderid is added 1000 because gateway needs 4 digits.
> $ordernum = 1000 + $this->orderUid;
> $merchant = "xxxxxxxx";
> // get amount
> $amount = $orderData['sum_price_gross'];
> $currency = "DKK";
> $okpage = "http://mediamax.dk/";
> $errorpage = "http://mediamax.dk/index.php?id=45";
> // result page where script will opdate orders payment_ref
> $resultpage = "http://mediamax.dk/index.php?id=32&step=result";
> $md5secret =
> "{md5 hash}";
> $md5check =
> md5($language.$autocapture.$ordernum.$amount.$currency.$merchant.$okpage.$erro
> rpage.$resultpage.$ccipage.$md5secret);
>
>
> // gateway url
> $action = "https://secure.quickpay.dk/quickpay.php";
>
>
> // generate button for going to gateway. Needed because gateway only
> accepts POST variables.
> $payform = '<form name="listingForm" action="'.$action.'" method="post">';
> $payform .= '<input type="hidden" name="language" value="'.$language.'" />';
> $payform .= '<input type="hidden" name="autocapture"
> value="'.$autocapture.'" />';
> $payform .= '<input type="hidden" name="ordernum" value="'.$ordernum.'" />';
> $payform .= '<input type="hidden" name="merchant" value="'.$merchant.'" />';
> $payform .= '<input type="hidden" name="amount" value="'.$amount.'" />';
> $payform .= '<input type="hidden" name="currency" value="'.$currency.'" />';
> $payform .= '<input type="hidden" name="okpage" value="'.$okpage.'" />';
> $payform .= '<input type="hidden" name="errorpage"
> value="'.$errorpage.'" />';
> $payform .= '<input type="hidden" name="resultpage"
> value="'.$resultpage.'" />';
> $payform .= '<input type="hidden" name="md5checkV2"
> value="'.$md5check.'" /> <input type="submit" value="Gå til betaling"
> /></form>';
>
> // make ekstra MARKER for button
> // OBS! Must also be defined in FINISH template
> $markerArray['###PAYMENT_BUTTON###'] = $payform;
>
>
> This is inserted in OUTPUT part of finishIt function. around line 780
>
> Also needed is opdate script for resultpage of gateway - i have put
> this in same file at the beginning of main function - but this is
> again not very pretty.
>
> // RESULT FROM GATEWAY
>
> // return url from gateway
> if ($_REQUEST["step"] == 'result') {
> // gateway only accepts id with at least 4 digits, remove these again.
> $id = $_REQUEST["ordernum"] - 1000;
>
> //transaction is a POST value the Gateway returns - save it as payment_ref
> $fields_values = array ("payment_ref_id" => $_REQUEST["transaction"]);
>
> //Update order
> $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_commerce_orders',"uid=$id",
> $fields_values);
>
> }
>
> KNOW PROBLEMS
> - This bypasses the normal payment structure hence making payment
> selection useless since this will happen no matter what you do.
>
>
> Hope this can get the discussion more specific to this kind of gateway
> procedue
>
More information about the TYPO3-project-commerce
mailing list