$params['mode'] = 'sandbox'; $min = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_min'); $secret = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_secret'); $page = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_request'); $lang = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_lang'); } else { $params['mode'] = 'live'; $min = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_min'); $secret = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_secret'); $page = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_request'); $lang = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_lang'); } $params['MIN'] = $min; $params['INVOICE'] = $payment_ref; $params['AMOUNT'] = $amount_to_pay; $params['CURRENCY'] = adminCurrencyCode(); $params['EXP_TIME'] = date('d.m.Y', strtotime('+5 days')); $params['DESCR'] = $payment_description; $fields['PAGE'] = $page; $fields['LANG'] = $lang; $fields['URL_OK'] = websiteUrl() . "/merchant/epaybg/mode/accept/token/{$my_token}"; $fields['URL_CANCEL'] = websiteUrl() . "/merchant/epaybg/mode/cancel"; $params['AMOUNT'] = $amount_to_pay; $EpayBg = new EpayBg(); $EpayBg->params = $params; $EpayBg->fields = $fields; $EpayBg->min = $min; $EpayBg->secret = $secret; $forms = $EpayBg->generateForms(); /*dump($params); dump($fields);*/
public function merchantPayment() { $token = isset($this->data['token']) ? $this->data['token'] : ''; if (isset($this->data['payment_opt'])) { if (!($merchant = Yii::app()->functions->getMerchantByToken($token))) { $this->msg = Yii::t("default", "ERROR: cannot get merchant information"); return; } if ($this->data['payment_opt'] == "ccr") { if (is_numeric($this->data['cc_id'])) { if (isset($this->data['renew'])) { $membership_info = Yii::app()->functions->upgradeMembership($merchant['merchant_id'], $this->data['package_id']); $params = array('package_id' => $this->data['package_id'], 'merchant_id' => $merchant['merchant_id'], 'price' => $membership_info['package_price'], 'payment_type' => $this->data['payment_opt'], 'mt_id' => $this->data['cc_id'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'membership_expired' => $membership_info['membership_expired']); $this->insertData("{{package_trans}}", $params); $params_update = array('package_id' => $this->data['package_id'], 'package_price' => $membership_info['package_price'], 'membership_expired' => $membership_info['membership_expired'], 'membership_purchase_date' => date('c'), 'status' => 'active'); $this->updateData("{{merchant}}", $params_update, 'merchant_id', $merchant['merchant_id']); $this->code = 1; $this->msg = Yii::t("default", "Payment Successful"); } else { $params = array('package_id' => $merchant['package_id'], 'merchant_id' => $merchant['merchant_id'], 'price' => $merchant['package_price'], 'payment_type' => $this->data['payment_opt'], 'mt_id' => $this->data['cc_id'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']); if ($package = Yii::app()->functions->getPackagesById($merchant['package_id'])) { $expiration = $package['expiration']; $membership_expired = date('Y-m-d', strtotime("+{$expiration} days")); $params['membership_expired'] = $membership_expired; } if ($this->insertData("{{package_trans}}", $params)) { $this->code = 1; $this->msg = Yii::t("default", "Payment Successful"); $this->details = $token; $this->updateData("{{merchant}}", array('payment_steps' => 3, 'membership_purchase_date' => date('c')), 'merchant_id', $merchant['merchant_id']); } else { $this->msg = Yii::t("default", "ERROR: Cannot insert records."); } } } else { $this->msg = Yii::t("default", "Please select credit card."); } } elseif ($this->data['payment_opt'] == "pyp") { if (isset($this->data['renew'])) { if ($new_info = Yii::app()->functions->getPackagesById($this->data['package_id'])) { $package_price = $new_info['price']; if ($new_info['promo_price'] > 0) { $package_price = $new_info['promo_price']; } $merchant['package_name'] = $new_info['title']; $merchant['package_id'] = $new_info['package_id']; } else { $package_price = 0; } } else { $package_price = $merchant['package_price']; } $paypal_con = Yii::app()->functions->getPaypalConnectionAdmin(); $params = ''; $x = 0; $params['L_NAME' . $x] = isset($merchant['package_name']) ? $merchant['package_name'] : Yii::t("default", "No description"); $params['L_NUMBER' . $x] = $merchant['package_id']; $params['L_DESC' . $x] = isset($merchant['package_name']) ? $merchant['package_name'] : Yii::t("default", "No description"); $params['L_AMT' . $x] = normalPrettyPrice($package_price); $params['L_QTY' . $x] = 1; $params['AMT'] = normalPrettyPrice($package_price); /** add card fee */ $card_fee = Yii::app()->functions->getOptionAdmin('admin_paypal_fee'); if (!empty($card_fee) && $card_fee >= 0.1) { $x++; $params['L_NAME' . $x] = t("Card Fee"); $params['L_DESC' . $x] = t("Card Fee"); $params['L_AMT' . $x] = normalPrettyPrice($card_fee); $params['L_QTY' . $x] = 1; $params['AMT'] = $params['AMT'] + $card_fee; } if (isset($this->data['renew'])) { $params['RETURNURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3a/internal-token/{$token}/renew/1/package_id/" . $this->data['package_id']; } else { $params['RETURNURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3a/internal-token/{$token}"; } $params['CANCELURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3/token/{$token}"; $params['NOSHIPPING'] = '1'; $params['LANDINGPAGE'] = 'Billing'; $params['SOLUTIONTYPE'] = 'Sole'; $params['CURRENCYCODE'] = adminCurrencyCode(); $paypal = new Paypal($paypal_con); $paypal->params = $params; $paypal->debug = false; if ($resp = $paypal->setExpressCheckout()) { $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to paypal."); $this->details = $resp['url']; } else { $this->msg = $paypal->getError(); } } elseif ($this->data['payment_opt'] == "stp") { /*STRIPE*/ $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to stripe"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "mcd") { /*MERCADO*/ $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to mercadopago"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/mcd"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/mcd/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "pyl") { /*PAYLINE*/ $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to payline"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/pyl"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/pyl/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "ide") { /*PAYLINE*/ $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to Sisow"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/ide"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/ide/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "payu") { /*PAYLINE*/ $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to PayUMoney"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/payu"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/payu/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "obd") { // offline bank deposit if (Yii::app()->functions->offlineBankDeposit($merchant, $this->data)) { $this->code = 1; $this->msg = Yii::t("default", "Thank You. an email has been sent to your email."); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/thankyou3/token/{$token}/"; } else { $this->msg = Yii::t("default", "Error: cannot send bank instructions email"); } } elseif ($this->data['payment_opt'] == "pys") { // paysera $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you to paysera"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/pys"; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/pys/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "bcy") { // barclay $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/" . $this->data['payment_opt']; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/bcy/renew/1/package_id/" . $this->data['package_id']; } } elseif ($this->data['payment_opt'] == "epy") { // EpayBg $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/" . $this->data['payment_opt']; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/epy/renew/1/package_id/" . $this->data['package_id']; } } else { if (isset($this->data['payment_opt'])) { $this->code = 1; $this->msg = Yii::t("default", "Please wait while we redirect you"); $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/" . $this->data['payment_opt']; if (isset($this->data['renew'])) { $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/gateway/" . $this->data['payment_opt'] . "/renew/1/package_id/" . $this->data['package_id']; } } else { $this->msg = Yii::t("default", "No payment method has been selected."); } } } else { $this->msg = Yii::t("default", "Please select payment option"); } }
public function payoutRequest($payment_method = '', $data = '') { $token = md5($this->generateRandomKey()); $wd_days_process = Yii::app()->functions->getOptionAdmin("wd_days_process"); //if (empty($wd_days_process)){ if (!is_numeric($wd_days_process)) { $wd_days_process = 5; } $process_date = date("Y-m-d", strtotime(" +{$wd_days_process} days")); switch ($payment_method) { case "paypal": $params = array('merchant_id' => $this->getMerchantID(), 'payment_type' => $data['payment_type'], 'payment_method' => $data['payment_method'], 'amount' => $data['amount'], 'currency_code' => adminCurrencyCode(), 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'account' => $data['account'], 'date_to_process' => $process_date, 'current_balance' => $data['current_balance'], 'balance' => $data['current_balance'] - $data['amount'], 'date_to_process' => $process_date, 'withdrawal_token' => $token); if ($this->db_ext->insertData("{{withdrawal}}", $params)) { //return Yii::app()->db->getLastInsertID(); return array('id' => Yii::app()->db->getLastInsertID(), 'token' => $token); } break; case "bank": $wd_bank_fields = yii::app()->functions->getOptionAdmin('wd_bank_fields'); $mtid = Yii::app()->functions->getMerchantID(); $params = array('merchant_id' => $this->getMerchantID(), 'payment_type' => $data['payment_type'], 'payment_method' => $data['payment_method'], 'amount' => $data['amount'], 'currency_code' => adminCurrencyCode(), 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'account_name' => $data['account_name'], 'bank_account_number' => $data['bank_account_number'], 'swift_code' => $data['swift_code'], 'bank_name' => isset($data['bank_name']) ? $data['bank_name'] : '', 'bank_branch' => isset($data['bank_branch']) ? $data['bank_branch'] : '', 'bank_country' => isset($data['bank_country']) ? $data['bank_country'] : '', 'date_to_process' => $process_date, 'current_balance' => $data['current_balance'], 'balance' => $data['current_balance'] - $data['amount'], 'date_to_process' => $process_date, 'withdrawal_token' => $token); if (!empty($wd_bank_fields)) { $params['bank_type'] = $wd_bank_fields; } if (isset($data['default_account_bank'])) { if ($data['default_account_bank'] == 2) { Yii::app()->functions->updateOption("merchant_payout_bank_account", json_encode($params), $this->getMerchantID()); } } if ($this->db_ext->insertData("{{withdrawal}}", $params)) { //return Yii::app()->db->getLastInsertID(); return array('id' => Yii::app()->db->getLastInsertID(), 'token' => $token); } break; default: break; } return true; }