[TYPO3-commerce] ugly hack for payment gateway
Stephan Viftrup
sviftrup at gmail.com
Mon Apr 9 14:11:23 CEST 2007
Hi Andreas
I have not been looking here the last days so i did not see your
message. Allthough my way of handling payment is still a ugly hack it
has become more stable. I have not used the localconf.php though.
I would much like to see the code you have made so that i can lean from
your approach if you'll still let me. Perhaps i can be of assistance
too.
Stephan
> ok seems my question concerns http://bugs.typo3.org/view.php?id=5027
>
> andreas
>
> Andreas Stauder wrote:
>> Hi Stephan,
>>
>> just a question: how have you integrated the new payment type? If I
>> write it in typo3conf/localconf.php it will be overwritten by
>> ext_localconf.php . How have you done it?
>>
>> I'am working on a similar thing: A payment gateway in Switzerland. But
> I
>> have done the first step with a hook. I can send you the code when finished...
>>
>> Thanks for your help
>> Andreas
>>
>> Stephan Viftrup 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 = "25571851";
>>> // 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=res
> ult";
>>> $md5secret =
>>> "vYTn54eSLUNZG8m81iC7h5s26k68u3R8M97rfj497VI4tX43JB3l152d7F11cx9D";
>>> $md5check =
>>> md5($language.$autocapture.$ordernum.$amount.$currency.$merchant.$okpa
> ge.$errorpage.$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 be
> taling"
>>> /></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
--
Regards
Stephan Viftrup
SV - Consult
More information about the TYPO3-project-commerce
mailing list