@@ -13,7 +13,7 @@ |
||
| 13 | 13 | ], 'migrations'); |
| 14 | 14 | |
| 15 | 15 | $this->publishes([ |
| 16 | - __DIR__.'/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
| 16 | + __DIR__ . '/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
| 17 | 17 | ], 'config'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class Mojo |
| 12 | 12 | { |
| 13 | - public static function go(User $user,$amount,$purpose) |
|
| 13 | + public static function go(User $user, $amount, $purpose) |
|
| 14 | 14 | { |
| 15 | 15 | DB::beginTransaction(); |
| 16 | 16 | |
| 17 | 17 | try |
| 18 | 18 | { |
| 19 | 19 | $sub = config('laravelmojo.subdomain_for_endpoints'); |
| 20 | - $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/payment-requests/",config('laravelmojo.key'),config('laravelmojo.token')); |
|
| 20 | + $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/payment-requests/", config('laravelmojo.key'), config('laravelmojo.token')); |
|
| 21 | 21 | |
| 22 | 22 | $details = ['purpose' => $purpose, |
| 23 | 23 | 'amount' => $amount, |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'webhook' => '', |
| 29 | 29 | 'send_sms' => false, |
| 30 | 30 | 'email' => $user->email, |
| 31 | - 'allow_repeated_payments' => false ]; |
|
| 31 | + 'allow_repeated_payments' => false]; |
|
| 32 | 32 | |
| 33 | 33 | curl_setopt($ch, CURLOPT_POST, true); |
| 34 | 34 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($details)); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | return $finalResponse->payment_request->longurl; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - catch(Exception $e) |
|
| 44 | + catch (Exception $e) |
|
| 45 | 45 | { |
| 46 | 46 | DB::rollback(); |
| 47 | 47 | return false; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $payment_id = filter_input(INPUT_GET, 'payment_id'); |
| 59 | 59 | $payment_request_id = filter_input(INPUT_GET, 'payment_request_id'); |
| 60 | 60 | $sub = config('laravelmojo.subdomain_for_endpoints'); |
| 61 | - $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/payment-requests/$payment_request_id/$payment_id/",config('laravelmojo.key'),config('laravelmojo.token')); |
|
| 61 | + $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/payment-requests/$payment_request_id/$payment_id/", config('laravelmojo.key'), config('laravelmojo.token')); |
|
| 62 | 62 | |
| 63 | 63 | $response = curl_exec($ch); |
| 64 | 64 | curl_close($ch); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | return $details; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - catch(Exception $e) |
|
| 75 | + catch (Exception $e) |
|
| 76 | 76 | { |
| 77 | 77 | DB::rollback(); |
| 78 | 78 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | try |
| 88 | 88 | { |
| 89 | - $user = User::where('email',$details->email)->first(); |
|
| 89 | + $user = User::where('email', $details->email)->first(); |
|
| 90 | 90 | $user_id = $user->id; |
| 91 | 91 | |
| 92 | 92 | MojoPaymentDetails::create(['user_id' => $user_id, |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | return true; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - catch(Exception $e) |
|
| 111 | + catch (Exception $e) |
|
| 112 | 112 | { |
| 113 | 113 | DB::rollback(); |
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public static function setupCURL($endPoint,$key,$token) |
|
| 118 | + public static function setupCURL($endPoint, $key, $token) |
|
| 119 | 119 | { |
| 120 | 120 | if (extension_loaded("curl")) |
| 121 | 121 | { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | curl_setopt($c_init, CURLOPT_HEADER, FALSE); |
| 127 | 127 | curl_setopt($c_init, CURLOPT_RETURNTRANSFER, TRUE); |
| 128 | 128 | curl_setopt($c_init, CURLOPT_FOLLOWLOCATION, TRUE); |
| 129 | - curl_setopt($c_init, CURLOPT_HTTPHEADER,[ |
|
| 129 | + curl_setopt($c_init, CURLOPT_HTTPHEADER, [ |
|
| 130 | 130 | "X-Api-Key: $key", |
| 131 | 131 | "X-Auth-Token: $token"] |
| 132 | 132 | ); |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | public static function allPaymentsFor(User $user) |
| 148 | 148 | { |
| 149 | - return MojoPaymentDetails::where('user_id',$user->id)->get(); |
|
| 149 | + return MojoPaymentDetails::where('user_id', $user->id)->get(); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public static function failedPayments() |
| 153 | 153 | { |
| 154 | - return MojoPaymentDetails::where('payment_status','!=','credit')->get(); |
|
| 154 | + return MojoPaymentDetails::where('payment_status', '!=', 'credit')->get(); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public static function successfulPayments() |
| 158 | 158 | { |
| 159 | - return MojoPaymentDetails::where('payment_status','credit')->get(); |
|
| 159 | + return MojoPaymentDetails::where('payment_status', 'credit')->get(); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function myAndMojosIncome() |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | return MojoPaymentDetails::sum('fees'); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public static function refund($payment_id,$type,$reason) |
|
| 179 | + public static function refund($payment_id, $type, $reason) |
|
| 180 | 180 | { |
| 181 | 181 | DB::beginTransaction(); |
| 182 | 182 | |
| 183 | 183 | try |
| 184 | 184 | { |
| 185 | 185 | $sub = config('laravelmojo.subdomain_for_endpoints'); |
| 186 | - $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/refunds/",config('laravelmojo.key'),config('laravelmojo.token')); |
|
| 186 | + $ch = static::setupCURL("https://$sub.instamojo.com/api/1.1/refunds/", config('laravelmojo.key'), config('laravelmojo.token')); |
|
| 187 | 187 | |
| 188 | 188 | $details = ['payment_id' => $payment_id, |
| 189 | 189 | 'type' => $type, |
| 190 | - 'body' => $reason ]; |
|
| 190 | + 'body' => $reason]; |
|
| 191 | 191 | |
| 192 | 192 | curl_setopt($ch, CURLOPT_POST, true); |
| 193 | 193 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($details)); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $finalResponse = json_decode($response); |
| 198 | 198 | $refund = $finalResponse->refund; |
| 199 | 199 | |
| 200 | - $inst = MojoPaymentDetails::where('payment_id',$payment_id)->first(); |
|
| 200 | + $inst = MojoPaymentDetails::where('payment_id', $payment_id)->first(); |
|
| 201 | 201 | $user_id = $inst->user_id; |
| 202 | 202 | |
| 203 | 203 | $refund_record = MojoRefundDetails::create(['user_id' => $user_id, |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | return $refund_record; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - catch(Exception $e) |
|
| 217 | + catch (Exception $e) |
|
| 218 | 218 | { |
| 219 | 219 | DB::rollback(); |
| 220 | 220 | return false; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | public static function allRefundsFor(User $user) |
| 230 | 230 | { |
| 231 | - return MojoRefundDetails::where('user_id',$user->id)->get(); |
|
| 231 | + return MojoRefundDetails::where('user_id', $user->id)->get(); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | protected $table = 'mojo_payment_details'; |
| 10 | 10 | |
| 11 | - protected $fillable = ['user_id','buyer_email','buyer_name','buyer_phone','currency','amount','fees','longurl','payment_id', |
|
| 12 | - 'payment_request_id','purpose','shorturl','request_status','payment_status',]; |
|
| 11 | + protected $fillable = ['user_id', 'buyer_email', 'buyer_name', 'buyer_phone', 'currency', 'amount', 'fees', 'longurl', 'payment_id', |
|
| 12 | + 'payment_request_id', 'purpose', 'shorturl', 'request_status', 'payment_status', ]; |
|
| 13 | 13 | } |
@@ -8,5 +8,5 @@ |
||
| 8 | 8 | { |
| 9 | 9 | protected $table = 'mojo_refund_details'; |
| 10 | 10 | |
| 11 | - protected $fillable = ['user_id','refund_id','payment_id','status','type','body','refund_amount','total_amount',]; |
|
| 11 | + protected $fillable = ['user_id', 'refund_id', 'payment_id', 'status', 'type', 'body', 'refund_amount', 'total_amount', ]; |
|
| 12 | 12 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function up() |
| 17 | 17 | { |
| 18 | - Schema::create('mojo_payment_details', function (Blueprint $table) { |
|
| 18 | + Schema::create('mojo_payment_details', function(Blueprint $table) { |
|
| 19 | 19 | $table->increments('id'); |
| 20 | 20 | $table->integer('user_id')->unsigned(); |
| 21 | 21 | $table->foreign('user_id')->references('id')->on('users'); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function up() |
| 17 | 17 | { |
| 18 | - Schema::create('mojo_refund_details', function (Blueprint $table) { |
|
| 18 | + Schema::create('mojo_refund_details', function(Blueprint $table) { |
|
| 19 | 19 | $table->increments('id'); |
| 20 | 20 | $table->integer('user_id')->unsigned(); |
| 21 | 21 | $table->foreign('user_id')->references('id')->on('users'); |