Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('BASEPATH'))
  4. exit('No direct script access allowed');
  5.  
  6.  
  7. class Paypalcode extends MX_Controller {
  8.  
  9.  
  10. public $uid = 0;
  11.  
  12. public $passkey = '';
  13.  
  14. public $url = '';
  15.  
  16.  
  17. function __construct()
  18. {
  19. parent::__construct();
  20.  
  21. $this->load->config('core/master');
  22. $this->load->config('core/system');
  23.  
  24. $this->uid = $this->config->item('user_id');
  25. $this->passkey = $this->config->item('passkey');
  26. $this->url = $this->config->item('api_url');
  27. }
  28.  
  29.  
  30. public function code_response_wsearch($code, $test = FALSE)
  31. {
  32. $test_code = ($test) ? 'yes' : 'no';
  33.  
  34. $data = array(
  35. 'code' => $code,
  36. 'findkey' => 'yes',
  37. 'test' => $test_code,
  38. 'id' => $this->uid
  39. );
  40.  
  41. $response = $this->_send($data, 'paypalcharger', 'validate');
  42.  
  43. $temp = explode(':', $response);
  44.  
  45. if(count($temp) == 3) {
  46.  
  47. $result = array (
  48. 'price' => $temp[0],
  49. 'currency' => $temp[1],
  50. 'answer' => $temp[2]
  51. );
  52. }
  53. else
  54. {
  55. $result = array (
  56. 'price' => 0,
  57. 'currency' => 0,
  58. 'answer' => $response
  59. );
  60. }
  61.  
  62. return $result;
  63. }
  64.  
  65.  
  66. private function _send($data, $request, $action)
  67. {
  68. $data['action'] = $action;
  69. $url = $this->url . $request . '.php?';
  70. $requrl = $url . http_build_query($data);
  71.  
  72.  
  73. if (ini_get('allow_url_fopen') == 1)
  74. {
  75. $response = file_get_contents($requrl, FALSE, NULL, 0);
  76. }
  77. else
  78. {
  79. $ch = curl_init();
  80. curl_setopt($ch, CURLOPT_URL, $requrl);
  81. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  82. curl_setopt($ch, CURLOPT_HEADER, 0);
  83. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  84. curl_setopt($ch, CURLOPT_USERAGENT, 'airtel.ci.class.v.1.1.0');
  85. $response = curl_exec ($ch);
  86. if (curl_error($ch) == '') {
  87. return($response);
  88. }
  89. else
  90. {
  91. return 'fatal_cant_request_remote_server';
  92. }
  93. }
  94.  
  95.  
  96. return $response;
  97. }
  98.  
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement