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')); Braintree_Configuration::merchantId(payment_decrypt(osc_get_preference('braintree_merchant_id', 'payment'))); Braintree_Configuration::publicKey(payment_decrypt(osc_get_preference('braintree_public_key', 'payment'))); Braintree_Configuration::privateKey(payment_decrypt(osc_get_preference('braintree_private_key', 'payment'))); $data = payment_get_custom(Params::getParam('extra')); $tmp = explode('x', $data['product']); if (count($tmp) > 1) { $amount = $tmp[1]; } else { return PAYMENT_FAILED; } $result = Braintree_Transaction::sale(array('amount' => $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))); print_r($result); if ($result->success == 1) { Params::setParam('braintree_transaction_id', $result->transaction->id); $exists = ModelPayment::newInstance()->getPaymentByCode($result->transaction->id, 'BRAINTREE'); if (isset($exists['pk_i_id'])) { return PAYMENT_ALREADY_PAID; } $product_type = explode('x', $data['product']); // SAVE TRANSACTION LOG $payment_id = ModelPayment::newInstance()->saveLog($data['concept'], $result->transaction->id, $result->transaction->amount, $result->transaction->currencyIsoCode, $data['email'], $data['user'], $data['itemid'], $product_type[0], 'BRAINTREE'); //source if ($product_type[0] == '101') { ModelPayment::newInstance()->payPublishFee($product_type[2], $payment_id); } else { if ($product_type[0] == '201') { ModelPayment::newInstance()->payPremiumFee($product_type[2], $payment_id); } else { ModelPayment::newInstance()->addWallet($data['user'], $result->transaction->amount); } } return PAYMENT_COMPLETED; } else { return PAYMENT_FAILED; } }
public static function processPayment() { if (osc_get_preference('coinjar_sandbox', 'payment') != 1) { $coinjar = new CoinJar(payment_decrypt(osc_get_preference('coinjar_merchant_user', 'payment')), payment_decrypt(osc_get_preference('coinjar_merchant_password', 'payment')), payment_decrypt(osc_get_preference('coinjar_api_key', 'payment'))); } else { $coinjar = new CoinJar(payment_decrypt(osc_get_preference('coinjar_sb_merchant_user', 'payment')), payment_decrypt(osc_get_preference('coinjar_sb_merchant_password', 'payment')), payment_decrypt(osc_get_preference('coinjar_sb_api_key', 'payment')), true); } // data from the post (it's supposed to be sent by CoinJar, is sent by POST!) if (Params::existParam('uuid') && Params::existParam('amount') && Params::existParam('currency') && Params::existParam('status') && Params::existParam('ipn_digest')) { if (Params::getParam('status') == 'COMPLETED') { $digest = $coinjar->IPNDigest(Params::getParam('uuid'), Params::getParam('amount'), Params::getParam('currency'), Params::getParam('status')); if ($digest == Params::getParam('ipn_digest')) { $order = json_decode($coinjar->order(Params::getParam('uuid'))); if ($order != null) { if (Params::getParam('amount') == $order->order->amount && Params::getParam('currency') == $order->order->currency && Params::getParam('status') == $order->order->status) { $payment = ModelPayment::newInstance()->getPayment($order->order->uuid); if (!$payment) { $data = payment_get_custom(Params::getParam('extra')); $product_type = explode('x', Params::getParam('item_number')); // SAVE TRANSACTION LOG $payment_id = ModelPayment::newInstance()->saveLog($data['concept'], $order->order->uuid, $order->order->amount, $order->order->currenct, $data['email'], $data['user'], $data['itemid'], $product_type[0], 'COINJAR'); //source if ($product_type[0] == '101') { ModelPayment::newInstance()->payPublishFee($product_type[2], $payment_id); } else { if ($product_type[0] == '201') { ModelPayment::newInstance()->payPremiumFee($product_type[2], $payment_id); } else { ModelPayment::newInstance()->addWallet($data['user'], $order->order->amount); } } return PAYMENT_COMPLETED; } else { return PAYMENT_ALREADY_PAID; } } } } } } return PAYMENT_PENDING; }
?> <br/> </div> <div class="payments-options"> <?php _e("In order to make visible your ad to other users, it's required to pay a fee", 'payment'); ?> .<br/> <?php echo sprintf(__('The current fee for this category is: %.2f %s', 'payment'), $category_fee, osc_get_preference('currency', 'payment')); ?> <br/> <ul class="payments-ul"> <?php if (osc_is_web_user_logged_in()) { $wallet = ModelPayment::newInstance()->getWallet(osc_logged_user_id()); if (isset($wallet['formatted_amount']) && $wallet['formatted_amount'] >= $category_fee) { wallet_button($category_fee, sprintf(__('Publish fee for item %d at %s', 'payment'), $item['pk_i_id'], osc_page_title()), "101x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id'], array('user' => $item['fk_i_user_id'], 'itemid' => $item['pk_i_id'], 'email' => $item['s_contact_email'])); } else { payment_buttons($category_fee, sprintf(__('Publish fee for item %d at %s', 'payment'), $item['pk_i_id'], osc_page_title()), "101x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id'], array('user' => $item['fk_i_user_id'], 'itemid' => $item['pk_i_id'], 'email' => $item['s_contact_email'])); } } else { payment_buttons($category_fee, sprintf(__('Publish fee for item %d at %s', 'payment'), $item['pk_i_id'], osc_page_title()), "101x" . $item['fk_i_category_id'] . "x" . $item['pk_i_id'], array('user' => $item['fk_i_user_id'], 'itemid' => $item['pk_i_id'], 'email' => $item['s_contact_email'])); } ?> </ul> </div> <div style="clear:both;"></div> <?php payment_buttons_js(); ?>
public static function processPayment() { require_once osc_plugins_path() . osc_plugin_folder(__FILE__) . 'lib/Stripe.php'; if (osc_get_preference('stripe_sandbox', 'payment') == 0) { $stripe = array("secret_key" => osc_get_preference('stripe_secret_key', 'payment'), "publishable_key" => osc_get_preference('stripe_public_key', 'payment')); } else { $stripe = array("secret_key" => osc_get_preference('stripe_secret_key_test', 'payment'), "publishable_key" => osc_get_preference('stripe_public_key_test', 'payment')); } Stripe::setApiKey($stripe['secret_key']); $token = Params::getParam('stripeToken'); $data = payment_get_custom(Params::getParam('extra')); $amount = payment_get_amount($data['product']); if ($amount <= 0) { return PAYMENT_FAILED; } $customer = Stripe_Customer::create(array('email' => $data['email'], 'card' => $token)); try { $charge = @Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $amount * 100, 'currency' => osc_get_preference("currency", "payment"))); if ($charge->__get('paid') == 1) { $exists = ModelPayment::newInstance()->getPaymentByCode($charge->__get('id'), 'STRIPE'); if (isset($exists['pk_i_id'])) { return PAYMENT_ALREADY_PAID; } $product_type = explode('x', $data['product']); Params::setParam('stripe_transaction_id', $charge->__get('id')); // SAVE TRANSACTION LOG $payment_id = ModelPayment::newInstance()->saveLog($data['concept'], $charge->__get('id'), $charge->__get('amount') / 100, $charge->__get('currency'), $data['email'], $data['user'], $data['itemid'], $product_type[0], 'STRIPE'); //source if ($product_type[0] == '101') { ModelPayment::newInstance()->payPublishFee($product_type[2], $payment_id); } else { if ($product_type[0] == '201') { ModelPayment::newInstance()->payPremiumFee($product_type[2], $payment_id); } else { ModelPayment::newInstance()->addWallet($data['user'], $charge->__get('amount') / 100); } } return PAYMENT_COMPLETED; } return PAYMENT_FAILED; } catch (Stripe_CardError $e) { return PAYMENT_FAILED; } return PAYMENT_FAILED; }
function payment_update_version() { ModelPayment::newInstance()->versionUpdate(); }
public function versionUpdate() { $version = osc_get_preference('version', 'payment'); if ($version < 200) { osc_set_preference('version', 200, 'payment', 'INTEGER'); $this->dao->query(sprintf('ALTER TABLE %s ADD i_amount BIGINT(20) NULL AFTER f_amount', ModelPayment::newInstance()->getTable_log())); $this->dao->query(sprintf('ALTER TABLE %s ADD i_amount BIGINT(20) NULL AFTER f_amount', ModelPayment::newInstance()->getTable_wallet())); $this->dao->select('*'); $this->dao->from($this->getTable_wallet()); $result = $this->dao->get(); if ($result) { $wallets = $result->result(); foreach ($wallets as $w) { $this->dao->update($this->getTable_wallet(), array('i_amount' => $w['f_amount'] * 1000000000000), array('fk_i_user_id' => $w['fk_i_user_id'])); } } $this->dao->select('*'); $this->dao->from($this->getTable_log()); $result = $this->dao->get(); if ($result) { $logs = $result->result(); foreach ($logs as $log) { $this->dao->update($this->getTable_log(), array('i_amount' => $log['f_amount'] * 1000000000000), array('pk_i_id' => $log['pk_i_id'])); } } osc_reset_preferences(); } }
?> <?php } ?> <?php if (osc_get_preference("pay_per_post", "payment") == "1" && osc_get_preference("allow_premium", "payment") == "1") { ?> <span>|</span> <?php } ?> <?php if (osc_get_preference("allow_premium", "payment") == "1") { ?> <?php if (ModelPayment::newInstance()->premiumFeeIsPaid(osc_item_id())) { ?> <strong><?php _e('Already premium!', 'payment'); ?> </strong> <?php } else { ?> <strong><a href="<?php echo osc_route_url('payment-premium', array('itemId' => osc_item_id())); ?> "><?php _e('Make premium', 'payment'); ?> </a></strong>
* License along with this program. If not, see <http://www.gnu.org/licenses/>. */ $mp = ModelPayment::newInstance(); if (Params::getParam('plugin_action') == 'done') { $pub_prices = Params::getParam("pub_prices"); $pr_prices = Params::getParam("pr_prices"); foreach ($pr_prices as $k => $v) { $mp->insertPrice($k, $pub_prices[$k] == '' ? NULL : $pub_prices[$k], $v == '' ? NULL : $v); } // HACK : This will make possible use of the flash messages ;) ob_get_clean(); osc_add_flash_ok_message(__('Congratulations, the plugin is now configured', 'payment'), 'admin'); osc_redirect_to(osc_route_admin_url('payment-admin-prices')); } $categories = Category::newInstance()->toTreeAll(); $prices = ModelPayment::newInstance()->getCategoriesPrices(); $cat_prices = array(); foreach ($prices as $p) { $cat_prices[$p['fk_i_category_id']]['f_publish_cost'] = $p['f_publish_cost']; $cat_prices[$p['fk_i_category_id']]['f_premium_cost'] = $p['f_premium_cost']; } function drawCategories($categories, $depth = 0, $cat_prices) { foreach ($categories as $c) { ?> <tr> <td> <?php for ($d = 0; $d < $depth; $d++) { echo " "; }
public static function processDGPayment($doresponse, $response) { $data = payment_get_custom(Params::getParam('extra')); if ($doresponse['ACK'] == 'Success' || $doresponse['ACK'] == 'SuccessWithWarning') { $product_type = explode('x', urldecode($response['L_PAYMENTREQUEST_0_NUMBER0'])); // SAVE TRANSACTION LOG $payment_id = ModelPayment::newInstance()->saveLog(urldecode($response['L_PAYMENTREQUEST_0_NAME0']), urldecode($doresponse['PAYMENTINFO_0_TRANSACTIONID']), urldecode($doresponse['PAYMENTINFO_0_AMT']), urldecode($doresponse['PAYMENTINFO_0_CURRENCYCODE']), isset($response['EMAIL']) ? urldecode($response['EMAIL']) : '', $data['user'], $data['itemid'], $product_type[0], 'PAYPAL'); //source if ($product_type[0] == '101') { ModelPayment::newInstance()->payPublishFee($product_type[2], $payment_id); } else { if ($product_type[0] == '201') { ModelPayment::newInstance()->payPremiumFee($product_type[2], $payment_id); } else { ModelPayment::newInstance()->addWallet($data['user'], Params::getParam('mc_gross') != '' ? Params::getParam('mc_gross') : Params::getParam('payment_gross')); } } return PAYMENT_COMPLETED; } else { if ($doresponse['ACK'] == "Failure" || $doresponse['ACK'] == "FailureWithWarning") { return PAYMENT_FAILED; } } return PAYMENT_PENDING; }
/** * Send email to un-registered users with payment options * * @param integer $item * @param float $category_fee */ function payment_send_email($item, $category_fee) { if (osc_is_web_user_logged_in()) { return false; } $mPages = new Page(); $aPage = $mPages->findByInternalName('email_payment'); $locale = osc_current_user_locale(); $content = array(); if (isset($aPage['locale'][$locale]['s_title'])) { $content = $aPage['locale'][$locale]; } else { $content = current($aPage['locale']); } $item_url = osc_item_url(); $item_url = '<a href="' . $item_url . '" >' . $item_url . '</a>'; $publish_url = osc_route_url('payment-publish', array('itemId' => $item['pk_i_id'])); $premium_url = osc_route_url('payment-premium', array('itemId' => $item['pk_i_id'])); $words = array(); $words[] = array('{ITEM_ID}', '{CONTACT_NAME}', '{CONTACT_EMAIL}', '{WEB_URL}', '{ITEM_TITLE}', '{ITEM_URL}', '{WEB_TITLE}', '{PUBLISH_LINK}', '{PUBLISH_URL}', '{PREMIUM_LINK}', '{PREMIUM_URL}', '{START_PUBLISH_FEE}', '{END_PUBLISH_FEE}', '{START_PREMIUM_FEE}', '{END_PREMIUM_FEE}'); $words[] = array($item['pk_i_id'], $item['s_contact_name'], $item['s_contact_email'], osc_base_url(), $item['s_title'], $item_url, osc_page_title(), '<a href="' . $publish_url . '">' . $publish_url . '</a>', $publish_url, '<a href="' . $premium_url . '">' . $premium_url . '</a>', $premium_url, '', '', '', ''); if ($category_fee == 0) { $content['s_text'] = preg_replace('|{START_PUBLISH_FEE}(.*){END_PUBLISH_FEE}|', '', $content['s_text']); } $premium_fee = ModelPayment::newInstance()->getPremiumPrice($item['fk_i_category_id']); if ($premium_fee == 0) { $content['s_text'] = preg_replace('|{START_PREMIUM_FEE}(.*){END_PREMIUM_FEE}|', '', $content['s_text']); } $title = osc_mailBeauty($content['s_title'], $words); $body = osc_mailBeauty($content['s_text'], $words); $emailParams = array('subject' => $title, 'to' => $item['s_contact_email'], 'to_name' => $item['s_contact_name'], 'body' => $body, 'alt_body' => $body); osc_sendMail($emailParams); }
public static function processPayment() { if (Params::getParam('test') == true) { return PAYMENT_FAILED; } $data = payment_get_custom(Params::getParam('extra')); $transaction_hash = Params::getParam('transaction_hash'); $value_in_btc = Params::getParam('value') / 100000000; $my_bitcoin_address = osc_get_preference('blockchain_btc_address', 'payment'); if (Params::getParam('address') != $my_bitcoin_address) { return PAYMENT_FAILED; } $hosts = gethostbynamel('blockchain.info'); foreach ($hosts as $ip) { // Check payment came from one of blockchain.info's IP if ($_SERVER['REMOTE_ADDR'] == $ip) { $exists = ModelPayment::newInstance()->getPaymentByCode($transaction_hash, 'BLOCKCHAIN'); if (isset($exists['pk_i_id'])) { return PAYMENT_ALREADY_PAID; } if (is_numeric(Params::getParam('confirmations')) && Params::getParam('confirmations') >= 6 || Params::getParam('anonymous') == true) { $product_type = explode('x', $data['product']); // SAVE TRANSACTION LOG $payment_id = ModelPayment::newInstance()->saveLog($data['concept'], $transaction_hash, $value_in_btc, 'BTC', $data['email'], $data['user'], $data['itemid'], $product_type[0], 'BLOCKCHAIN'); //source if ($product_type[0] == '101') { ModelPayment::newInstance()->payPublishFee($product_type[2], $payment_id); } else { if ($product_type[0] == '201') { ModelPayment::newInstance()->payPremiumFee($product_type[2], $payment_id); } else { ModelPayment::newInstance()->addWallet($data['user'], $value_in_btc); } } return PAYMENT_COMPLETED; } else { // Maybe we could do something here (the payment was correct, but it didn't get enought confirmations yet) return PAYMENT_PENDING; } break; } } return $status = PAYMENT_FAILED; }
<?php $url = ''; $mp = ModelPayment::newInstance(); if (osc_is_web_user_logged_in()) { $data = payment_get_custom(Params::getParam('extra')); $product_type = explode('x', $data['product']); $item = Item::newInstance()->findByPrimaryKey($data['itemid']); $wallet = $mp->getWallet(osc_logged_user_id()); $category_fee = 0; if (osc_logged_user_id() == $item['fk_i_user_id']) { if ($product_type[0] == '101') { if (!$mp->publishFeeIsPaid($item['pk_i_id'])) { $category_fee = $mp->getPublishPrice($item['fk_i_category_id']); } } else { if ($product_type[0] == '201') { if (!$mp->premiumFeeIsPaid($item['pk_i_id'])) { $category_fee = $mp->getPremiumPrice($item['fk_i_category_id']); } } } } if ($category_fee > 0 && $wallet['formatted_amount'] > $category_fee) { $payment_id = $mp->saveLog(Params::getParam('desc'), 'wallet_' . date("YmdHis"), $category_fee, osc_get_preference("currency", "payment"), $data['email'], $data['user'], $data['itemid'], $product_type[0], 'WALLET'); //source $mp->addWallet(osc_logged_user_id(), -$category_fee); if ($product_type[0] == '101') { $mp->payPublishFee($data['itemid'], $payment_id); $url = osc_search_category_url(); } else {
<?php /* * return.php * * This page will handle the GetECDetails, and DoECPayment API Calls */ //set include define('ABS_PATH', dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/'); require_once ABS_PATH . 'oc-load.php'; $status = PAYMENT_FAILED; if (osc_get_preference('paypal_standard', 'payment') == 1) { $data = payment_get_custom(Params::getParam('custom')); $product_type = explode('x', Params::getParam('item_number')); $tx = Params::getParam('tx') == '' ? Params::getParam('tx') : Params::getParam('txn_id'); $payment = ModelPayment::newInstance()->getPayment($tx); if (isset($payment['pk_i_id'])) { osc_add_flash_ok_message(__('Payment processed correctly', 'payment')); if ($product_type[0] == 101) { $item = Item::newInstance()->findByPrimaryKey($product_type[2]); $category = Category::newInstance()->findByPrimaryKey($item['fk_i_category_id']); View::newInstance()->_exportVariableToView('category', $category); payment_js_redirect_to(osc_search_category_url()); } else { if ($product_type[0] == 201) { if (osc_is_web_user_logged_in()) { payment_js_redirect_to(osc_route_url('payment-user-menu')); } else { View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($product_type[2])); payment_js_redirect_to(osc_item_url()); }