Ejemplo n.º 1
0
/**
 * Redirect to payment page after publishing an item
 *
 * @param integer $item
 */
function payment_publish($item)
{
    // Need to pay to publish ?
    if (osc_get_preference('pay_per_post', 'payment') == 1) {
        $category_fee = ModelPayment::newInstance()->getPublishPrice($item['fk_i_category_id']);
        payment_send_email($item, $category_fee);
        if ($category_fee > 0) {
            // Catch and re-set FlashMessages
            osc_resend_flash_messages();
            $mItems = new ItemActions(false);
            $mItems->disable($item['pk_i_id']);
            ModelPayment::newInstance()->createItem($item['pk_i_id'], 0);
            osc_redirect_to(osc_route_url('payment-publish', array('itemId' => $item['pk_i_id'])));
        } else {
            // PRICE IS ZERO
            ModelPayment::newInstance()->createItem($item['pk_i_id'], 1);
        }
    } else {
        // NO NEED TO PAY PUBLISH FEE
        payment_send_email($item, 0);
        if (osc_get_preference('allow_premium', 'payment') == 1) {
            $premium_fee = ModelPayment::newInstance()->getPremiumPrice($item['fk_i_category_id']);
            if ($premium_fee > 0) {
                osc_redirect_to(osc_route_url('payment-premium', array('itemId' => $item['pk_i_id'])));
            }
        }
    }
}
Ejemplo n.º 2
0
/**
 * Redirect to payment page after publishing an item
 *
 * @param integer $item
 */
function payment_publish($item)
{
    if (osc_get_preference('paypal_enabled', 'payment') == 1 && (osc_get_preference('paypal_standard', 'payment') == 1 && osc_get_preference('paypal_email', 'payment') != '' || payment_decrypt(osc_get_preference('paypal_api_username', 'payment')) != '' && payment_decrypt(osc_get_preference('paypal_api_password', 'payment')) != '' && payment_decrypt(osc_get_preference('paypal_api_signature', 'payment')) != '' && osc_get_preference('paypal_standard', 'payment') == 0) || osc_get_preference('blockchain_enabled', 'payment') == 1 && osc_get_preference('blockchain_btc_address', 'payment') != '' || osc_get_preference('braintree_enabled', 'payment') == 1 && osc_get_preference('braintree_merchant_id', 'payment') != '' && osc_get_preference('braintree_public_key', 'payment') != '' && osc_get_preference('braintree_private_key', 'payment') != '') {
        // Need to pay to publish ?
        if (osc_get_preference('pay_per_post', 'payment') == 1) {
            $category_fee = ModelPayment::newInstance()->getPublishPrice($item['fk_i_category_id']);
            payment_send_email($item, $category_fee);
            if ($category_fee > 0) {
                // Catch and re-set FlashMessages
                osc_resend_flash_messages();
                $mItems = new ItemActions(false);
                $mItems->disable($item['pk_i_id']);
                ModelPayment::newInstance()->createItem($item['pk_i_id'], 0);
                osc_redirect_to(osc_route_url('payment-publish', array('itemId' => $item['pk_i_id'])));
            } else {
                // PRICE IS ZERO
                ModelPayment::newInstance()->createItem($item['pk_i_id'], 1);
            }
        } else {
            // NO NEED TO PAY PUBLISH FEE
            payment_send_email($item, 0);
            if (osc_get_preference('allow_premium', 'payment') == 1) {
                $premium_fee = ModelPayment::newInstance()->getPremiumPrice($item['fk_i_category_id']);
                if ($premium_fee > 0) {
                    osc_redirect_to(osc_route_url('payment-premium', array('itemId' => $item['pk_i_id'])));
                }
            }
        }
    }
}