示例#1
0
 function actionfree()
 {
     $id = addslashes($_POST['app_id']);
     $action = addslashes($_POST['action']);
     $app = new AppAccount();
     $app->getByID($id);
     $acc = new Account();
     $acc->getByID($app->app_client_id);
     $agent = new Account();
     if ($acc->admin_marketer != "") {
         $agent->getByUsername($acc->admin_marketer);
     }
     $dataemail = new DataEmail();
     $json['bool'] = 0;
     if ($action == "accept") {
         //status = 1 tetap
         $app->app_type = 0;
         //type = 0
         //contract start n end
         $app->app_contract_start = date("Y-m-d");
         $app->app_contract_end = date('Y-m-d', strtotime(date("Y-m-d", mktime()) . " + 365 day"));
         $app->app_paket_id = 1;
         //free
         $succ = $app->save();
         //spy masuk ke job queue
         //email ke marcel
         //komisi untuk agent nya...
         if ($succ) {
             //notify Admins kalau ada app active
             $dataemail->appBisaDibuat($app->app_name, $app->app_id, "Free App Accepted");
             //notify User
             $dataemail->freeAppAccepted($acc->admin_email, $acc->admin_username, $app->app_name);
             $vpt = new VpTransaction();
             $vpt->order_id = time();
             //hitung komisi
             //ini belum bener
             //TODO 31 maret 2016
             KomisiModel::log($app, $vpt);
             $json['bool'] = $succ;
         }
     }
     if ($action == "reject") {
         //status = 0
         $app->app_active = 0;
         //type = 0
         $app->app_type = 0;
         $app->app_paket_id = 0;
         $succ = $app->save();
         //email ke client & agent
         if ($succ) {
             $dataemail->freeRequestRejected($acc->admin_email, $acc->admin_username, $app->app_name);
             if ($acc->admin_marketer != "") {
                 $dataemail->freeRequestRejectedAgent($agent->admin_email, $acc->admin_username, $app->app_name, $agent->admin_username);
             }
             $json['bool'] = $succ;
         }
     }
     echo json_encode($json);
     die;
 }
 function addConfirm()
 {
     $err = array();
     $json['bool'] = 0;
     //       $json['err'] = array("apptitle"=>"harus diisi");
     $ttdate = addslashes($_POST['ttdate']);
     if ($ttdate == "") {
         $err['ttdate'] = "Date must be filled";
     }
     $ttname = addslashes($_POST['ttname']);
     if ($ttname == "") {
         $err['ttname'] = "Name must be filled";
     }
     $ttamount = addslashes($_POST['ttamount']);
     if ($ttamount == "") {
         $err['ttamount'] = "Amount must be filled";
     }
     $ttto = addslashes($_POST['ttto']);
     if ($ttto == "") {
         $err['ttto'] = "Bank Account must be filled";
     }
     if (count($err) > 0) {
         $json['bool'] = 0;
         $json['err'] = $err;
     } else {
         //save here
         $pc = new PaymentConfirm();
         $pc->confirm_app_id = addslashes($_POST['appid']);
         $pc->confirm_bank = $ttto;
         $pc->confirm_amount = $ttamount;
         $pc->confirm_create_date = leap_mysqldate();
         $pc->confirm_date = $ttdate;
         $pc->confirm_name = $ttname;
         $pc->confirm_receipt = addslashes($_POST['ttfile']);
         $pc->confirm_status = "not reviewed";
         $pc->confirm_user_id = Account::getMyID();
         $confirmID = $pc->save();
         if ($confirmID) {
             $app = new AppAccount();
             $app->getByID($pc->confirm_app_id);
             $app->app_active = 2;
             $app->load = 1;
             $app->app_pulsa = 1000;
             $app->save();
             $paket = new Paket();
             $paket->getByID($app->app_paket_id);
             //add pporder
             $ppo = new PaypalOrder();
             $ppo->payment_id = $confirmID;
             $ppo->payment_type = "banktt";
             $ppo->amount = $pc->confirm_amount;
             $ppo->currency = "IDR";
             $ppo->created_time = leap_mysqldate();
             $ppo->state = "pending";
             $ppo->user_id = Account::getMyID();
             $ppo->description = "Payment " . $app->app_name . " Paket " . $paket->paket_name . " ID : " . $app->app_id;
             $succ = $ppo->save();
             if ($succ) {
                 $json['bool'] = 1;
                 $json['order_id'] = $succ;
             } else {
                 $json['bool'] = 0;
                 $json['all'] = "Saving PPO Error";
             }
         } else {
             $json['bool'] = 0;
             $json['all'] = "Saving PConfirm Error";
         }
     }
     echo json_encode($json);
     die;
 }
 function saveIntoApp()
 {
     $app = new AppAccount();
     if (isset($_GET['id']) && $_GET['id'] > 0) {
         $id = addslashes($_GET['id']);
         $app->getByID($id);
         $app->load = 1;
         if ($app->app_client_id != Account::getMyID()) {
             die("Owner's ID Mismatch");
         }
     }
     $detail = ZAppFeature::loadDetails();
     $app->app_client_id = Account::getMyID();
     $app->app_name = $detail['app_name'];
     $app->app_create_date = leap_mysqldate();
     $app->app_api_access_key = Efiwebsetting::getData('GCM_ACCESS_KEY');
     $app->app_token = md5(leap_mysqldate());
     $app->app_icon = $detail['app_icon'];
     $app->app_shortdes = $detail['app_des_short'];
     $app->app_feat = $detail['app_feature_img'];
     $app->app_fulldes = $detail['app_des_long'];
     if (isset($_GET['id']) && $_GET['id'] > 0) {
         $app->save();
         $appID = $app->app_id;
     } else {
         $app->app_keywords = session_id();
         $app->app_active = 0;
         $appID = $app->save();
         if ($appID) {
             $app2acc = new App2Acc();
             $app2acc->ac_admin_id = Account::getMyID();
             $app2acc->ac_app_id = $appID;
             $appID2 = $app2acc->save();
         }
     }
     $json['id'] = $appID;
     echo json_encode($json);
     //        echo $appID;
     die;
 }
 function placeOrder()
 {
     //sementara semua credit card
     //$order = $_REQUEST['order'];
     //$order['payment_method'] == 'credit_card';
     $json['paystate'] = 0;
     //langkah pertama daftarkan cc
     $creditCardId = $this->daftarkanCC();
     $currency = 'USD';
     $amount = addslashes($_POST['appprice']);
     $descr = addslashes($_POST['appdescr']);
     $app_id = addslashes($_POST['appid']);
     if ($creditCardId != NULL) {
         try {
             $paypal = new PaypalWrap();
             $payment = $paypal->makePaymentUsingCC($creditCardId, $amount, $currency, $descr);
             //                pr($payment);
             $order = new PaypalOrder();
             $order->amount = $amount;
             $order->created_time = leap_mysqldate();
             $order->currency = $currency;
             $order->description = $descr;
             $order->user_id = Account::getMyID();
             $order->payment_id = $payment->getId();
             $order->state = $payment->getState();
             $orderId = $order->save();
             $state = $order->state;
             if ($state == "approved") {
                 $json['paystate'] = 1;
                 //update paket active
                 $app = new AppAccount();
                 $app->getByID($app_id);
                 $app->app_active = 1;
                 $app->app_contract_start = leap_mysqldate();
                 $app->app_pulsa = 1000;
                 $app->app_contract_end = date('Y-m-d', strtotime('+1 year'));
                 $app->load = 1;
                 $app->save();
             }
             $message = "Your order has been placed successfully. Your Order id is <b>{$orderId}</b>";
             $messageType = 1;
         } catch (\PayPal\Exception\PPConnectionException $ex) {
             $message = parseApiError($ex->getData());
             $messageType = 0;
         } catch (Exception $ex) {
             $message = $ex->getMessage();
             $messageType = 0;
         }
     } else {
         $messageType = 0;
         $message = "credit card ID registration error";
     }
     $json['bool'] = $messageType;
     $json['err'] = $message;
     echo json_encode($json);
     die;
     //        if($_SERVER['REQUEST_METHOD'] == 'POST') {
     //
     //            try {
     //                if($order['payment_method'] == 'credit_card') {
     //
     //                    // Make a payment using credit card.
     //                    $user = getUser(getSignedInUser());
     //                    $payment = makePaymentUsingCC($user['creditcard_id'], $order['amount'], 'USD', $order['description']);
     //                    $orderId = addOrder(getSignedInUser(), $payment->getId(), $payment->getState(),
     //                        $order['amount'], $order['description']);
     //                    $message = "Your order has been placed successfully. Your Order id is <b>$orderId</b>";
     //                    $messageType = "success";
     //
     //                } else if($order['payment_method'] == 'paypal') {
     //
     //                    $orderId = addOrder(getSignedInUser(), NULL, NULL, $order['amount'], $order['description']);
     //                    // Create the payment and redirect buyer to paypal for payment approval.
     //                    $baseUrl = getBaseUrl() . "/order_completion.php?orderId=$orderId";
     //                    $payment = makePaymentUsingPayPal($order['amount'], 'USD', $order['description'],
     //                        "$baseUrl&success=true", "$baseUrl&success=false");
     //                    updateOrder($orderId, $payment->getState(), $payment->getId());
     //                    header("Location: " . getLink($payment->getLinks(), "approval_url") );
     //                    exit;
     //                }
     //            } catch (\PayPal\Exception\PPConnectionException $ex) {
     //                $message = parseApiError($ex->getData());
     //                $messageType = "error";
     //            } catch (Exception $ex) {
     //                $message = $ex->getMessage();
     //                $messageType = "error";
     //            }
     //        }
 }
 function appReg()
 {
     $err = array();
     $json['bool'] = 0;
     //       $json['err'] = array("apptitle"=>"harus diisi");
     $apptitle = addslashes($_POST['apptitle']);
     if ($apptitle == "") {
         $err['apptitle'] = "App Title must be filled";
     }
     if (strlen($apptitle) > 30) {
         $err['apptitle'] = "Max 30 Chars";
     }
     $appshort = addslashes($_POST['appshort']);
     if ($appshort == "") {
         $err['appshort'] = "Short Description must be filled";
     }
     if (strlen($appshort) > 80) {
         $err['appshort'] = "Max 80 Chars";
     }
     $appfull = addslashes($_POST['appfull']);
     if ($appfull == "") {
         $err['appfull'] = "Full Description must be filled";
     }
     if (strlen($appfull) > 4000) {
         $err['appfull'] = "Max 4000 Chars";
     }
     $appkey = addslashes($_POST['appkey']);
     if ($appkey == "") {
         $err['appkey'] = "Keywords must be filled";
     }
     $appicon = addslashes($_POST['appicon']);
     if ($appicon == "") {
         $err['appicon'] = "Please insert Icon";
     }
     $appfeat = addslashes($_POST['appfeat']);
     if ($appfeat == "") {
         $err['appfeat'] = "Please insert Feature Graphics";
     }
     $apppaket = addslashes($_POST['apppaket']);
     if ($apppaket == "") {
         $err['apppaket'] = "Please select Package";
     }
     if (count($err) > 0) {
         $json['bool'] = 0;
         $json['err'] = $err;
     } else {
         //save here
         //add app
         $app = new AppAccount();
         $app->app_name = $apptitle;
         $app->app_shortdes = $appshort;
         $app->app_fulldes = $appfull;
         $app->app_icon = $appicon;
         $app->app_feat = $appfeat;
         $app->app_keywords = $appkey;
         $app->app_create_date = leap_mysqldate();
         $app->app_active = 0;
         $app->app_client_id = Account::getMyID();
         $app->app_token = md5($apptitle . time());
         $app->app_pulsa = 1000;
         $app->app_paket_id = $apppaket;
         $app_id = $app->save();
         if ($app_id) {
             //add app2acc
             $app2acc = new App2Acc();
             $app2acc->ac_admin_id = Account::getMyID();
             $app2acc->ac_app_id = $app_id;
             $succ = $app2acc->save();
             if ($succ) {
                 $json['bool'] = 1;
                 $json['app_id'] = $app_id;
             } else {
                 $json['bool'] = 0;
                 $json['all'] = "Saving Role Error";
             }
         } else {
             $json['bool'] = 0;
             $json['all'] = "Saving App Error";
         }
     }
     echo json_encode($json);
     die;
 }
