Esempio n. 1
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'])));
                }
            }
        }
    }
}
Esempio n. 2
0
 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;
 }
 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;
     }
 }
Esempio n. 4
0
                        <div class="form-label"><?php 
_e('Paypal API password', 'payment');
?>
</div>
                        <div class="form-controls"><input type="text" class="xlarge" name="paypal_api_password" value="<?php 
echo payment_decrypt(osc_get_preference('paypal_api_password', 'payment'));
?>
" /></div>
                    </div>
                    <div class="form-row paypal hide">
                        <div class="form-label"><?php 
_e('Paypal API signature', 'payment');
?>
</div>
                        <div class="form-controls"><input type="text" class="xlarge" name="paypal_api_signature" value="<?php 
echo payment_decrypt(osc_get_preference('paypal_api_signature', 'payment'));
?>
" /></div>
                    </div>
                    <div class="form-row paypal hide">
                        <div class="form-label"><?php 
_e('Paypal email', 'payment');
?>
</div>
                        <div class="form-controls"><input type="text" class="xlarge" name="paypal_email" value="<?php 
echo osc_get_preference('paypal_email', 'payment');
?>
" /></div>
                    </div>
                    <div class="form-row paypal hide">
                        <div class="form-label"><?php 
Esempio n. 5
0
                        <div class="form-label"><?php 
_e('CoinJar merchant password (sandbox)', 'payment');
?>
</div>
                        <div class="form-controls"><input type="text" class="xlarge" name="coinjar_sb_merchant_password" value="<?php 
echo payment_decrypt(osc_get_preference('coinjar_sb_merchant_password', 'payment'));
?>
" /></div>
                    </div>
                    <div class="form-row coinjar hide">
                        <div class="form-label"><?php 
_e('CoinJar API key (sandbox)', 'payment');
?>
</div>
                        <div class="form-controls"><input type="text" class="xlarge" name="coinjar_sb_api_key" value="<?php 
echo payment_decrypt(osc_get_preference('coinjar_sb_api_key', 'payment'));
?>
" /></div>
                    </div>
                    <div class="form-row coinjar hide">
                        <div class="form-label"><?php 
_e('CoinJar merchant reference', 'payment');
?>
</div>
                        <div class="form-controls">
                            <input type="text" class="xlarge" name="coinjar_merchant_reference" value="<?php 
echo osc_get_preference('coinjar_merchant_reference', 'payment');
?>
" />
                            <span class="help-box"><?php 
_e('It you have several websites this field helps you identify from which one is the payment', 'payment');
Esempio n. 6
0
    public static function dgButton($amount = '0.00', $description = '', $itemnumber = '101', $extra_array = null)
    {
        $extra = payment_prepare_custom($extra_array);
        $r = rand(0, 1000);
        $extra .= 'random,' . $r;
        $APIUSERNAME = payment_decrypt(osc_get_preference('paypal_api_username', 'payment'));
        $APIPASSWORD = payment_decrypt(osc_get_preference('paypal_api_password', 'payment'));
        $APISIGNATURE = payment_decrypt(osc_get_preference('paypal_api_signature', 'payment'));
        if (osc_get_preference('paypal_sandbox', 'payment') == 1) {
            $ENDPOINT = 'https://api-3t.sandbox.paypal.com/nvp';
        } else {
            $ENDPOINT = 'https://api-3t.paypal.com/nvp';
        }
        $VERSION = '65.1';
        // must be >= 65.1
        $REDIRECTURL = 'https://www.paypal.com/incontext?token=';
        if (osc_get_preference('paypal_sandbox', 'payment') == 1) {
            $REDIRECTURL = "https://www.sandbox.paypal.com/incontext?token=";
        }
        //Build the Credential String:
        $cred_str = 'USER='******'&PWD=' . $APIPASSWORD . '&SIGNATURE=' . $APISIGNATURE . '&VERSION=' . $VERSION;
        //For Testing this is hardcoded. You would want to set these variable values dynamically
        $nvp_str = "&METHOD=SetExpressCheckout" . '&RETURNURL=' . osc_base_url() . 'oc-content/plugins/' . osc_plugin_folder(__FILE__) . 'return.php?extra=' . $extra . '&CANCELURL=' . osc_base_url() . 'oc-content/plugins/' . osc_plugin_folder(__FILE__) . 'cancel.php?extra=' . $extra . '&PAYMENTREQUEST_0_CURRENCYCODE=' . osc_get_preference('currency', 'payment') . '&PAYMENTREQUEST_0_AMT=' . $amount . '&PAYMENTREQUEST_0_ITEMAMT=' . $amount . '&PAYMENTREQUEST_0_TAXAMT=0' . '&PAYMENTREQUEST_0_DESC=' . $description . '&PAYMENTREQUEST_0_PAYMENTACTION=Sale' . '&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital' . '&L_PAYMENTREQUEST_0_NAME0=' . $description . '&L_PAYMENTREQUEST_0_NUMBER0=' . $itemnumber . '&L_PAYMENTREQUEST_0_QTY0=1' . '&L_PAYMENTREQUEST_0_TAXAMT0=0' . '&L_PAYMENTREQUEST_0_AMT0=' . $amount . '&L_PAYMENTREQUEST_0_DESC0=Download' . '&CUSTOM=' . $extra . '&useraction=commit';
        //combine the two strings and make the API Call
        $req_str = $cred_str . $nvp_str;
        $response = Paypal::httpPost($ENDPOINT, $req_str);
        //check Response
        if ($response['ACK'] == "Success" || $response['ACK'] == "SuccessWithWarning") {
            //setup redirect URL
            $redirect_url = $REDIRECTURL . urldecode($response['TOKEN']);
            ?>
                <a href="<?php 
            echo $redirect_url;
            ?>
" id='paypalBtn_<?php 
            echo $r;
            ?>
'>
                    <img src='<?php 
            echo payment_url();
            ?>
payments/paypal/paypal.gif' border='0' />
                </a>
                <script>
                    var dg_<?php 
            echo $r;
            ?>
 = new PAYPAL.apps.DGFlow({
                        trigger: "paypalBtn_<?php 
            echo $r;
            ?>
"
                    });
                </script><?php 
        } else {
            if ($response['ACK'] == 'Failure' || $response['ACK'] == 'FailureWithWarning') {
                $redirect_url = '';
                //SOMETHING FAILED
            }
        }
    }
