Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Posts
    7
    Plugin Contributions
    0

    Default custom payment module help with coupons

    Hi everybody, i'm posting here that seems the most appropriate thread to me... hopefully!
    I'd like some help for this issue.
    I'm implementing a credit card module which redirects the user on a bank website using the curl_setopt() function, so i have this code:

    $data="id=$id&password=$password&action=$action&amt=$amt&currencycode=$currencyc ode&langid=$langid&responseurl=$responseurl&errorurl=$errorurl&trackid=$trackid& udf1=$udf1";
    $curl_handle=curl_init();
    curl_setopt($curl_handle,CURLOPT_URL,bank link xxxx');
    curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data);
    $buffer = curl_exec($curl_handle);
    curl_close($curl_handle);
    $token=explode(":",$buffer);
    $tid=$token[0];

    my payment URL will be something like:
    $this->form_action_url = 'bank link xxx/payment.jsp?PaymentID='.$tid;

    Now, if i add the "curl" code in the class constructor the module is working perfectly but the amount sent to the bank page is not correct in case of coupons, because the array $order has not been processed for taxes and coupons yet. But if i add the "curl code" into the "process_button" function (where the array order is already updated) i cannot find a way to change the "form action" so i cannot set the proper payment id.
    Do you guys could please help me to have this sorted because i can't find a solution!! thanx a lot everyone :)
    Last edited by Kim; 17 May 2011 at 07:04 PM.

  2. #2
    Join Date
    Jan 2009
    Posts
    7
    Plugin Contributions
    0

    Default Re: custom payment module help

    hi again! if nobody can help I was thinking maybe someone knows about a payment module where is used the curl_opt? I can study the code by myself if you can suggest me an existing module with the same logic...
    thanks again

  3. #3
    Join Date
    Jan 2009
    Posts
    7
    Plugin Contributions
    0

    Default Re: custom payment module help

    well, dunno if anyone else one day could be need of it, but i solved it this way (guess it's working because the coupon's validity is properly checked on phase 2, so this code won't check the coupon but just take it off from the total)

    // into constructor
    if (($order->info['coupon_code'] != '') or ($_POST['dc_redeem_code'] != '')) $discount = calculateCoupon($order->info['coupon_code'], $order->info['total'], $_POST['dc_redeem_code']);
    else $discount =0;
    // the amount to pass into the form action
    $importo= ($order->info['total']) - $discount;
    // the function
    function calculateCoupon($cupon,$tot, $code) {
    if ($cupon != '') $cup = $cupon; else $cup = $code;
    $sql_c='select * from coupons where coupon_code like "'.$cup.'" limit 0,1';
    $query_c=@mysql_query($sql_c);
    $row=@mysql_fetch_array($query_c);
    if ($row['coupon_type'] == 'F') $discount= $row['coupon_amount'];
    else $discount= $tot * $row['coupon_amount'] / 100;
    return $discount;
    }

 

 

Similar Threads

  1. v152 Coupons not working when payment module is on. Need help Please
    By Fadora Vapor in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 26
    Last Post: 14 Apr 2014, 12:14 AM
  2. v151 Low order fee in trouble with custom payment module
    By ellivir in forum Addon Payment Modules
    Replies: 3
    Last Post: 27 Feb 2014, 03:32 PM
  3. Custom payment module text help
    By SethF in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 1 Oct 2011, 10:47 AM
  4. Discount coupons with payment module problem!
    By thuxen in forum Addon Payment Modules
    Replies: 0
    Last Post: 15 Oct 2009, 04:56 PM
  5. Help needed with custom payment module
    By etrader in forum General Questions
    Replies: 1
    Last Post: 2 Dec 2008, 03:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg