Advertisement
gempaq

Sync JeC To Filpal

Jan 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.15 KB | None | 0 0
  1. if (isset($this->session->data['order_id'])) {
  2.             $this->cart->clear();
  3.             $server_url = 'http://filpal-license.apphb.com/';
  4.             $token = "QMtjQamHO_v_jiO55dnWEnoWGeNPso4H2bXy6s8058ZAYnjr5We1EOsKLb7wwH9j7u1EX8w5a2K6tgnqy3Ju1_1gvm6OG58Kmv3XN_xwJwXWeMbZ5USm4BrEt71oCsT3ooFtUohxrZvja5NluplaZisXsyb7tWYU-AJjpeAksafySlUNsaTjmjXxr66FOv48cxeB3yyEXHQeGG4lzptxn9Y9ghzu5_3EiUYN37FroXBeZm2ooa5yfFojAOK3gFZH5dpedbB3uhGLzktBgi89AxxhFfjh8viIl7h9tg2hJ7hhi-DzXolisOuN3V8rGe2Fs4--KQUAQ2GnJCFYr6heF_eK2dOQGiGo8xqrznCBeiv4dOix7Wl6KGPqeOCwoFhn0rVetnfwADqoquuge4927OQbCmPZDjMbvWjVX8cLcejXlS3tsrUaUQBD9aqa7mYwR9ak6XNTdivVGVQtSIwkdquNOVZXPQCEbTbO0IcOY80fIs3EYt2ruUt4NdBnOK4Xxs011H1xRAJAiJKwtsMAog";
  5.             $this->load->model('account/activity');
  6.            
  7.             if ($this->customer->isLogged()) {
  8.  
  9.                 $address_id = $this->customer->getAddressId();
  10.                 $this->load->model('account/address');
  11.                 $address = $this->model_account_address->getAddress($address_id);
  12.                    
  13.                     $license_data = array(
  14.                     'FirstName'     => $this->customer->getFirstName(),
  15.                     'LastName' => $this->customer->getLastName(),
  16.                     'Age' => '',
  17.                     'Gender' => '',
  18.                     'Birthday' => '',
  19.                     'UserName' => $this->customer->getEmail(),
  20.                     'Password' => $this->customer->getPasswd(),
  21.                     'Salt'    => $this->customer->getSalt(),
  22.                     'Email' => $this->customer->getEmail(),
  23.                     'Telephone' => '',
  24.                     'Mobile' => $this->customer->getTelephone(),
  25.                     'Fax' => $this->customer->getFax(),
  26.                     'Address1' => $address['address_1'],
  27.                     'Address2' => $address['address_2'],
  28.                     'City' => $address['city'],
  29.                     'Postcode' => $address['postcode'],
  30.                     'State' => $address['zone'],
  31.                     'Country' => $address['country']
  32.                     );
  33.                    
  34.  
  35.                     /* PROCESS 1 */
  36.                     /* CALL CURL TO MAKE REGISTRATION TO LICENSE SERVER */
  37.                     $add_user = $this->model_account_activity->addLicence($license_data,$server_url.'api/user',$token);
  38.  
  39.                     /* RECIEVE CALLBACK/RETURN DATA (UserID) FROM LICENSE SERVER IN JSON
  40.                        NEW USER OR EXISTING USER NEED TO GET RETURN DATA (UserID) FROM LICENSE SERVER FOR SUBSCRIBE LICENSE IN PROCESS 2 */
  41.                     $user_info = json_decode($add_user, true);
  42.                    
  43.                     /* PROCESS 2*/
  44.                     /* SUBSCRIBE LICENSE */
  45.                     $orders = $this->model_account_activity->getOrderInfo($this->session->data['order_id']);
  46.                     foreach ($orders as $order){
  47.                         $product_id = $order['product_id'];
  48.  
  49.                         //$product_id is get from Product in JeC [Jumix eCommerce]
  50.                         if($product_id == '58'){
  51.                             $product_id_license = 1; //Monthly License
  52.                         }elseif($product_id == '59'){
  53.                             $product_id_license = 2; //Yearly License
  54.                         }elseif($product_id == '60'){
  55.                             $product_id_license = 3; //Perpetual
  56.                         }else{
  57.                         $product_id_license = 4; //Other product have same license
  58.                         }
  59.                        
  60.                        
  61.                         /* DATA FROM $user_info AND $product_id IN ARRAY */
  62.                         $license_order = array(
  63.                             'UserID' => $user_info['ID'],
  64.                             'ProductID' => $product_id_license,
  65.                         );
  66.                        
  67.                         /* CALL CURL TO ADD SUBSCRIBE LICENSE TO LICENSE SERVER */
  68.                         $this->model_account_activity->addLicence($license_order,$server_url.'api/subscription',$token);
  69.                     }
  70.  
  71.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement