Code Duplication    Length = 86-86 lines in 2 locations

sdk/ECPay.Payment.Integration.php 2 locations

@@ 1163-1248 (lines=86) @@
1160
/**
1161
 *  付款方式:超商代碼
1162
 */
1163
class ECPay_CVS extends ECPay_Verification
1164
{
1165
    public $arPayMentExtend = [
1166
                            'Desc_1' => '',
1167
                            'Desc_2' => '',
1168
                            'Desc_3' => '',
1169
                            'Desc_4' => '',
1170
                            'PaymentInfoURL' => '',
1171
                            'ClientRedirectURL' => '',
1172
                            'StoreExpireDate' => '',
1173
                        ];
1174
1175
    //檢查共同參數
1176
    public function check_string($arParameters = [])
1177
    {
1178
        parent::check_string($arParameters);
1179
        if (! $arParameters['PlatformID']) {
1180
            unset($arParameters['PlatformID']);
1181
        }
1182
        unset($arParameters['IgnorePayment']);
1183
1184
        return $arParameters;
1185
    }
1186
1187
    //檢查CVS的延伸參數
1188
    public function check_extend_string($arExtend = [], $InvoiceMark = '')
1189
    {
1190
1191
        //沒設定參數的話,就給預設參數
1192
        foreach ($this->arPayMentExtend as $key => $value) {
1193
            if (! isset($arExtend[$key])) {
1194
                $arExtend[$key] = $value;
1195
            }
1196
        }
1197
1198
        //若有開發票,檢查一下發票參數
1199
        if ($InvoiceMark == 'Y') {
1200
            $arExtend = $this->check_invoiceString($arExtend);
1201
        }
1202
1203
        return $arExtend;
1204
    }
1205
1206
    //過濾多餘參數
1207
    public function filter_string($arExtend = [], $InvoiceMark = '')
1208
    {
1209
        $arPayMentExtend = ($InvoiceMark == '') ? array_keys($this->arPayMentExtend) : array_merge(array_keys($this->arPayMentExtend), $this->arInvoice);
1210
        foreach ($arExtend as $key => $value) {
1211
            if (! in_array($key, $arPayMentExtend)) {
1212
                unset($arExtend[$key]);
1213
            }
1214
        }
1215
1216
        return $arExtend;
1217
    }
1218
1219
    //檢查商品
1220
    public function check_goods($arParameters = [])
1221
    {
1222
        // 檢查產品名稱。
1223
        $szItemName = '';
1224
        $arErrors = [];
1225
        if (count($arParameters['Items']) > 0) {
1226
            foreach ($arParameters['Items'] as $keys => $value) {
1227
                $szItemName .= vsprintf('#%s %d %s x %u', $arParameters['Items'][$keys]);
1228
                if (! array_key_exists('ItemURL', $arParameters)) {
1229
                    $arParameters['ItemURL'] = $arParameters['Items'][$keys]['URL'];
1230
                }
1231
            }
1232
1233
            if (strlen($szItemName) > 0) {
1234
                $szItemName = mb_substr($szItemName, 1, 200);
1235
                $arParameters['ItemName'] = $szItemName;
1236
            }
1237
        } else {
1238
            array_push($arErrors, 'Goods information not found.');
1239
        }
1240
1241
        if (count($arErrors) > 0) {
1242
            throw new Exception(implode('<br>', $arErrors));
1243
        }
1244
1245
        unset($arParameters['Items']);
1246
1247
        return $arParameters;
1248
    }
1249
}
1250
1251
/**
@@ 1254-1339 (lines=86) @@
1251
/**
1252
 * 付款方式 : BARCODE.
1253
 */
1254
class ECPay_BARCODE extends ECPay_Verification
1255
{
1256
    public $arPayMentExtend = [
1257
                            'Desc_1' => '',
1258
                            'Desc_2' => '',
1259
                            'Desc_3' => '',
1260
                            'Desc_4' => '',
1261
                            'PaymentInfoURL' => '',
1262
                            'ClientRedirectURL' => '',
1263
                            'StoreExpireDate' => '',
1264
                        ];
1265
1266
    //檢查共同參數
1267
    public function check_string($arParameters = [])
1268
    {
1269
        parent::check_string($arParameters);
1270
        if (! $arParameters['PlatformID']) {
1271
            unset($arParameters['PlatformID']);
1272
        }
1273
        unset($arParameters['IgnorePayment']);
1274
1275
        return $arParameters;
1276
    }
1277
1278
    //檢查BARCODE的延伸參數
1279
    public function check_extend_string($arExtend = [], $InvoiceMark = '')
1280
    {
1281
1282
        //沒設定參數的話,就給預設參數
1283
        foreach ($this->arPayMentExtend as $key => $value) {
1284
            if (! isset($arExtend[$key])) {
1285
                $arExtend[$key] = $value;
1286
            }
1287
        }
1288
1289
        //若有開發票,檢查一下發票參數
1290
        if ($InvoiceMark == 'Y') {
1291
            $arExtend = $this->check_invoiceString($arExtend);
1292
        }
1293
1294
        return $arExtend;
1295
    }
1296
1297
    //過濾多餘參數
1298
    public function filter_string($arExtend = [], $InvoiceMark = '')
1299
    {
1300
        $arPayMentExtend = ($InvoiceMark == '') ? array_keys($this->arPayMentExtend) : array_merge(array_keys($this->arPayMentExtend), $this->arInvoice);
1301
        foreach ($arExtend as $key => $value) {
1302
            if (! in_array($key, $arPayMentExtend)) {
1303
                unset($arExtend[$key]);
1304
            }
1305
        }
1306
1307
        return $arExtend;
1308
    }
1309
1310
    //檢查商品
1311
    public function check_goods($arParameters = [])
1312
    {
1313
        // 檢查產品名稱。
1314
        $szItemName = '';
1315
        $arErrors = [];
1316
        if (count($arParameters['Items']) > 0) {
1317
            foreach ($arParameters['Items'] as $keys => $value) {
1318
                $szItemName .= vsprintf('#%s %d %s x %u', $arParameters['Items'][$keys]);
1319
                if (! array_key_exists('ItemURL', $arParameters)) {
1320
                    $arParameters['ItemURL'] = $arParameters['Items'][$keys]['URL'];
1321
                }
1322
            }
1323
1324
            if (strlen($szItemName) > 0) {
1325
                $szItemName = mb_substr($szItemName, 1, 200);
1326
                $arParameters['ItemName'] = $szItemName;
1327
            }
1328
        } else {
1329
            array_push($arErrors, 'Goods information not found.');
1330
        }
1331
1332
        if (count($arErrors) > 0) {
1333
            throw new Exception(implode('<br>', $arErrors));
1334
        }
1335
1336
        unset($arParameters['Items']);
1337
1338
        return $arParameters;
1339
    }
1340
}
1341
1342
/**