Esempio n. 7
0
    }
} else {
    $data = payment_get_custom(Params::getParam('extra'));
    //set GET var's to local vars:
    $token = $_GET['token'];
    $payerid = $_GET['PayerID'];
    //set API Creds, Version, and endpoint:
    //**************************************************//
    // This is where you would set your API Credentials //
    // Please note this is not considered "SECURE" this //
    // is an example only. It is NOT Recommended to use //
    // this method in production........................//
    //**************************************************//
    $APIUSERNAME = payment_decrypt(osc_get_preference('paypal_api_username', 'payment'));
    $APIPASSWORD = payment_decrypt(osc_get_preference('paypal_api_password', 'payment'));
    $APISIGNATURE = payment_decrypt(osc_get_preference('paypal_api_signature', 'payment'));
    $ENDPOINT = 'https://api-3t.paypal.com/nvp';
    if (osc_get_preference('paypal_sandbox', 'payment') == 1) {
        $ENDPOINT = 'https://api-3t.sandbox.paypal.com/nvp';
    }
    $VERSION = '65.1';
    //must be >= 65.1
    //Build the Credential String:
    $cred_str = 'USER='******'&PWD=' . $APIPASSWORD . '&SIGNATURE=' . $APISIGNATURE . '&VERSION=' . $VERSION;
    //Build NVP String for GetExpressCheckoutDetails
    $nvp_str = '&METHOD=GetExpressCheckoutDetails&TOKEN=' . urldecode($token);
    //combine the two strings and make the API Call
    $req_str = $cred_str . $nvp_str;
    $response = Paypal::httpPost($ENDPOINT, $req_str);
    //based on the API Response from GetExpressCheckoutDetails
    $doec_str = $cred_str . '&METHOD=DoExpressCheckoutPayment' . '&TOKEN=' . $token . '&PAYERID=' . $payerid . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urldecode($response['PAYMENTREQUEST_0_CURRENCYCODE']) . '&PAYMENTREQUEST_0_AMT=' . urldecode($response['PAYMENTREQUEST_0_AMT']) . '&PAYMENTREQUEST_0_ITEMAMT=' . urldecode($response['PAYMENTREQUEST_0_ITEMAMT']) . '&PAYMENTREQUEST_0_TAXAMT=' . urldecode($response['PAYMENTREQUEST_0_TAXAMT']) . '&PAYMENTREQUEST_0_DESC=' . urldecode($response['PAYMENTREQUEST_0_DESC']) . '&PAYMENTREQUEST_0_PAYMENTACTION=Sale' . '&L_PAYMENTREQUEST_0_ITEMCATEGORY0=' . urldecode($response['L_PAYMENTREQUEST_0_ITEMCATEGORY0']) . '&L_PAYMENTREQUEST_0_NAME0=' . urldecode($response['L_PAYMENTREQUEST_0_NAME0']) . '&L_PAYMENTREQUEST_0_NUMBER0=' . urldecode($response['L_PAYMENTREQUEST_0_NUMBER0']) . '&L_PAYMENTREQUEST_0_QTY0=' . urldecode($response['L_PAYMENTREQUEST_0_QTY0']) . '&L_PAYMENTREQUEST_0_TAXAMT0=' . urldecode($response['L_PAYMENTREQUEST_0_TAXAMT0']) . '&L_PAYMENTREQUEST_0_AMT0=' . urldecode($response['L_PAYMENTREQUEST_0_AMT0']) . '&L_PAYMENTREQUEST_0_DESC0=' . urldecode($response['L_PAYMENTREQUEST_0_DESC0']) . '&NOTIFYURL=';