<?php $data = payment_get_custom(Params::getParam('extra')); $url = osc_base_url(); if (isset($data['product']) && isset($data['itemid'])) { $product = explode('x', $data['product']); if ($product[0] == '301') { // PACK PAYMENT FROM USER'S DASHBOARD $url = osc_user_dashboard_url(); } else { $item = Item::newInstance()->findByPrimaryKey($data['itemid']); $category = Category::newInstance()->findByPrimaryKey($item['fk_i_category_id']); View::newInstance()->_exportVariableToView('category', $category); $url = osc_search_category_url(); } } else { } osc_add_flash_error_message(__('You cancel the payment process or there was an error. If the error continue, please contact the administrator', 'payment')); _e('You cancel the payment process or there was an error. If the error continue, please contact the administrator', 'payment'); payment_js_redirect_to($url);
public static function ajaxPayment() { $status = self::processPayment(); $data = payment_get_custom(Params::getParam('extra')); $product_type = explode('x', $data['product']); if ($status == PAYMENT_COMPLETED) { osc_add_flash_ok_message(sprintf(__('Success! Please write down this transaction ID in case you have any problem: %s', 'payment'), Params::getParam('stripe_transaction_id'))); 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()); } } else { if (osc_is_web_user_logged_in()) { payment_js_redirect_to(osc_route_url('payment-user-pack')); } else { // THIS SHOULD NOT HAPPEN payment_js_redirect_to(osc_base_path()); } } } } else { if ($status == PAYMENT_ALREADY_PAID) { osc_add_flash_warning_message(__('Warning! This payment was already paid', 'payment')); } else { osc_add_flash_error_message(_e('There were an error processing your payment', 'payment')); } if ($product_type[0] == 301) { if (osc_is_web_user_logged_in()) { payment_js_redirect_to(osc_route_url('payment-user-pack')); } else { // THIS SHOULD NOT HAPPEN payment_js_redirect_to(osc_base_path()); } } else { 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()); } } } }
} } 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 { if ($product_type[0] == '201') { $mp->payPremiumFee($data['itemid'], $payment_id); $url = osc_route_url('payment-user-menu'); } } } } if ($url != '') { osc_add_flash_ok_message(__('Payment processed correctly', 'payment')); payment_js_redirect_to($url); } else { osc_add_flash_error_message(__('There were some errors, please try again later or contact the administrators', 'payment')); payment_js_redirect_to(osc_route_url('payment-user-menu')); }