function payment_pro_publish($item, $do_edit = false)
{
    $item = Item::newInstance()->findByPrimaryKey($item['pk_i_id']);
    if (!$do_edit) {
        ModelPaymentPro::newInstance()->createItem($item['pk_i_id'], 0, null, null, $item['b_enabled']);
    }
    $checkout = false;
    $category_fee = 0;
    $premium_fee = 0;
    // Need to pay to publish ?
    if (osc_get_preference('pay_per_post', 'payment_pro') == 1) {
        $is_paid = false;
        if ($do_edit) {
            $is_paid = ModelPaymentPro::newInstance()->publishFeeIsPaid($item['pk_i_id']);
        }
        if (!$is_paid) {
            $category_fee = ModelPaymentPro::newInstance()->getPublishPrice($item['fk_i_category_id']);
            if ($category_fee > 0) {
                // Catch and re-set FlashMessages
                osc_resend_flash_messages();
                $mItems = new ItemActions(false);
                $mItems->disable($item['pk_i_id']);
                if ($item['b_enabled'] == 1) {
                    ModelPaymentPro::newInstance()->enableItem($item['pk_i_id']);
                    payment_pro_cart_add('PUB' . $item['fk_i_category_id'] . '-' . $item['pk_i_id'], sprintf(__('Publish fee for item %s', 'payment_pro'), $item['pk_i_id']), $category_fee, 1);
                    $checkout = true;
                }
            } else {
                // PRICE IS ZERO
                if (!$do_edit) {
                    ModelPaymentPro::newInstance()->payPostItem($item['pk_i_id']);
                    ModelPaymentPro::newInstance()->createItem($item['pk_i_id'], 1, null, null, $item['b_enabled']);
                }
            }
        }
    }
    if (osc_get_preference('allow_premium', 'payment_pro') == 1) {
        $premium_fee = ModelPaymentPro::newInstance()->getPremiumPrice($item['fk_i_category_id']);
        if ($premium_fee > 0) {
            if (Params::getParam('payment_pro_make_premium') == 1) {
                if ($item['b_enabled'] == 1) {
                    payment_pro_cart_add('PRM' . $item['fk_i_category_id'] . '-' . $item['pk_i_id'], sprintf(__('Premium fee for item %s', 'payment_pro'), $item['pk_i_id']), $premium_fee, 1);
                    $checkout = true;
                }
            }
        }
    }
    if ($checkout && !OC_ADMIN) {
        ModelPaymentPro::newInstance()->addQueue(date('Y-m-d H:i:s', time() + 1800), $item['pk_i_id'], $category_fee != 0, $premium_fee != 0);
        osc_redirect_to(osc_route_url('payment-pro-checkout', array('itemId' => $item['pk_i_id'])));
    }
}
Beispiel #2
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'])));
            }
        }
    }
}
Beispiel #3
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'])));
                }
            }
        }
    }
}