示例#6
0
 function handling()
 {
     echo 1;
     if ($this->isProd) {
         Veritrans_Config::$isProduction = true;
     }
     echo 3;
     Veritrans_Config::$serverKey = $this->getKeyUsed();
     echo 4;
     $raw_notification = "";
     try {
         $notif = new Veritrans_Notification();
         $input_source = "php://input";
         $raw_notification = file_get_contents($input_source);
     } catch (Exception $e) {
         echo "<h2>" . $e->getMessage() . "</h2>";
     }
     echo "<h1>jahahaa</h1>";
     $transaction = $notif->transaction_status;
     $type = $notif->payment_type;
     $order_id = $notif->order_id;
     $fraud = $notif->fraud_status;
     $vpt = new VpTransaction();
     $vpt->getByID($order_id);
     //dataemail
     $dataemail = new DataEmail();
     if ($transaction == 'capture') {
         // For credit card transaction, we need to check whether transaction is challenge by FDS or not
         if ($type == 'credit_card') {
             if ($fraud == 'challenge') {
                 // TODO set payment status in merchant's database to 'Challenge by FDS'
                 // TODO merchant should decide whether this transaction is authorized or not in MAP
                 echo "Transaction order_id: " . $order_id . " is challenged by FDS";
                 $vpt->order_message = "Transaction order_id: " . $order_id . " is challenged by FDS";
                 $vpt->order_status = 3;
                 $vpt->save();
                 //notify User
                 $app = new AppAccount();
                 $app->getByID($vpt->order_app_id);
                 $acc = new Account();
                 $acc->getByID($app->app_client_id);
                 $dataemail->appPaymentMode($acc->admin_email, $acc->admin_username, $app->app_name, $fraud);
             } else {
                 // TODO set payment status in merchant's database to 'Success'
                 echo "Transaction order_id: " . $order_id . " successfully captured using " . $type;
                 $vpt->order_message = "Transaction order_id: " . $order_id . " successfully captured using " . $type;
                 $vpt->order_status = 2;
                 $vpt->save();
                 //notify User
                 //update active di app
                 $app = new AppAccount();
                 $app->getByID($vpt->order_app_id);
                 $app->app_contract_start = date("Y-m-d");
                 $app->app_contract_end = date('Y-m-d', strtotime(date("Y-m-d", mktime()) . " + 365 day"));
                 $app->app_active = 1;
                 $app->app_paket_id = $vpt->order_paket_id;
                 $app->save();
                 //notify Admins kalau ada app active
                 $dataemail->appBisaDibuat($app->app_name, $app->app_id, $transaction);
                 //notify User
                 $acc = new Account();
                 $acc->getByID($app->app_client_id);
                 $dataemail->appPaymentSuccess($acc->admin_email, $acc->admin_username, $app->app_name);
                 //hitung komisi
                 //ini belum bener
                 //TODO 31 maret 2016
                 KomisiModel::log($app, $vpt);
                 //email dapat komisi
             }
         }
     } else {
         if ($transaction == 'settlement') {
             // TODO set payment status in merchant's database to 'Settlement'
             echo "Transaction order_id: " . $order_id . " successfully transfered using " . $type;
             $oldstatus = $vpt->order_status;
             $vpt->order_message = "Transaction order_id: " . $order_id . " successfully transfered using " . $type;
             $vpt->order_status = 1;
             $vpt->save();
             if ($oldstatus != 2) {
                 //update active di app
                 $app = new AppAccount();
                 $app->getByID($vpt->order_app_id);
                 $app->app_contract_start = date("Y-m-d");
                 $app->app_contract_end = date('Y-m-d', strtotime(date("Y-m-d", mktime()) . " + 365 day"));
                 $app->app_active = 1;
                 $app->app_paket_id = $vpt->order_paket_id;
                 $app->save();
                 //notify Admins kalau ada app active
                 $dataemail->appBisaDibuat($app->app_name, $app->app_id, $transaction);
                 //notify User
                 $acc = new Account();
                 $acc->getByID($app->app_client_id);
                 $dataemail->appPaymentSettle($acc->admin_email, $acc->admin_username, $app->app_name);
                 //hitung komisi
                 //TODO 31 maret 2016
                 KomisiModel::log($app, $vpt);
                 //email dpt komisi
             }
         } else {
             if ($transaction == 'pending') {
                 // TODO set payment status in merchant's database to 'Pending'
                 echo "Waiting customer to finish transaction order_id: " . $order_id . " using " . $type;
                 $vpt->order_message = "Waiting customer to finish transaction order_id: " . $order_id . " using " . $type;
                 $vpt->order_status = 4;
                 $vpt->save();
                 //notify User
                 $app = new AppAccount();
                 $app->getByID($vpt->order_app_id);
                 $acc = new Account();
                 $acc->getByID($app->app_client_id);
                 $dataemail->appPaymentMode($acc->admin_email, $acc->admin_username, $app->app_name, $transaction);
             } else {
                 if ($transaction == 'deny') {
                     // TODO set payment status in merchant's database to 'Denied'
                     echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is denied.";
                     $vpt->order_message = "Payment using " . $type . " for transaction order_id: " . $order_id . " is denied.";
                     $vpt->order_status = 5;
                     $vpt->save();
                     //notify User
                     $app = new AppAccount();
                     $app->getByID($vpt->order_app_id);
                     $acc = new Account();
                     $acc->getByID($app->app_client_id);
                     $dataemail->appPaymentMode($acc->admin_email, $acc->admin_username, $app->app_name, "denied");
                 } else {
                     if ($transaction == 'cancel') {
                         // TODO set payment status in merchant's database to 'Denied'
                         echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is canceled.";
                         $vpt->order_message = "Payment using " . $type . " for transaction order_id: " . $order_id . " is canceled.";
                         $vpt->order_status = 6;
                         $vpt->save();
                         //notify User
                         $app = new AppAccount();
                         $app->getByID($vpt->order_app_id);
                         $acc = new Account();
                         $acc->getByID($app->app_client_id);
                         $dataemail->appPaymentMode($acc->admin_email, $acc->admin_username, $app->app_name, "canceled");
                     }
                 }
             }
         }
     }
     $vp = new VpData();
     $vp->vp_date = leap_mysqldate();
     $vp->vp_obj = serialize($notif) . " ||| " . $raw_notification;
     $vp->approval_code = $notif->approval_code;
     $vp->order_id = $notif->order_id;
     $vp->status_code = $notif->status_code;
     $vp->transaction_status = $notif->transaction_status;
     $vp->status_message = $notif->status_message;
     $vp->transaction_id = $notif->transaction_id;
     $vp->masked_card = $notif->masked_card;
     $vp->gross_amount = $notif->gross_amount;
     $vp->payment_type = $notif->payment_type;
     $vp->transaction_time = $notif->transaction_time;
     $vp->fraud_status = $notif->fraud_status;
     $vp->approval_code = $notif->approval_code;
     $vp->signature_key = $notif->signature_key;
     $vp->bank = $notif->bank;
     $vp->eci = $notif->eci;
     $vp->save();
     pr($notif);
     /*
              * Veritrans_Notification Object
     (
         [response:Veritrans_Notification:private] => stdClass Object
             (
                 [status_code] => 200
                 [status_message] => Success, transaction found
                 [transaction_id] => a293ec21-9572-4333-9a41-640a6789b713
                 [masked_card] => 518323-9790
                 [order_id] => 1084599542
                 [gross_amount] => 10000.00
                 [payment_type] => credit_card
                 [transaction_time] => 2016-02-17 15:20:37
                 [transaction_status] => capture
                 [fraud_status] => accept
                 [approval_code] => T08489
                 [signature_key] => 12a2c1d52cdd03326727b1ee0cc8a9f658146dbaedac46490f269183291885772e5a31a121c94ebde9f501733c8e7802cf74c3bb839ad687188456c3bf0d45e0
                 [bank] => bni
                 [eci] => 02
             )
     
     )
     */
     die;
 }
 function addpulsatrans()
 {
     $app_id = addslashes($_POST['app_id']);
     $jml = addslashes($_POST['jml']);
     if ($jml < 1) {
         die("jumlah nol");
     }
     if ($app_id == "" || $app_id < 1) {
         die("app id nol");
     }
     $app = new AppAccount();
     $app->getByID($app_id);
     $add = new AppPulsa();
     $add->pulsa_acc_id = Account::getMyID();
     $add->pulsa_action = 'credit';
     $add->pulsa_jumlah = $jml;
     $add->pulsa_app_id = $app_id;
     $add->pulsa_old = $app->app_pulsa;
     $add->pulsa_new = $app->app_pulsa + $jml;
     $add->pulsa_date = leap_mysqldate();
     $add->pulsa_camp_id = 0;
     $s1 = $add->save();
     if ($s1) {
         $app->app_pulsa = $add->pulsa_new;
         $app->load = 1;
         $s2 = $app->save();
         if ($s2) {
             die("Saved");
         } else {
             die("Error on adding pulsa to AppAcc");
         }
     } else {
         die("Error on adding pulsa to AppPulsa");
     }
 }