コード例 #1
0
 public function postUpdateCard()
 {
     // Add Curl library
     require_once app_path() . "/libraries/Curl/Curl.php";
     // Get Product
     $product = Product::where('code', Input::get('code'))->first();
     // Get Expiry month and year
     $expiry = explode(' / ', Input::get('ccExpire'));
     // Put all values in session
     Session::flash('ccNum', Input::get('ccNum'));
     Session::flash('ccExpire', Input::get('ccExpire'));
     Session::flash('ccCVC', Input::get('ccCVC'));
     $data = array('email' => Input::get('email'), 'code' => Input::get('code'), 'number' => Input::get('ccNum'), 'exp_month' => !empty($expiry[0]) ? $expiry[0] : NULL, 'exp_year' => !empty($expiry[1]) ? $expiry[1] : NULL, 'cvc' => Input::get('ccCVC'));
     $data['key'] = DKHelpers::GenerateHash($data, $product->api_key);
     $url = url() . "/api/v1/update-card";
     // Post data to IPN
     $curl = new Curl();
     $response = $curl->simple_post($url, $data, array(CURLOPT_BUFFERSIZE => 10));
     $response = json_decode($response);
     if (empty($response->error)) {
         $success = "Your card (**** **** **** {$response->last4}) has been updated successfully.";
         return Redirect::back()->with('success', $success);
     } else {
         return Redirect::back()->with('error', $response->error);
     }
 }
コード例 #2
0
 public function getPayload()
 {
     $code = Input::get('code');
     $api_key = Input::get('api_key');
     $license_key = Input::get('license');
     $activate = Input::get('activate');
     $current_url = url("admin/licenses/payload?code={$code}&api_key={$api_key}&license={$license_key}");
     // Page Title
     $this->_data['page_title'] = "Licenses - Get Payload";
     $this->_data['license_key'] = $license_key;
     $this->_data['uses'] = LicensesUses::getAllUsage($license_key);
     // Include libraries
     require_once app_path() . "/libraries/Curl/Curl.php";
     $params = array("code" => $code, "license" => $license_key);
     $curl = new Curl();
     if ($activate) {
         $params['guid'] = time();
     }
     $params['key'] = DKHelpers::GenerateHash($params, $api_key);
     if ($activate) {
         $response = $curl->simple_post(url('api/v1/license-manager/activate'), $params, array(CURLOPT_BUFFERSIZE => 10));
         $response = json_decode($response);
         if (isset($response->success) and $response->success == 'false') {
             if (isset($response->overusage) and $response->overusage == 'true') {
                 Session::flash('alert_error', '<strong>Alert!</strong> License cannot be activated due to overusage.');
                 return Redirect::to($current_url);
             }
         } else {
             Session::flash('alert_message', '<strong>Done!</strong> License has been activated successfully.');
             return Redirect::to($current_url);
         }
     }
     // Get Payload
     $this->_data['payload'] = $curl->simple_post(url('api/v1/license-manager'), $params, array(CURLOPT_BUFFERSIZE => 10));
     $this->_data['activate_url'] = $current_url . '&activate=true';
     return View::make('admin.licenses.payload', $this->_data)->nest('header', 'admin.common.header', $this->_data)->nest('footer', 'admin.common.footer', $this->_data);
 }
コード例 #3
0
 /**
  * Complete refund and push notification
  */
 static function completeRefund($transaction)
 {
     // Update transaction
     $transaction->is_refunded = 1;
     $transaction->save();
     // Push to IPN
     $ipn_data = array("type" => "refund", "plan" => $transaction->plan->code, "email" => $transaction->purchase->buyer->email);
     // Add Curl library
     require_once app_path() . "/libraries/Curl/Curl.php";
     // Add an encrypted key to the request
     $ipn_data['key'] = DKHelpers::GenerateHash($ipn_data, $transaction->purchase->product->api_key);
     // Post data to IPN
     $curl = new Curl();
     $curl->simple_post($transaction->purchase->product->ipn_url, $ipn_data, array(CURLOPT_BUFFERSIZE => 10));
     // Send refund email to buyer
     self::send_email_refund($transaction->purchase->product->name, $transaction->plan->name, $transaction->purchase->buyer->email, $transaction->pay_id, $transaction->amount);
     return TRUE;
 }
コード例 #4
0
 /**
  * Generate Hash for a request
  */
 private function _generateHash($params, $secret_key)
 {
     return DKHelpers::GenerateHash($params, $secret_key);
 }