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. 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
<?php

$data = payment_get_custom(Params::getParam('extra'));
$product_type = explode('x', Params::getParam('item_number'));
osc_add_flash_info_message(__('We are processing your payment, if we did not finish in a few minutes, please contact us', 'payment'));
if ($product_type[0] == 301) {
    if (osc_is_web_user_logged_in()) {
        osc_redirect_to(osc_route_url('payment-user-pack'));
    } else {
        // THIS SHOULD NOT HAPPEN
        osc_redirect_to(osc_base_path());
    }
} else {
    if (osc_is_web_user_logged_in()) {
        osc_redirect_to(osc_route_url('payment-user-menu'));
    } else {
        View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($product_type[2]));
        osc_redirect_to(osc_item_url());
    }
}
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
        $testModeStatus = $info['ap_test'];
        $purchaseType = $info['ap_purchasetype'];
        $totalAmountReceived = $info['ap_totalamount'];
        $feeAmount = $info['ap_feeamount'];
        $netAmount = $info['ap_netamount'];
        $transactionReferenceNumber = $info['ap_referencenumber'];
        $currency = $info['ap_currency'];
        $transactionDate = $info['ap_transactiondate'];
        $transactionType = $info['ap_transactiontype'];
        $customerFirstName = $info['ap_custfirstname'];
        $customerLastName = $info['ap_custlastname'];
        $customerAddress = $info['ap_custaddress'];
        $customerCity = $info['ap_custcity'];
        $customerState = $info['ap_custstate'];
        $customerCountry = $info['ap_custcountry'];
        $customerZipCode = $info['ap_custzip'];
        $customerEmailAddress = $info['ap_custemailaddress'];
        $myItemName = $info['ap_itemname'];
        $myItemCode = $info['ap_itemcode'];
        $myItemDescription = $info['ap_description'];
        $myItemQuantity = $info['ap_quantity'];
        $myItemAmount = $info['ap_amount'];
        $additionalCharges = $info['ap_additionalcharges'];
        $shippingCharges = $info['ap_shippingcharges'];
        $taxAmount = $info['ap_taxamount'];
        $discountAmount = $info['ap_discountamount'];
        $data = payment_get_custom($info['apc_1'] . $info['apc_2'] . $info['apc_3'] . $info['apc_4'] . $info['apc_5'] . $info['apc_6']);
    }
} else {
    //something is wrong, no response is received from Payza
}
Esempio n. 7
0
 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;
 }