ari100krat.local /modules/shop/classes/model/paymethods/moneyua.php

Language PHP Lines 153
MD5 Hash bda49bdd483d8bacb0518389f4868036 Estimated Cost $3,095 (why?)
Repository https://bitbucket.org/seyar/ari100krat.local View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php defined('SYSPATH') OR die('No direct access allowed.');
/* @version $Id: v 0.1 ${date} - ${time} Exp $
 *
 * Project:     ${project.name}
 * File:        ${nameAndExt} * 
 *
 * This library is commercial distributed software; you can't
 * redistribute it and/or modify it without owner (or author) approval.
 *
 * @link http://bestartdesign.com
 * @Best IT Solutions (C) 2010
 * 
 * @author ${fullName} ${email}
 */
class Model_Paymethods_moneyua extends Model_Paymethods
{
    private $_method = 'Moneyua';

    function getItem( $where = NULL, $as_array = TRUE )
    {
        $query = DB::select()
            ->from('paymethod_'.strtolower($this->_method))
        ;

        if($where)
        {
            foreach($where as $key => $item)
                $query->where($key,'=', $item);
        }
        $result = $query->execute();
        if( $result->count() == 0 ) return array();
        else{
            if( $as_array )                return $result->as_array();
            else{
                $return = $result->current();
                $return['fields'] = array(
                    'PAYMENT_AMOUNT' => '',
                    'PAYMENT_INFO' => '',
                    'PAYMENT_DELIVER' => '',
                    'PAYMENT_ORDER' => '',
                    'PAYMENT_TYPE' => $return['payment_type'],
                    'MERCHANT_INFO' => $return['merchant_info'],
                    'SECRETCODE' => $return['secretcode'],
                    'PAYMENT_ADDVALUE' => str_replace(' ', '_', $return['payment_addvalue']),
                    'PAYMENT_RULE' => $return['payment_rule'],
                    'PAYMENT_RETURNRES' => Kohana::config('shop')->PAYMENT_RETURNRES,
                    'PAYMENT_RETURN' => Kohana::config('shop')->PAYMENT_RETURN,
                    'PAYMENT_RETURNFAIL' => Kohana::config('shop')->PAYMENT_RETURNFAIL,
                    'PAYMENT_RETURNMET' => 1,
                    'PAYMENT_TESTMODE' => $return['payment_testmode'],
                    'PAYMENT_HASH' => '',
                );
                return $return;
            }
        }

    }

    public function delete($id = NULL)
    {
        $query = DB::delete('paymethod_'.strtolower($this->_method));

        if (is_numeric($id))
	{
            $query->where('id', '=', $id); // ->limit(1)

	    $total_rows = $query->execute();
	}
    }

    public function delete_list($array)
    {
        $query = DB::delete('paymethod_'.strtolower($this->_method));

        if (count($array))
	{
            $query->where('id', 'IN', DB::expr('('.implode(',', $array).')') ); // ->limit(1)

	    $total_rows = $query->execute();
	}
        return true;
    }

    public function getCost($obj,$sum = 0,$weight = 0 )
    {   
        return (float)$sum * (float)$obj['percent'] / 100;
    }

    function add( $data )
    {
        list($insert_id, $total_rows) = DB::insert('paymethod_'.strtolower($this->_method),
            array (
                    'merchant_info',
                    'payment_testmode',
                    'percent',
                    'payment_rule',
                    'secretcode',
                    'payment_addvalue',
                    'invoice',
                    'ordersendmail',
                    'letter_description',
                    'action_url',
                    'payment_type',
                    'postavshik',
                )
            )
        ->values(
                array (
                    $data['merchant_info'],
                    (isset($data['payment_testmode']) && !empty($data['payment_testmode']) ? 1 : 0 ),
                    $data['percent'],
                    (isset($data['plusToOrder']) && !empty($data['plusToOrder']) ? 1 : 2 ),
                    $data['secretcode'],
                    $data['payment_addvalue'],
                    $data['invoice'],
                    $data['ordersendmail'],
                    $data['letter_description'],
                    $data['action_url'],
                    $data['payment_type'],
                    $data['postavshik'],
                )
            )
            ->execute()
        ;
        return $insert_id;
    }

    function save( $id, $data )
    {        
        DB::update('paymethod_'.strtolower($this->_method))
            ->set(
                array (
                    'merchant_info' => $data['merchant_info'],
                    'payment_testmode' => (isset($data['payment_testmode']) && !empty($data['payment_testmode']) ? 1 : 0 ),
                    'percent' => $data['percent'],
                    'payment_rule' => (isset($data['payment_rule']) && !empty($data['payment_rule']) ? 1 : 2 ),
                    'invoice' => $data['invoice'],
                    'secretcode' => $data['secretcode'],
                    'payment_addvalue' => $data['payment_addvalue'],
                    'ordersendmail' => $data['ordersendmail'],
                    'letter_description' => $data['letter_description'],
                    'action_url' => $data['action_url'],
                    'payment_type' => $data['payment_type'],
                    'postavshik' => $data['postavshik'],
                )
            )
            ->where('id','=',$id)
            ->execute()
        ;
        return true;
    }
}
?>
Back to Top