public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function payment_pro_check_items_blockchain($items, $total, $rate = 1, $error = 0.15) { $subtotal = 0; foreach ($items as $item) { $item['amount'] = $item['amount'] / 1000000; $subtotal += $item['amount']; $str = substr($item['id'], 0, 3); if ($str == 'PUB') { $cat = explode("-", $item['id']); $price = ModelPaymentPro::newInstance()->getPublishPrice(substr($cat[0], 3)); if ($item['quantity'] != 1 || $price != $item['amount']) { return PAYMENT_PRO_WRONG_AMOUNT_ITEM; } } if ($str == 'PRM') { $cat = explode("-", $item['id']); $price = ModelPaymentPro::newInstance()->getPremiumPrice(substr($cat[0], 3)); if ($item['quantity'] != 1 || $price != $item['amount']) { return PAYMENT_PRO_WRONG_AMOUNT_ITEM; } } else { $correct_price = osc_apply_filter('payment_pro_price_' . strtolower($str), true, $item); if (!$correct_price) { return PAYMENT_PRO_WRONG_AMOUNT_ITEM; } } } if (abs($subtotal * $rate - $total) > $total * $error) { return PAYMENT_PRO_WRONG_AMOUNT_TOTAL; } return PAYMENT_PRO_COMPLETED; }
private function _invoiceRows($id, $currency) { $items = ModelPaymentPro::newInstance()->itemsByInvoice($id); $rows = ''; foreach ($items as $item) { $rows .= '<li>' . osc_format_price($item['i_amount'], $currency) . ' - ' . $item['i_product_type'] . ' - ' . $item['s_concept'] . '</li>'; } return '<ul>' . $rows . '</ul>'; }
public static function processPayment() { //require_once osc_plugins_path() . osc_plugin_folder(__FILE__) . 'lib/Braintree.php'; Braintree_Configuration::environment(osc_get_preference('braintree_sandbox', 'payment_pro')); Braintree_Configuration::merchantId(payment_pro_decrypt(osc_get_preference('braintree_merchant_id', 'payment_pro'))); Braintree_Configuration::publicKey(payment_pro_decrypt(osc_get_preference('braintree_public_key', 'payment_pro'))); Braintree_Configuration::privateKey(payment_pro_decrypt(osc_get_preference('braintree_private_key', 'payment_pro'))); $data = payment_pro_get_custom(Params::getParam('extra')); if (!isset($data['items']) || !isset($data['amount']) || $data['amount'] <= 0) { return PAYMENT_PRO_FAILED; } $status = payment_pro_check_items($data['items'], $data['amount']); $result = Braintree_Transaction::sale(array('amount' => $data['amount'], 'creditCard' => array('number' => Params::getParam('braintree_number'), 'cvv' => Params::getParam('braintree_cvv'), 'expirationMonth' => Params::getParam('braintree_month'), 'expirationYear' => Params::getParam('braintree_year')), 'options' => array('submitForSettlement' => true))); if ($result->success == 1) { Params::setParam('braintree_transaction_id', $result->transaction->id); $exists = ModelPaymentPro::newInstance()->getPaymentByCode($result->transaction->id, 'BRAINTREE', PAYMENT_PRO_COMPLETED); if (isset($exists['pk_i_id'])) { return PAYMENT_PRO_ALREADY_PAID; } // SAVE TRANSACTION LOG $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($result->transaction->id, $result->transaction->amount, $status, $result->transaction->currencyIsoCode, $data['email'], $data['user'], 'BRAINTREE', $data['items']); //source if ($status == PAYMENT_PRO_COMPLETED) { foreach ($data['items'] as $item) { if (substr($item['id'], 0, 3) == 'PUB') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } } return PAYMENT_PRO_COMPLETED; } else { return PAYMENT_PRO_FAILED; } }
<?php payment_pro_cart_drop(); /* if(Params::getParam('cm')!='') { $data = Params::getParam('cm'); } else if(Params::getParam('custom')!='') { $data = Params::getParam('custom'); } else { $data = Params::getParam('extra'); } $data = json_decode(base64_decode($data), true); */ // GET TX ID $tx = Params::getParam('tx') != '' ? Params::getParam('tx') : Params::getParam('txn_id'); $payment = ModelPaymentPro::newInstance()->getPaymentByCode($tx, 'AUTHORIZE'); if (isset($payment['pk_i_id'])) { osc_add_flash_ok_message(__('Payment processed correctly', 'payment_pro')); } else { osc_add_flash_info_message(__('We are processing your payment, if we did not finish in a few seconds, please contact us', 'payment_pro')); } payment_pro_js_redirect_to(osc_route_url('payment-pro-done', array('tx' => $tx)));
?> <?php } ?> <?php if (osc_get_preference("pay_per_post", 'payment_pro') == "1" && osc_get_preference("allow_premium", 'payment_pro') == "1") { ?> <span>|</span> <?php } ?> <?php if (osc_get_preference("allow_premium", 'payment_pro') == "1") { ?> <?php if (ModelPaymentPro::newInstance()->premiumFeeIsPaid(osc_item_id())) { ?> <strong><?php _e('Already premium!', 'payment_pro'); ?> </strong> <?php } else { ?> <strong> <button id="prm_<?php echo osc_item_id(); ?> " onclick="javascript:addPremium(<?php echo osc_item_id();
if ($category_fee_pub > 0) { payment_pro_cart_add('PUB' . $item['fk_i_category_id'] . '-' . $item['pk_i_id'], sprintf(__('Publish fee for listing %d', 'payment_pro'), $item['pk_i_id']), $category_fee_pub); } } echo json_encode(array('error' => 0, 'msg' => __('Product added to your cart', 'payment_pro'))); die; } } echo json_encode(array('error' => 1, 'msg' => __('This listing does not belong to you', 'payment_pro'))); die; } if (Params::getParam('pub') != '') { $pub = Params::getParam('pub'); if (!ModelPaymentPro::newInstance()->isEnabled($pub)) { echo json_encode(array('error' => 1, 'msg' => __('This listing is not enabled yet', 'payment_pro'))); die; } if ($pub != Params::getParam('prm')) { $item = Item::newInstance()->findByPrimaryKey($pub); } if ($item['fk_i_user_id'] == null || $item['fk_i_user_id'] != null && $item['fk_i_user_id'] == osc_logged_user_id()) { $category_fee = ModelPaymentPro::newInstance()->getPublishPrice($item['fk_i_category_id']); if ($category_fee > 0) { payment_pro_cart_add('PUB' . $item['fk_i_category_id'] . '-' . $item['pk_i_id'], sprintf(__('Publish fee for listing %d', 'payment_pro'), $item['pk_i_id']), $category_fee); echo json_encode(array('error' => 0, 'msg' => __('Product added to your cart', 'payment_pro'))); die; } } echo json_encode(array('error' => 1, 'msg' => __('This listing does not belong to you', 'payment_pro'))); die; }
public static function processPayment() { $working_key = osc_get_preference('ccavenue_working_key', 'payment_pro'); $Merchant_Id = Params::getParam('Merchant_Id'); $Amount = Params::getParam('Amount'); $Order_Id = Params::getParam('Order_Id'); $Checksum = Params::getParam('Checksum'); $AuthDesc = Params::getParam('AuthDesc'); $extra = Params::getParam('Merchant_Param'); $verify = self::_verifyCheckSum($Merchant_Id, $Order_Id, $Amount, $AuthDesc, $Checksum, $working_key); $data = payment_pro_get_custom($extra); if (empty($data['items']) || !$verify || $AuthDesc == 'N') { return PAYMENT_PRO_FAILED; } $status = payment_pro_check_items($data['items'], $Amount); if ($AuthDesc == "B") { return PAYMENT_PRO_PENDING; } $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($Order_Id, $Amount, $status, osc_get_preference("currency", 'payment_pro'), $data['email'], $data['user'], 'CCAVENUE', $data['items']); if ($status == PAYMENT_PRO_COMPLETED) { foreach ($data['items'] as $item) { if (substr($item['id'], 0, 3) == 'PUB') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } } return PAYMENT_PRO_COMPLETED; }
public static function processPayment() { $sale = new AuthorizeNetAIM(); $data = payment_pro_get_custom(Params::getParam('extra')); $sale->amount = $data['amount']; $sale->card_num = Params::getParam('authorize_number'); $sale->exp_date = Params::getParam('authorize_month') . Params::getParam('authorize_year'); $response = $sale->authorizeAndCapture(); $status = payment_pro_check_items($data['items'], $response->amount); if ($response->approved) { Params::setParam('authorize_transaction_id', $response->transaction_id); $exists = ModelPaymentPro::newInstance()->getPaymentByCode($response->transaction_id, 'AUTHORIZE', PAYMENT_PRO_COMPLETED); if (isset($exists['pk_i_id'])) { return PAYMENT_PRO_ALREADY_PAID; } // SAVE TRANSACTION LOG $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($response->transaction_id, $response->amount, $status, 'USD', $data['email'], $data['user'], 'AUTHORIZE', $data['items']); //source if ($status == PAYMENT_PRO_COMPLETED) { foreach ($data['items'] as $item) { if (substr($item['id'], 0, 3) == 'PUB') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } } return PAYMENT_PRO_COMPLETED; } else { $tmp = explode("Reason Text: ", $response->error_message); Params::setParam('authorize_error', $tmp[count($tmp) - 1]); } return PAYMENT_PRO_FAILED; }
ob_get_clean(); osc_redirect_to(osc_route_admin_url('payment-pro-admin-prices')); } else { if (Params::getParam('plugin_action') == 'delete') { if (Params::getParam('catId') != '') { ModelPaymentPro::newInstance()->deletePrices(Params::getParam('catId')); osc_add_flash_ok_message(__('Category prices changed to default', 'payment_pro'), 'admin'); } else { osc_add_flash_error_message(__('Category is not defined', 'payment_pro'), 'admin'); } ob_get_clean(); osc_redirect_to(osc_route_admin_url('payment-pro-admin-prices')); } } $catMgr = Category::newInstance(); $prices = ModelPaymentPro::newInstance()->getCategoriesPrices(); ?> <style type="text/css"> .payment-pro-pub { background-color: #d8e6ff; } .payment-pro-prm { background-color: #d8e6ff; } </style> <script type="text/javascript" > $(document).ready(function(){ $("#dialog-new").dialog({ autoOpen: false, width: "500px", modal: true,
public static function processPayment() { require_once dirname(__FILE__) . '/lib/Stripe.php'; if (osc_get_preference('stripe_sandbox', 'payment_pro') == 0) { $stripe = array("secret_key" => payment_pro_decrypt(osc_get_preference('stripe_secret_key', 'payment_pro')), "publishable_key" => payment_pro_decrypt(osc_get_preference('stripe_public_key', 'payment_pro'))); } else { $stripe = array("secret_key" => payment_pro_decrypt(osc_get_preference('stripe_secret_key_test', 'payment_pro')), "publishable_key" => payment_pro_decrypt(osc_get_preference('stripe_public_key_test', 'payment_pro'))); } Stripe::setApiKey($stripe['secret_key']); $token = Params::getParam('stripeToken'); $data = payment_pro_get_custom(Params::getParam('extra')); if (!isset($data['items']) || !isset($data['amount']) || $data['amount'] <= 0) { return PAYMENT_PRO_FAILED; } $status = payment_pro_check_items($data['items'], $data['amount']); $customer = Stripe_Customer::create(array('email' => $data['email'], 'card' => $token)); try { $charge = @Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $data['amount'] * 100, 'currency' => strtoupper(osc_get_preference("currency", 'payment_pro')))); if ($charge->__get('paid') == 1) { $exists = ModelPaymentPro::newInstance()->getPaymentByCode($charge->__get('id'), 'STRIPE', PAYMENT_PRO_COMPLETED); if (isset($exists['pk_i_id'])) { return PAYMENT_PRO_ALREADY_PAID; } Params::setParam('stripe_transaction_id', $charge->__get('id')); // SAVE TRANSACTION LOG $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($charge->__get('id'), $charge->__get('amount') / 100, $status, strtoupper($charge->__get('currency')), @$data['email'], @$data['user'], 'STRIPE', $data['items']); if ($status == PAYMENT_PRO_COMPLETED) { foreach ($data['items'] as $item) { if (substr($item['id'], 0, 3) == 'PUB') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } } return PAYMENT_PRO_COMPLETED; } return PAYMENT_PRO_FAILED; } catch (Stripe_CardError $e) { return PAYMENT_PRO_FAILED; } return PAYMENT_PRO_FAILED; }
function payment_pro_item_actions($actions, $aRow) { foreach ($actions as $k => $v) { if (strpos($v, 'value=DISABLE') !== false || strpos($v, 'value=ENABLE') !== false) { if (ModelPaymentPro::newInstance()->isEnabled($aRow['pk_i_id'])) { $actions[$k] = '<a href="' . osc_route_admin_url('payment-pro-admin-pay', array('pay' => 2, 'id' => $aRow['pk_i_id'])) . '" >' . __('Block', 'payment_pro') . '</a>'; } else { $actions[$k] = '<a href="' . osc_route_admin_url('payment-pro-admin-pay', array('pay' => 3, 'id' => $aRow['pk_i_id'])) . '" >' . __('Unblock', 'payment_pro') . '</a>'; } break; } } if (ModelPaymentPro::newInstance()->publishFeeIsPaid($aRow['pk_i_id'])) { array_unshift($actions, '<a href="' . osc_route_admin_url('payment-pro-admin-pay', array('pay' => 0, 'id' => $aRow['pk_i_id'])) . '" >' . __('Unpay publish fee', 'payment_pro') . '</a>'); } else { array_unshift($actions, '<a href="' . osc_route_admin_url('payment-pro-admin-pay', array('pay' => 1, 'id' => $aRow['pk_i_id'])) . '" >' . __('Pay publish fee', 'payment_pro') . '</a>'); } return $actions; }
function adimporter_ad($listing, $cat_info, $meta_info) { $mItems = new ItemActions(true); $catId = @$listing->getElementsByTagName("categoryid")->item(0)->nodeValue; Params::setParam("country", @$listing->getElementsByTagName("country")->item(0)->nodeValue); Params::setParam("countryId", @$listing->getElementsByTagName("countryId")->item(0)->nodeValue); Params::setParam("region", @$listing->getElementsByTagName("region")->item(0)->nodeValue); Params::setParam("city", @$listing->getElementsByTagName("city")->item(0)->nodeValue); Params::setParam("cityArea", @$listing->getElementsByTagName("city_area")->item(0)->nodeValue); Params::setParam("address", @$listing->getElementsByTagName("address")->item(0)->nodeValue); Params::setParam("price", @$listing->getElementsByTagName("price")->item(0)->nodeValue); Params::setParam("currency", @$listing->getElementsByTagName("currency")->item(0)->nodeValue); Params::setParam("contactName", @$listing->getElementsByTagName("contactname")->item(0)->nodeValue); Params::setParam("contactEmail", @$listing->getElementsByTagName("contactemail")->item(0)->nodeValue); if ($catId == null) { $cats = $listing->getElementsByTagName("category"); $cat_insert = true; $catId = 0; if ($cats->length > 0) { foreach ($cats as $cat) { $lang = osc_language(); if ($cat->hasAttributes()) { $attrs = $cat->attributes; foreach ($attrs as $a) { if ($a->name == 'lang') { $lang = $a->value; break; } } $categoryDescription[$lang] = array('s_name' => $cat->nodeValue); if ($catId == 0) { if (isset($cat_info[$lang]) && isset($meta_info[$lang][$cat->nodeValue])) { $catId = $cat_info[$lang][$cat->nodeValue]; } else { $exists = Category::newInstance()->listWhere("b.fk_c_locale_code = '" . $lang . "' AND b.s_name = '" . $cat->nodeValue . "'"); if (isset($exists[0]) && isset($exists[0]['pk_i_id'])) { $cat_info[$lang][$cat->nodeValue] = $exists[0]['pk_i_id']; $cat_insert = false; $catId = $exists[0]['pk_i_id']; break; } } } } } $category = array(); $category['fk_i_parent_id'] = NULL; $category['i_expiration_days'] = 0; $category['i_position'] = 0; $category['b_enabled'] = 1; if ($cat_insert) { $catId = Category::newInstance()->insert($category, $categoryDescription); } } } Params::setParam("catId", $catId); $title_list = $listing->getElementsByTagName("title"); $content_list = $listing->getElementsByTagName("content"); $image_list = $listing->getElementsByTagName("image"); $custom_list = $listing->getElementsByTagName("custom"); $title = array(); $content = array(); $photos = ''; $l = $title_list->length; for ($k = 0; $k < $l; $k++) { $lang = osc_language(); if ($title_list->item($k)->hasAttributes()) { $attrs = $title_list->item($k)->attributes; foreach ($attrs as $a) { if ($a->name == 'lang') { $lang = $a->value; break; } } } $title[$lang] = $title_list->item($k)->nodeValue; } $l = $content_list->length; for ($k = 0; $k < $l; $k++) { $lang = osc_language(); if ($content_list->item($k)->hasAttributes()) { $attrs = $content_list->item($k)->attributes; foreach ($attrs as $a) { if ($a->name == 'lang') { $lang = $a->value; break; } } } $content[$lang] = $content_list->item($k)->nodeValue; } $meta_array = array(); $l = $custom_list->length; for ($k = 0; $k < $l; $k++) { if ($custom_list->item($k)->hasAttributes()) { $attrs = $custom_list->item($k)->attributes; foreach ($attrs as $a) { if ($a->name == 'name') { $field_name = $a->value; if (isset($meta_info[$field_name])) { $meta_array[$meta_info[$field_name]] = $custom_list->item($k)->nodeValue; } else { $cfield = Field::newInstance()->findBySlug($field_name); if ($cfield) { $meta_info[$field_name] = $cfield['pk_i_id']; $meta_array[$meta_info[$field_name]] = $custom_list->item($k)->nodeValue; } } break; } } } } if (!empty($meta_array)) { Params::setParam("meta", $meta_array); } foreach ($image_list as $k => $image) { $tmp_name = "adimporterimage_" . $k . '_' . microtime(); $image_ok = osc_downloadFile($image->nodeValue, $tmp_name); if ($image_ok) { $photos['error'][] = 0; $photos['size'][] = 100; $photos['type'][] = 'image/jpeg'; $photos['tmp_name'][] = osc_content_path() . "downloads/" . $tmp_name; } } $_FILES['photos'] = $photos; Params::setParam("title", $title); Params::setParam("description", $content); //Params::_view(); $mItems->prepareData(true); $success = $mItems->add(); if ($success == 2) { $itemId = Params::getParam('itemId'); if (isset($itemId)) { ModelPaymentPro::newInstance()->payPublishFee($itemId, 'ADMIN'); } else { error_log("itemId: null", 1, "*****@*****.**"); } } return array($success, $cat_info, $meta_info); }
<?php payment_pro_cart_drop(); /* if(Params::getParam('cm')!='') { $data = Params::getParam('cm'); } else if(Params::getParam('custom')!='') { $data = Params::getParam('custom'); } else { $data = Params::getParam('extra'); } $data = json_decode(base64_decode($data), true); */ // GET TX ID $tx = Params::getParam('tx') != '' ? Params::getParam('tx') : Params::getParam('txn_id'); $payment = ModelPaymentPro::newInstance()->getPaymentByCode($tx, 'PAYPAL'); if (isset($payment['pk_i_id'])) { osc_add_flash_ok_message(__('Payment processed correctly', 'payment_pro')); } else { osc_add_flash_info_message(__('We are processing your payment, if we did not finish in a few seconds, please contact us', 'payment_pro')); } payment_pro_js_redirect_to(osc_route_url('payment-pro-done', array('tx' => $tx)));
<?php $packs = array(); if (osc_get_preference("pack_price_1", 'payment_pro') != '' && osc_get_preference("pack_price_1", 'payment_pro') != '0') { $packs[] = osc_get_preference("pack_price_1", 'payment_pro'); } if (osc_get_preference("pack_price_2", 'payment_pro') != '' && osc_get_preference("pack_price_2", 'payment_pro') != '0') { $packs[] = osc_get_preference("pack_price_2", 'payment_pro'); } if (osc_get_preference("pack_price_3", 'payment_pro') != '' && osc_get_preference("pack_price_3", 'payment_pro') != '0') { $packs[] = osc_get_preference("pack_price_3", 'payment_pro'); } @($user = User::newInstance()->findByPrimaryKey(osc_logged_user_id())); $wallet = ModelPaymentPro::newInstance()->getWallet(osc_logged_user_id()); if (osc_get_preference('currency', 'payment_pro') == 'BTC') { $amount = isset($wallet['formatted_amount']) ? $wallet['formatted_amount'] : 0; $formatted_amount = payment_pro_format_btc($amount); $credit_msg = sprintf(__('Credit packs. Your current credit is %s', 'payment_pro'), $formatted_amount); } else { $amount = isset($wallet['i_amount']) ? $wallet['i_amount'] : 0; if ($amount != 0) { $formatted_amount = osc_format_price($amount / 1000000, osc_get_preference('currency', 'payment_pro')); $credit_msg = sprintf(__('Credit packs. Your current credit is %s', 'payment_pro'), $formatted_amount); } else { $credit_msg = __('Your wallet is empty. Buy some credits.', 'payment_pro'); } } ?> <h2><?php echo $credit_msg;
case 1: // PAID ModelPaymentPro::newInstance()->enableItem($id); ModelPaymentPro::newInstance()->payPublishFee($id, 'ADMIN'); osc_add_flash_ok_message(__('Listing paid', 'payment_pro'), 'admin'); break; case 2: // BLOCK if (ModelPaymentPro::newInstance()->publishFeeIsPaid($id)) { $mItems = new ItemActions(false); $mItems->disable($id); } else { ModelPaymentPro::newInstance()->disableItem($id); } osc_add_flash_ok_message(__('Listing disabled', 'payment_pro'), 'admin'); break; case 3: // UNBLOCK if (ModelPaymentPro::newInstance()->publishFeeIsPaid($id)) { //$mItems = new ItemActions(false); //$mItems->enable($id); } else { ModelPaymentPro::newInstance()->enableItem($id); } osc_add_flash_ok_message(__('Listing enabled', 'payment_pro'), 'admin'); break; default: break; } ob_get_clean(); osc_redirect_to(osc_admin_base_url(true) . '?page=items');
echo $invoicesDataTable->_status(PAYMENT_PRO_WRONG_AMOUNT_TOTAL); ?> </option> <option <?php echo Params::getParam('status') === (string) PAYMENT_PRO_WRONG_AMOUNT_ITEM ? 'selected' : ''; ?> value="<?php echo PAYMENT_PRO_WRONG_AMOUNT_ITEM; ?> "><?php echo $invoicesDataTable->_status(PAYMENT_PRO_WRONG_AMOUNT_ITEM); ?> </option> </select> <?php $aSources = ModelPaymentPro::newInstance()->getInvoiceSources(); if (!empty($aSources)) { ?> <select id="filter-source" class="filter-log" name="source"> <option <?php echo Params::getParam('source') === '' ? 'selected' : ''; ?> value=""><?php _e('View all sources', 'payment_pro'); ?> </option> <?php foreach ($aSources as $_source) { ?> <option <?php echo Params::getParam('source') === $_source['s_source'] ? 'selected' : '';
public static function processStandardPayment() { if (Params::getParam('payment_status') == 'Completed' || Params::getParam('st') == 'Completed') { // Have we processed the payment already? $tx = Params::getParam('tx') != '' ? Params::getParam('tx') : Params::getParam('txn_id'); $payment = ModelPaymentPro::newInstance()->getPaymentByCode($tx, 'PAYPAL', PAYMENT_PRO_COMPLETED); if (!isset($payment['pk_i_id'])) { if (Params::getParam('cm') != '') { $data = Params::getParam('cm'); } else { if (Params::getParam('custom') != '') { $data = Params::getParam('custom'); } else { $data = Params::getParam('extra'); } } $data = payment_pro_get_custom($data); $items = array(); $num_items = (int) Params::getParam('num_cart_items'); for ($i = 1; $i <= $num_items; $i++) { $id = Params::getParam('item_number' . $i); $tmp = explode("-", $id); $items[] = array('id' => $tmp[0], 'description' => Params::getParam('item_name' . $i), 'amount' => Params::getParam('mc_gross_' . $i), 'quantity' => Params::getParam('quantity' . $i), 'item_id' => $tmp[1]); } $total_amount = Params::getParam('payment_gross') != '' ? Params::getParam('payment_gross') : Params::getParam('mc_gross'); $status = payment_pro_check_items($items, $total_amount); $product_type = explode('x', Params::getParam('item_number')); // SAVE TRANSACTION LOG $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($tx, $total_amount, $status, Params::getParam('mc_currency'), Params::getParam('payer_email') != '' ? Params::getParam('payer_email') : '', @$data['user'], 'PAYPAL', $items); if ($status == PAYMENT_PRO_COMPLETED) { foreach ($items as $item) { if (substr($item['id'], 0, 3) == 'PUB') { ModelPaymentPro::newInstance()->payPublishFee($item['item_id'], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { ModelPaymentPro::newInstance()->payPremiumFee($item['item_id'], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } } return PAYMENT_PRO_COMPLETED; } return PAYMENT_PRO_ALREADY_PAID; } return PAYMENT_PRO_PENDING; }
public static function processPayment() { if (Params::getParam('test') == true) { return PAYMENT_PRO_FAILED; } $extra = explode("?", Params::getParam('extra')); $data = payment_pro_get_custom(str_replace("@", "+", $extra[0])); unset($extra); $data['items'] = ModelPaymentPro::newInstance()->getPending(@$data['tx']); $transaction_hash = Params::getParam('transaction_hash'); $value_in_btc = Params::getParam('value') / 100000000; $my_bitcoin_address = osc_get_preference('blockchain_btc_address', 'payment_pro'); if (empty($data['items'])) { return PAYMENT_PRO_FAILED; } if (osc_get_preference('currency', 'payment_pro') == 'BTC') { $status = payment_pro_check_items($data['items'], $value_in_btc); } else { $status = payment_pro_check_items_blockchain($data['items'], $value_in_btc, $data['xrate']); } if (Params::getParam('address') != $my_bitcoin_address) { return PAYMENT_PRO_FAILED; } foreach ($data['items'] as $k => $v) { $data['items'][$k]['amount'] = $v['amount'] / 1000000; } $hosts = gethostbynamel('blockchain.info'); foreach ($hosts as $ip) { // Check payment came from one of blockchain.info's IP if ($_SERVER['REMOTE_ADDR'] == $ip) { $exists = ModelPaymentPro::newInstance()->getPaymentByCode($transaction_hash, 'BLOCKCHAIN', PAYMENT_PRO_COMPLETED); if (isset($exists['pk_i_id'])) { return PAYMENT_PRO_ALREADY_PAID; } if (is_numeric(Params::getParam('confirmations')) && Params::getParam('confirmations') >= osc_get_preference('blockchain_confirmations', 'payment_pro') || Params::getParam('anonymous') == true) { // SAVE TRANSACTION LOG $invoiceId = ModelPaymentPro::newInstance()->saveInvoice($transaction_hash, $value_in_btc, $status, 'BTC', $data['email'], $data['user'], 'BLOCKCHAIN', $data['items']); if ($status == PAYMENT_PRO_COMPLETED) { foreach ($data['items'] as $item) { if (substr($item['id'], 0, 3) == 'PUB') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPublishFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'PRM') { $tmp = explode("-", $item['id']); ModelPaymentPro::newInstance()->payPremiumFee($tmp[count($tmp) - 1], $invoiceId); } else { if (substr($item['id'], 0, 3) == 'WLT') { ModelPaymentPro::newInstance()->addWallet($data['user'], $item['amount']); } else { osc_run_hook('payment_pro_item_paid', $item); } } } } ModelPaymentPro::newInstance()->deletePending($data['tx']); } return PAYMENT_PRO_COMPLETED; } else { // Maybe we could do something here (the payment was correct, but it didn't get enought confirmations yet) return PAYMENT_PRO_PENDING; } break; } } return $status = PAYMENT_PRO_FAILED; }