@@ -17,24 +17,24 @@ discard block |
||
| 17 | 17 | $major = (int) $ver[0]; |
| 18 | 18 | $minor = (int) $ver[1]; |
| 19 | 19 | if($major >= 5 && $minor >= 4){ |
| 20 | - ksort($data, SORT_STRING | SORT_FLAG_CASE); |
|
| 20 | + ksort($data, SORT_STRING | SORT_FLAG_CASE); |
|
| 21 | 21 | } |
| 22 | 22 | else{ |
| 23 | - uksort($data, 'strcasecmp'); |
|
| 23 | + uksort($data, 'strcasecmp'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $mac_calculated = hash_hmac("sha1", implode("|", $data), config('laravelmojo.salt')); |
| 27 | 27 | if($mac_provided == $mac_calculated){ |
| 28 | - if($data['status'] == "Credit") { |
|
| 29 | - $this->updateDB($data); |
|
| 30 | - } |
|
| 28 | + if($data['status'] == "Credit") { |
|
| 29 | + $this->updateDB($data); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - else { |
|
| 33 | - $this->updateDB($data); |
|
| 34 | - } |
|
| 32 | + else { |
|
| 33 | + $this->updateDB($data); |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | else{ |
| 37 | - echo "MAC mismatch"; |
|
| 37 | + echo "MAC mismatch"; |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $user = User::where('email',$data['buyer'])->first(); |
| 44 | 44 | $user_id = $user->id; |
| 45 | - MojoPaymentDetails::create(['user_id' => $user_id, |
|
| 45 | + MojoPaymentDetails::create(['user_id' => $user_id, |
|
| 46 | 46 | 'buyer_email' => $data['buyer'], |
| 47 | 47 | 'buyer_name' => $data['buyer_name'], |
| 48 | 48 | 'buyer_phone' => $data['buyer_phone'], |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | $ver = explode('.', phpversion()); |
| 17 | 17 | $major = (int) $ver[0]; |
| 18 | 18 | $minor = (int) $ver[1]; |
| 19 | - if($major >= 5 && $minor >= 4){ |
|
| 19 | + if ($major >= 5 && $minor >= 4) { |
|
| 20 | 20 | ksort($data, SORT_STRING | SORT_FLAG_CASE); |
| 21 | 21 | } |
| 22 | - else{ |
|
| 22 | + else { |
|
| 23 | 23 | uksort($data, 'strcasecmp'); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $mac_calculated = hash_hmac("sha1", implode("|", $data), config('laravelmojo.salt')); |
| 27 | - if($mac_provided == $mac_calculated){ |
|
| 28 | - if($data['status'] == "Credit") { |
|
| 27 | + if ($mac_provided == $mac_calculated) { |
|
| 28 | + if ($data['status'] == "Credit") { |
|
| 29 | 29 | $this->updateDB($data); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | $this->updateDB($data); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | - else{ |
|
| 36 | + else { |
|
| 37 | 37 | echo "MAC mismatch"; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function updateDB($data) |
| 42 | 42 | { |
| 43 | - $user = User::where('email',$data['buyer'])->first(); |
|
| 43 | + $user = User::where('email', $data['buyer'])->first(); |
|
| 44 | 44 | $user_id = $user->id; |
| 45 | 45 | MojoPaymentDetails::create(['user_id' => $user_id, |
| 46 | 46 | 'buyer_email' => $data['buyer'], |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | $minor = (int) $ver[1]; |
| 19 | 19 | if($major >= 5 && $minor >= 4){ |
| 20 | 20 | ksort($data, SORT_STRING | SORT_FLAG_CASE); |
| 21 | - } |
|
| 22 | - else{ |
|
| 21 | + } else{ |
|
| 23 | 22 | uksort($data, 'strcasecmp'); |
| 24 | 23 | } |
| 25 | 24 | |
@@ -27,13 +26,10 @@ discard block |
||
| 27 | 26 | if($mac_provided == $mac_calculated){ |
| 28 | 27 | if($data['status'] == "Credit") { |
| 29 | 28 | $this->updateDB($data); |
| 30 | - } |
|
| 31 | - |
|
| 32 | - else { |
|
| 29 | + } else { |
|
| 33 | 30 | $this->updateDB($data); |
| 34 | 31 | } |
| 35 | - } |
|
| 36 | - else{ |
|
| 32 | + } else{ |
|
| 37 | 33 | echo "MAC mismatch"; |
| 38 | 34 | } |
| 39 | 35 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $payload = self::createPaymentPayload($user, $amount, $purpose, $phone); |
| 27 | 27 | |
| 28 | - $response = self::closeCurl($curl,$payload); |
|
| 28 | + $response = self::closeCurl($curl, $payload); |
|
| 29 | 29 | |
| 30 | 30 | $finalResponse = json_decode($response); |
| 31 | 31 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * To process the refund's |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | - public static function refund($payment_id,$type,$reason) |
|
| 61 | + public static function refund($payment_id, $type, $reason) |
|
| 62 | 62 | { |
| 63 | 63 | $sub = config('laravelmojo.subdomain_for_endpoints'); |
| 64 | 64 | |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $payload = ['payment_id' => $payment_id, |
| 68 | 68 | 'type' => $type, |
| 69 | - 'body' => $reason ]; |
|
| 69 | + 'body' => $reason]; |
|
| 70 | 70 | |
| 71 | - $response = self::closeCurl($curl,$payload); |
|
| 71 | + $response = self::closeCurl($curl, $payload); |
|
| 72 | 72 | $afterDecoding = json_decode($response); |
| 73 | 73 | $refund = $afterDecoding->refund; |
| 74 | 74 | |
| 75 | - $transaction = MojoPaymentDetails::where('payment_id',$payment_id)->first(); |
|
| 75 | + $transaction = MojoPaymentDetails::where('payment_id', $payment_id)->first(); |
|
| 76 | 76 | $user_id = $transaction->user_id; |
| 77 | 77 | |
| 78 | - $refund_record = self::createRefundInDB($user_id,$refund,$payment_id); |
|
| 78 | + $refund_record = self::createRefundInDB($user_id, $refund, $payment_id); |
|
| 79 | 79 | |
| 80 | 80 | return $refund_record; |
| 81 | 81 | } |
@@ -86,23 +86,23 @@ discard block |
||
| 86 | 86 | throw new Exception('Please set the Instamojo API key in your env file'); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - elseif(!config('laravelmojo.token')) { |
|
| 89 | + elseif (!config('laravelmojo.token')) { |
|
| 90 | 90 | throw new Exception('Please set the Instamojo token in your env file'); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - elseif(!config('laravelmojo.redirect_url_after_payment')) { |
|
| 93 | + elseif (!config('laravelmojo.redirect_url_after_payment')) { |
|
| 94 | 94 | throw new Exception('Please set the redirect url in your env file'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - elseif(!config('laravelmojo.subdomain_for_endpoints')) { |
|
| 97 | + elseif (!config('laravelmojo.subdomain_for_endpoints')) { |
|
| 98 | 98 | throw new Exception('Please set the subdomain for Instamojo api endpoint in your env file'); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - elseif(!config('laravelmojo.webhook_url')) { |
|
| 101 | + elseif (!config('laravelmojo.webhook_url')) { |
|
| 102 | 102 | throw new Exception('Please set the webhook url in your env file'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - elseif(!config('laravelmojo.salt')) { |
|
| 105 | + elseif (!config('laravelmojo.salt')) { |
|
| 106 | 106 | throw new Exception('Please set the instamojo salt in your env file'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | curl_setopt($ch, CURLOPT_HEADER, FALSE); |
| 124 | 124 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 125 | 125 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
| 126 | - curl_setopt($ch, CURLOPT_HTTPHEADER,["X-Api-Key:{$api_key}", |
|
| 126 | + curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-Api-Key:{$api_key}", |
|
| 127 | 127 | "X-Auth-Token:{$api_token}"]); |
| 128 | 128 | return $ch; |
| 129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - private static function closeCurl($curl,$payload) |
|
| 136 | + private static function closeCurl($curl, $payload) |
|
| 137 | 137 | { |
| 138 | 138 | curl_setopt($curl, CURLOPT_POST, true); |
| 139 | 139 | curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($payload)); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | private static function createPaymentPayload(User $user, $amount, $purpose, $phone = null) |
| 147 | 147 | { |
| 148 | - if(is_null($phone)) { |
|
| 148 | + if (is_null($phone)) { |
|
| 149 | 149 | $phone = $user->phone; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | 'webhook' => config('laravelmojo.webhook_url'), |
| 159 | 159 | 'send_sms' => false, |
| 160 | 160 | 'email' => $user->email, |
| 161 | - 'allow_repeated_payments' => false ]; |
|
| 161 | + 'allow_repeated_payments' => false]; |
|
| 162 | 162 | |
| 163 | 163 | return $payload; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - private static function createRefundInDB($user_id,stdClass $refund,$payment_id) |
|
| 166 | + private static function createRefundInDB($user_id, stdClass $refund, $payment_id) |
|
| 167 | 167 | { |
| 168 | 168 | $refund_record = MojoRefundDetails::create(['user_id' => $user_id, |
| 169 | 169 | 'refund_id' => $refund->id, |
@@ -184,15 +184,15 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | public static function allPaymentsFor(User $user) |
| 186 | 186 | { |
| 187 | - return MojoPaymentDetails::where('user_id',$user->id)->get(); |
|
| 187 | + return MojoPaymentDetails::where('user_id', $user->id)->get(); |
|
| 188 | 188 | } |
| 189 | 189 | public static function failedPayments() |
| 190 | 190 | { |
| 191 | - return MojoPaymentDetails::where('payment_status','!=','credit')->get(); |
|
| 191 | + return MojoPaymentDetails::where('payment_status', '!=', 'credit')->get(); |
|
| 192 | 192 | } |
| 193 | 193 | public static function successfulPayments() |
| 194 | 194 | { |
| 195 | - return MojoPaymentDetails::where('payment_status','credit')->get(); |
|
| 195 | + return MojoPaymentDetails::where('payment_status', 'credit')->get(); |
|
| 196 | 196 | } |
| 197 | 197 | public static function myAndMojosIncome() |
| 198 | 198 | { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | public static function allRefundsFor(User $user) |
| 217 | 217 | { |
| 218 | - return MojoRefundDetails::where('user_id',$user->id)->get(); |
|
| 218 | + return MojoRefundDetails::where('user_id', $user->id)->get(); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |