@@ -21,7 +21,7 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - protected $fillable = ['user_id','buyer_email','buyer_name','buyer_phone','currency','amount','unit_price', 'fees','longurl','payment_id', 'payment_request_id','purpose','shorturl','request_status','payment_status', 'affiliate_commission', 'instrument_type', 'billing_instrument', 'created_by']; |
|
| 24 | + protected $fillable = [ 'user_id', 'buyer_email', 'buyer_name', 'buyer_phone', 'currency', 'amount', 'unit_price', 'fees', 'longurl', 'payment_id', 'payment_request_id', 'purpose', 'shorturl', 'request_status', 'payment_status', 'affiliate_commission', 'instrument_type', 'billing_instrument', 'created_by' ]; |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - protected $fillable = ['user_id','refund_id','payment_id','status','type','body','refund_amount','total_amount','created_by']; |
|
| 24 | + protected $fillable = [ 'user_id', 'refund_id', 'payment_id', 'status', 'type', 'body', 'refund_amount', 'total_amount', 'created_by' ]; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * The "booting" method of the model. |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | protected $auth_token = null; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @param string $api_key |
|
| 20 | - * @param string $auth_token is available on the d |
|
| 21 | - * @param string $endpoint can be set if you are working on an alternative server. |
|
| 22 | - * @return array AuthToken object. |
|
| 23 | - */ |
|
| 19 | + * @param string $api_key |
|
| 20 | + * @param string $auth_token is available on the d |
|
| 21 | + * @param string $endpoint can be set if you are working on an alternative server. |
|
| 22 | + * @return array AuthToken object. |
|
| 23 | + */ |
|
| 24 | 24 | public function __construct($api_key, $auth_token=null, $endpoint=null) |
| 25 | 25 | { |
| 26 | 26 | $this->api_key = (string) $api_key; |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * @return array headers with Authentication tokens added |
|
| 42 | - */ |
|
| 41 | + * @return array headers with Authentication tokens added |
|
| 42 | + */ |
|
| 43 | 43 | private function build_curl_headers() |
| 44 | 44 | { |
| 45 | 45 | $headers = array("X-Api-key: $this->api_key"); |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * @param string $path |
|
| 59 | - * @return string adds the path to endpoint with. |
|
| 60 | - */ |
|
| 58 | + * @param string $path |
|
| 59 | + * @return string adds the path to endpoint with. |
|
| 60 | + */ |
|
| 61 | 61 | private function build_api_call_url($path) |
| 62 | 62 | { |
| 63 | 63 | if (strpos($path, '/?') === false and strpos($path, '?') === false) { |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @param string $method ('GET', 'POST', 'DELETE', 'PATCH') |
|
| 72 | - * @param string $path whichever API path you want to target. |
|
| 73 | - * @param array $data contains the POST data to be sent to the API. |
|
| 74 | - * @return array decoded json returned by API. |
|
| 75 | - */ |
|
| 71 | + * @param string $method ('GET', 'POST', 'DELETE', 'PATCH') |
|
| 72 | + * @param string $path whichever API path you want to target. |
|
| 73 | + * @param array $data contains the POST data to be sent to the API. |
|
| 74 | + * @return array decoded json returned by API. |
|
| 75 | + */ |
|
| 76 | 76 | private function api_call($method, $path, array $data=null) |
| 77 | 77 | { |
| 78 | 78 | $path = (string) $path; |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * @return string URL to upload file or cover image asynchronously |
|
| 136 | - */ |
|
| 135 | + * @return string URL to upload file or cover image asynchronously |
|
| 136 | + */ |
|
| 137 | 137 | public function getUploadUrl() |
| 138 | 138 | { |
| 139 | 139 | $result = $this->api_call('GET', 'links/get_file_upload_url', array()); |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | - * @param string $file_path |
|
| 145 | - * @return string JSON returned when the file upload is complete. |
|
| 146 | - */ |
|
| 144 | + * @param string $file_path |
|
| 145 | + * @return string JSON returned when the file upload is complete. |
|
| 146 | + */ |
|
| 147 | 147 | public function uploadFile($file_path) |
| 148 | 148 | { |
| 149 | 149 | $upload_url = $this->getUploadUrl(); |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * Uploads any file or cover image mentioned in $link and |
|
| 181 | - * updates it with the json required by the API. |
|
| 182 | - * @param array $link |
|
| 183 | - * @return array $link updated with uploaded file information if applicable. |
|
| 184 | - */ |
|
| 180 | + * Uploads any file or cover image mentioned in $link and |
|
| 181 | + * updates it with the json required by the API. |
|
| 182 | + * @param array $link |
|
| 183 | + * @return array $link updated with uploaded file information if applicable. |
|
| 184 | + */ |
|
| 185 | 185 | public function uploadMagic(array $link) |
| 186 | 186 | { |
| 187 | 187 | if(!empty($link['file_upload'])) { |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * Authenticate using username and password of a user. |
|
| 202 | - * Automatically updates the auth_token value. |
|
| 203 | - * @param array $args contains username=>USERNAME and password=PASSWORD |
|
| 204 | - * @return array AuthToken object. |
|
| 205 | - */ |
|
| 201 | + * Authenticate using username and password of a user. |
|
| 202 | + * Automatically updates the auth_token value. |
|
| 203 | + * @param array $args contains username=>USERNAME and password=PASSWORD |
|
| 204 | + * @return array AuthToken object. |
|
| 205 | + */ |
|
| 206 | 206 | public function auth(array $args) |
| 207 | 207 | { |
| 208 | 208 | $response = $this->api_call('POST', 'auth', $args); |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * @return array list of Link objects. |
|
| 215 | - */ |
|
| 214 | + * @return array list of Link objects. |
|
| 215 | + */ |
|
| 216 | 216 | public function linksList() |
| 217 | 217 | { |
| 218 | 218 | $response = $this->api_call('GET', 'links', array()); |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | - * @return array single Link object. |
|
| 224 | - */ |
|
| 223 | + * @return array single Link object. |
|
| 224 | + */ |
|
| 225 | 225 | public function linkDetail($slug) |
| 226 | 226 | { |
| 227 | 227 | $response = $this->api_call('GET', 'links/' . $slug, array()); |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @return array single Link object. |
|
| 233 | - */ |
|
| 232 | + * @return array single Link object. |
|
| 233 | + */ |
|
| 234 | 234 | public function linkCreate(array $link) |
| 235 | 235 | { |
| 236 | 236 | if(empty($link['currency'])){ |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * @return array single Link object. |
|
| 246 | - */ |
|
| 245 | + * @return array single Link object. |
|
| 246 | + */ |
|
| 247 | 247 | public function linkEdit($slug, array $link) |
| 248 | 248 | { |
| 249 | 249 | $link = $this->uploadMagic($link); |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @return array single Link object. |
|
| 256 | - */ |
|
| 255 | + * @return array single Link object. |
|
| 256 | + */ |
|
| 257 | 257 | public function linkDelete($slug) |
| 258 | 258 | { |
| 259 | 259 | $response = $this->api_call('DELETE', 'links/' . $slug, array()); |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * @return array list of Payment objects. |
|
| 265 | - */ |
|
| 264 | + * @return array list of Payment objects. |
|
| 265 | + */ |
|
| 266 | 266 | public function paymentsList($limit = null, $page = null) |
| 267 | 267 | { |
| 268 | 268 | $params = array(); |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * @param string payment_id as provided by paymentsList() or Instamojo's webhook or redirect functions. |
|
| 283 | - * @return array single Payment object. |
|
| 284 | - */ |
|
| 282 | + * @param string payment_id as provided by paymentsList() or Instamojo's webhook or redirect functions. |
|
| 283 | + * @return array single Payment object. |
|
| 284 | + */ |
|
| 285 | 285 | public function paymentDetail($payment_id) |
| 286 | 286 | { |
| 287 | 287 | $response = $this->api_call('GET', 'payments/' . $payment_id, array()); |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | ///// Request a Payment ///// |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | - * @param array single PaymentRequest object. |
|
| 296 | - * @return array single PaymentRequest object. |
|
| 297 | - */ |
|
| 295 | + * @param array single PaymentRequest object. |
|
| 296 | + * @return array single PaymentRequest object. |
|
| 297 | + */ |
|
| 298 | 298 | public function paymentRequestCreate(array $payment_request) |
| 299 | 299 | { |
| 300 | 300 | $response = $this->api_call('POST', 'payment-requests', $payment_request); |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * @param string id as provided by paymentRequestCreate, paymentRequestsList, webhook or redirect. |
|
| 306 | - * @return array single PaymentRequest object. |
|
| 307 | - */ |
|
| 305 | + * @param string id as provided by paymentRequestCreate, paymentRequestsList, webhook or redirect. |
|
| 306 | + * @return array single PaymentRequest object. |
|
| 307 | + */ |
|
| 308 | 308 | public function paymentRequestStatus($id) |
| 309 | 309 | { |
| 310 | 310 | $response = $this->api_call('GET', 'payment-requests/' . $id, array()); |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
| 315 | - * @param string id as provided by paymentRequestCreate, paymentRequestsList, webhook or redirect. |
|
| 316 | - * @param string payment_id as received with the redirection URL or webhook. |
|
| 317 | - * @return array single PaymentRequest object. |
|
| 318 | - */ |
|
| 315 | + * @param string id as provided by paymentRequestCreate, paymentRequestsList, webhook or redirect. |
|
| 316 | + * @param string payment_id as received with the redirection URL or webhook. |
|
| 317 | + * @return array single PaymentRequest object. |
|
| 318 | + */ |
|
| 319 | 319 | public function paymentRequestPaymentStatus($id, $payment_id) |
| 320 | 320 | { |
| 321 | 321 | $response = $this->api_call('GET', 'payment-requests/' . $id . '/' . $payment_id, array()); |
@@ -324,12 +324,12 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * @param array datetime_limits containing datetime data with keys 'max_created_at', 'min_created_at', |
|
| 328 | - * 'min_modified_at' and 'max_modified_at' in ISO 8601 format(optional). |
|
| 329 | - * @return array containing list of PaymentRequest objects. |
|
| 330 | - * For more information on the allowed date formats check the |
|
| 331 | - * docs: https://www.instamojo.com/developers/request-a-payment-api/#toc-filtering-payment-requests |
|
| 332 | - */ |
|
| 327 | + * @param array datetime_limits containing datetime data with keys 'max_created_at', 'min_created_at', |
|
| 328 | + * 'min_modified_at' and 'max_modified_at' in ISO 8601 format(optional). |
|
| 329 | + * @return array containing list of PaymentRequest objects. |
|
| 330 | + * For more information on the allowed date formats check the |
|
| 331 | + * docs: https://www.instamojo.com/developers/request-a-payment-api/#toc-filtering-payment-requests |
|
| 332 | + */ |
|
| 333 | 333 | public function paymentRequestsList($datetime_limits=null) |
| 334 | 334 | { |
| 335 | 335 | $endpoint = 'payment-requests'; |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | ///// Refunds ///// |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | - * @param array single Refund object. |
|
| 353 | - * @return array single Refund object. |
|
| 354 | - */ |
|
| 352 | + * @param array single Refund object. |
|
| 353 | + * @return array single Refund object. |
|
| 354 | + */ |
|
| 355 | 355 | public function refundCreate(array $refund) |
| 356 | 356 | { |
| 357 | 357 | $response = $this->api_call('POST', 'refunds', $refund); |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | - * @param string id as provided by refundCreate or refundsList. |
|
| 363 | - * @return array single Refund object. |
|
| 364 | - */ |
|
| 362 | + * @param string id as provided by refundCreate or refundsList. |
|
| 363 | + * @return array single Refund object. |
|
| 364 | + */ |
|
| 365 | 365 | public function refundDetail($id) |
| 366 | 366 | { |
| 367 | 367 | $response = $this->api_call('GET', 'refunds/' . $id, array()); |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | - * @return array containing list of Refund objects. |
|
| 373 | - */ |
|
| 372 | + * @return array containing list of Refund objects. |
|
| 373 | + */ |
|
| 374 | 374 | public function refundsList() |
| 375 | 375 | { |
| 376 | 376 | $response = $this->api_call('GET', 'refunds', array()); |
@@ -21,18 +21,18 @@ discard block |
||
| 21 | 21 | * @param string $endpoint can be set if you are working on an alternative server. |
| 22 | 22 | * @return array AuthToken object. |
| 23 | 23 | */ |
| 24 | - public function __construct($api_key, $auth_token=null, $endpoint=null) |
|
| 24 | + public function __construct($api_key, $auth_token = null, $endpoint = null) |
|
| 25 | 25 | { |
| 26 | 26 | $this->api_key = (string) $api_key; |
| 27 | 27 | $this->auth_token = (string) $auth_token; |
| 28 | - if(!is_null($endpoint)){ |
|
| 28 | + if (!is_null($endpoint)) { |
|
| 29 | 29 | $this->endpoint = (string) $endpoint; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function __destruct() |
| 34 | 34 | { |
| 35 | - if(!is_null($this->curl)) { |
|
| 35 | + if (!is_null($this->curl)) { |
|
| 36 | 36 | curl_close($this->curl); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | private function build_curl_headers() |
| 44 | 44 | { |
| 45 | 45 | $headers = array("X-Api-key: $this->api_key"); |
| 46 | - if($this->auth_token) { |
|
| 47 | - $headers[] = "X-Auth-Token: $this->auth_token"; |
|
| 46 | + if ($this->auth_token) { |
|
| 47 | + $headers[ ] = "X-Auth-Token: $this->auth_token"; |
|
| 48 | 48 | } |
| 49 | 49 | return $headers; |
| 50 | 50 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | private function build_api_call_url($path) |
| 62 | 62 | { |
| 63 | 63 | if (strpos($path, '/?') === false and strpos($path, '?') === false) { |
| 64 | - return $this->endpoint . $path . '/'; |
|
| 64 | + return $this->endpoint.$path.'/'; |
|
| 65 | 65 | } |
| 66 | - return $this->endpoint . $path; |
|
| 66 | + return $this->endpoint.$path; |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param array $data contains the POST data to be sent to the API. |
| 74 | 74 | * @return array decoded json returned by API. |
| 75 | 75 | */ |
| 76 | - private function api_call($method, $path, array $data=null) |
|
| 76 | + private function api_call($method, $path, array $data = null) |
|
| 77 | 77 | { |
| 78 | 78 | $path = (string) $path; |
| 79 | 79 | $method = (string) $method; |
@@ -82,28 +82,28 @@ discard block |
||
| 82 | 82 | $request_url = $this-> build_api_call_url($path); |
| 83 | 83 | |
| 84 | 84 | $options = array(); |
| 85 | - $options[CURLOPT_HTTPHEADER] = $headers; |
|
| 86 | - $options[CURLOPT_RETURNTRANSFER] = true; |
|
| 87 | - |
|
| 88 | - if($method == 'POST') { |
|
| 89 | - $options[CURLOPT_POST] = 1; |
|
| 90 | - $options[CURLOPT_POSTFIELDS] = http_build_query($data); |
|
| 91 | - } else if($method == 'DELETE') { |
|
| 92 | - $options[CURLOPT_CUSTOMREQUEST] = 'DELETE'; |
|
| 93 | - } else if($method == 'PATCH') { |
|
| 94 | - $options[CURLOPT_POST] = 1; |
|
| 95 | - $options[CURLOPT_POSTFIELDS] = http_build_query($data); |
|
| 96 | - $options[CURLOPT_CUSTOMREQUEST] = 'PATCH'; |
|
| 85 | + $options[ CURLOPT_HTTPHEADER ] = $headers; |
|
| 86 | + $options[ CURLOPT_RETURNTRANSFER ] = true; |
|
| 87 | + |
|
| 88 | + if ($method == 'POST') { |
|
| 89 | + $options[ CURLOPT_POST ] = 1; |
|
| 90 | + $options[ CURLOPT_POSTFIELDS ] = http_build_query($data); |
|
| 91 | + } else if ($method == 'DELETE') { |
|
| 92 | + $options[ CURLOPT_CUSTOMREQUEST ] = 'DELETE'; |
|
| 93 | + } else if ($method == 'PATCH') { |
|
| 94 | + $options[ CURLOPT_POST ] = 1; |
|
| 95 | + $options[ CURLOPT_POSTFIELDS ] = http_build_query($data); |
|
| 96 | + $options[ CURLOPT_CUSTOMREQUEST ] = 'PATCH'; |
|
| 97 | 97 | } else if ($method == 'GET' or $method == 'HEAD') { |
| 98 | 98 | if (!empty($data)) { |
| 99 | 99 | /* Update URL to container Query String of Paramaters */ |
| 100 | - $request_url .= '?' . http_build_query($data); |
|
| 100 | + $request_url .= '?'.http_build_query($data); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | // $options[CURLOPT_VERBOSE] = true; |
| 104 | - $options[CURLOPT_URL] = $request_url; |
|
| 105 | - $options[CURLOPT_SSL_VERIFYPEER] = true; |
|
| 106 | - $options[CURLOPT_CAINFO] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cacert.pem'; |
|
| 104 | + $options[ CURLOPT_URL ] = $request_url; |
|
| 105 | + $options[ CURLOPT_SSL_VERIFYPEER ] = true; |
|
| 106 | + $options[ CURLOPT_CAINFO ] = dirname(__FILE__).DIRECTORY_SEPARATOR.'cacert.pem'; |
|
| 107 | 107 | |
| 108 | 108 | $this->curl = curl_init(); |
| 109 | 109 | $setopt = curl_setopt_array($this->curl, $options); |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | $error_message = curl_error($this->curl); |
| 115 | 115 | $response_obj = json_decode($response, true); |
| 116 | 116 | |
| 117 | - if($error_number != 0){ |
|
| 118 | - if($error_number == 60){ |
|
| 119 | - throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message. " . |
|
| 120 | - "Please check http://stackoverflow.com/a/21114601/846892 for a fix." . PHP_EOL); |
|
| 117 | + if ($error_number != 0) { |
|
| 118 | + if ($error_number == 60) { |
|
| 119 | + throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message. ". |
|
| 120 | + "Please check http://stackoverflow.com/a/21114601/846892 for a fix.".PHP_EOL); |
|
| 121 | 121 | } |
| 122 | - else{ |
|
| 123 | - throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message." . PHP_EOL); |
|
| 122 | + else { |
|
| 123 | + throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message.".PHP_EOL); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if($response_obj['success'] == false) { |
|
| 128 | - $message = json_encode($response_obj['message']); |
|
| 129 | - throw new \Exception($message . PHP_EOL); |
|
| 127 | + if ($response_obj[ 'success' ] == false) { |
|
| 128 | + $message = json_encode($response_obj[ 'message' ]); |
|
| 129 | + throw new \Exception($message.PHP_EOL); |
|
| 130 | 130 | } |
| 131 | 131 | return $response_obj; |
| 132 | 132 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function getUploadUrl() |
| 138 | 138 | { |
| 139 | 139 | $result = $this->api_call('GET', 'links/get_file_upload_url', array()); |
| 140 | - return $result['upload_url']; |
|
| 140 | + return $result[ 'upload_url' ]; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | return curl_exec($ch); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function getCurlValue($file_path, $file_name, $content_type='') |
|
| 161 | + public function getCurlValue($file_path, $file_name, $content_type = '') |
|
| 162 | 162 | { |
| 163 | 163 | // http://stackoverflow.com/a/21048702/846892 |
| 164 | 164 | // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | // Use the old style if using an older version of PHP |
| 171 | 171 | $value = "@{$file_path};filename=$file_name"; |
| 172 | 172 | if ($content_type) { |
| 173 | - $value .= ';type=' . $content_type; |
|
| 173 | + $value .= ';type='.$content_type; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | return $value; |
@@ -184,15 +184,15 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function uploadMagic(array $link) |
| 186 | 186 | { |
| 187 | - if(!empty($link['file_upload'])) { |
|
| 188 | - $file_upload_json = $this->uploadFile($link['file_upload']); |
|
| 189 | - $link['file_upload_json'] = $file_upload_json; |
|
| 190 | - unset($link['file_upload']); |
|
| 187 | + if (!empty($link[ 'file_upload' ])) { |
|
| 188 | + $file_upload_json = $this->uploadFile($link[ 'file_upload' ]); |
|
| 189 | + $link[ 'file_upload_json' ] = $file_upload_json; |
|
| 190 | + unset($link[ 'file_upload' ]); |
|
| 191 | 191 | } |
| 192 | - if(!empty($link['cover_image'])) { |
|
| 193 | - $cover_image_json = $this->uploadFile($link['cover_image']); |
|
| 194 | - $link['cover_image_json'] = $cover_image_json; |
|
| 195 | - unset($link['cover_image']); |
|
| 192 | + if (!empty($link[ 'cover_image' ])) { |
|
| 193 | + $cover_image_json = $this->uploadFile($link[ 'cover_image' ]); |
|
| 194 | + $link[ 'cover_image_json' ] = $cover_image_json; |
|
| 195 | + unset($link[ 'cover_image' ]); |
|
| 196 | 196 | } |
| 197 | 197 | return $link; |
| 198 | 198 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | public function auth(array $args) |
| 207 | 207 | { |
| 208 | 208 | $response = $this->api_call('POST', 'auth', $args); |
| 209 | - $this->auth_token = $response['auth_token']['auth_token']; |
|
| 209 | + $this->auth_token = $response[ 'auth_token' ][ 'auth_token' ]; |
|
| 210 | 210 | return $this->auth_token; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | public function linksList() |
| 217 | 217 | { |
| 218 | 218 | $response = $this->api_call('GET', 'links', array()); |
| 219 | - return $response['links']; |
|
| 219 | + return $response[ 'links' ]; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public function linkDetail($slug) |
| 226 | 226 | { |
| 227 | - $response = $this->api_call('GET', 'links/' . $slug, array()); |
|
| 228 | - return $response['link']; |
|
| 227 | + $response = $this->api_call('GET', 'links/'.$slug, array()); |
|
| 228 | + return $response[ 'link' ]; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function linkCreate(array $link) |
| 235 | 235 | { |
| 236 | - if(empty($link['currency'])){ |
|
| 237 | - $link['currency'] = 'INR'; |
|
| 236 | + if (empty($link[ 'currency' ])) { |
|
| 237 | + $link[ 'currency' ] = 'INR'; |
|
| 238 | 238 | } |
| 239 | 239 | $link = $this->uploadMagic($link); |
| 240 | 240 | $response = $this->api_call('POST', 'links', $link); |
| 241 | - return $response['link']; |
|
| 241 | + return $response[ 'link' ]; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | public function linkEdit($slug, array $link) |
| 248 | 248 | { |
| 249 | 249 | $link = $this->uploadMagic($link); |
| 250 | - $response = $this->api_call('PATCH', 'links/' . $slug, $link); |
|
| 251 | - return $response['link']; |
|
| 250 | + $response = $this->api_call('PATCH', 'links/'.$slug, $link); |
|
| 251 | + return $response[ 'link' ]; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function linkDelete($slug) |
| 258 | 258 | { |
| 259 | - $response = $this->api_call('DELETE', 'links/' . $slug, array()); |
|
| 259 | + $response = $this->api_call('DELETE', 'links/'.$slug, array()); |
|
| 260 | 260 | return $response; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -267,15 +267,15 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | $params = array(); |
| 269 | 269 | if (!is_null($limit)) { |
| 270 | - $params['limit'] = $limit; |
|
| 270 | + $params[ 'limit' ] = $limit; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | if (!is_null($page)) { |
| 274 | - $params['page'] = $page; |
|
| 274 | + $params[ 'page' ] = $page; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | $response = $this->api_call('GET', 'payments', $params); |
| 278 | - return $response['payments']; |
|
| 278 | + return $response[ 'payments' ]; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function paymentDetail($payment_id) |
| 286 | 286 | { |
| 287 | - $response = $this->api_call('GET', 'payments/' . $payment_id, array()); |
|
| 288 | - return $response['payment']; |
|
| 287 | + $response = $this->api_call('GET', 'payments/'.$payment_id, array()); |
|
| 288 | + return $response[ 'payment' ]; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | public function paymentRequestCreate(array $payment_request) |
| 299 | 299 | { |
| 300 | 300 | $response = $this->api_call('POST', 'payment-requests', $payment_request); |
| 301 | - return $response['payment_request']; |
|
| 301 | + return $response[ 'payment_request' ]; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function paymentRequestStatus($id) |
| 309 | 309 | { |
| 310 | - $response = $this->api_call('GET', 'payment-requests/' . $id, array()); |
|
| 311 | - return $response['payment_request']; |
|
| 310 | + $response = $this->api_call('GET', 'payment-requests/'.$id, array()); |
|
| 311 | + return $response[ 'payment_request' ]; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function paymentRequestPaymentStatus($id, $payment_id) |
| 320 | 320 | { |
| 321 | - $response = $this->api_call('GET', 'payment-requests/' . $id . '/' . $payment_id, array()); |
|
| 322 | - return $response['payment_request']; |
|
| 321 | + $response = $this->api_call('GET', 'payment-requests/'.$id.'/'.$payment_id, array()); |
|
| 322 | + return $response[ 'payment_request' ]; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -330,19 +330,19 @@ discard block |
||
| 330 | 330 | * For more information on the allowed date formats check the |
| 331 | 331 | * docs: https://www.instamojo.com/developers/request-a-payment-api/#toc-filtering-payment-requests |
| 332 | 332 | */ |
| 333 | - public function paymentRequestsList($datetime_limits=null) |
|
| 333 | + public function paymentRequestsList($datetime_limits = null) |
|
| 334 | 334 | { |
| 335 | 335 | $endpoint = 'payment-requests'; |
| 336 | 336 | |
| 337 | - if(!empty($datetime_limits)){ |
|
| 337 | + if (!empty($datetime_limits)) { |
|
| 338 | 338 | $query_string = http_build_query($datetime_limits); |
| 339 | 339 | |
| 340 | - if(!empty($query_string)){ |
|
| 341 | - $endpoint .= '/?' . $query_string; |
|
| 340 | + if (!empty($query_string)) { |
|
| 341 | + $endpoint .= '/?'.$query_string; |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | $response = $this->api_call('GET', $endpoint, array()); |
| 345 | - return $response['payment_requests']; |
|
| 345 | + return $response[ 'payment_requests' ]; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | public function refundCreate(array $refund) |
| 356 | 356 | { |
| 357 | 357 | $response = $this->api_call('POST', 'refunds', $refund); |
| 358 | - return $response['refund']; |
|
| 358 | + return $response[ 'refund' ]; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | public function refundDetail($id) |
| 366 | 366 | { |
| 367 | - $response = $this->api_call('GET', 'refunds/' . $id, array()); |
|
| 368 | - return $response['refund']; |
|
| 367 | + $response = $this->api_call('GET', 'refunds/'.$id, array()); |
|
| 368 | + return $response[ 'refund' ]; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | public function refundsList() |
| 375 | 375 | { |
| 376 | 376 | $response = $this->api_call('GET', 'refunds', array()); |
| 377 | - return $response['refunds']; |
|
| 377 | + return $response[ 'refunds' ]; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | } |
@@ -118,8 +118,7 @@ |
||
| 118 | 118 | if($error_number == 60){ |
| 119 | 119 | throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message. " . |
| 120 | 120 | "Please check http://stackoverflow.com/a/21114601/846892 for a fix." . PHP_EOL); |
| 121 | - } |
|
| 122 | - else{ |
|
| 121 | + } else{ |
|
| 123 | 122 | throw new \Exception("Something went wrong. cURL raised an error with number: $error_number and message: $error_message." . PHP_EOL); |
| 124 | 123 | } |
| 125 | 124 | } |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | class InstamojoServiceProvider extends \Illuminate\Support\ServiceProvider |
| 4 | 4 | { |
| 5 | 5 | /** |
| 6 | - * Bootstrap services. |
|
| 7 | - * |
|
| 8 | - * @return void |
|
| 9 | - */ |
|
| 6 | + * Bootstrap services. |
|
| 7 | + * |
|
| 8 | + * @return void |
|
| 9 | + */ |
|
| 10 | 10 | public function boot() |
| 11 | 11 | { |
| 12 | 12 | $this->loadRoutesFrom(__DIR__.'/routes/web.php'); |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Register services. |
|
| 18 | - * |
|
| 19 | - * @return void |
|
| 20 | - */ |
|
| 17 | + * Register services. |
|
| 18 | + * |
|
| 19 | + * @return void |
|
| 20 | + */ |
|
| 21 | 21 | public function register() |
| 22 | 22 | { |
| 23 | 23 | // register our controller |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | class CreateInstamojoPaymentTable extends Migration |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | 16 | Schema::create('instamojo_payment', function (Blueprint $table) { |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Reverse the migrations. |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 44 | + * Reverse the migrations. |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | 48 | public function down() |
| 49 | 49 | { |
| 50 | 50 | Schema::dropIfExists('instamojo_payment'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('instamojo_payment', function (Blueprint $table) { |
|
| 16 | + Schema::create('instamojo_payment', function(Blueprint $table) { |
|
| 17 | 17 | $table->engine = 'InnoDB'; |
| 18 | 18 | $table->charset = 'utf8mb4'; |
| 19 | 19 | $table->collation = 'utf8mb4_unicode_ci'; |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | class CreateInstamojoRefundTable extends Migration |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | 16 | Schema::create('instamojo_refund', function (Blueprint $table) { |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Reverse the migrations. |
|
| 39 | - * |
|
| 40 | - * @return void |
|
| 41 | - */ |
|
| 38 | + * Reverse the migrations. |
|
| 39 | + * |
|
| 40 | + * @return void |
|
| 41 | + */ |
|
| 42 | 42 | public function down() |
| 43 | 43 | { |
| 44 | 44 | Schema::dropIfExists('instamojo_refund'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('instamojo_refund', function (Blueprint $table) { |
|
| 16 | + Schema::create('instamojo_refund', function(Blueprint $table) { |
|
| 17 | 17 | $table->engine = 'InnoDB'; |
| 18 | 18 | $table->charset = 'utf8mb4'; |
| 19 | 19 | $table->collation = 'utf8mb4_unicode_ci'; |