@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class MojoPaymentDetails extends Model |
8 | 8 | { |
9 | - protected $table = 'mojo_payment_details'; |
|
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,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 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class MojoRefundDetails extends Model |
8 | 8 | { |
9 | - protected $table = 'mojo_refund_details'; |
|
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 | } |
@@ -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 | } |
@@ -134,6 +134,9 @@ |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | + /** |
|
138 | + * @param resource $curl |
|
139 | + */ |
|
137 | 140 | private static function closeCurl($curl,$payload) |
138 | 141 | { |
139 | 142 | curl_setopt($curl, CURLOPT_POST, true); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | $payload = self::createPaymentPayload($user, $amount, $purpose, $phone); |
28 | 28 | |
29 | - $response = self::closeCurl($curl,$payload); |
|
29 | + $response = self::closeCurl($curl,$payload); |
|
30 | 30 | |
31 | 31 | $finalResponse = json_decode($response); |
32 | 32 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $curl = static::setupCURL("https://{$sub}.instamojo.com/api/1.1/refunds/"); |
67 | 67 | |
68 | 68 | $payload = ['payment_id' => $payment_id, |
69 | - 'type' => $type, |
|
70 | - 'body' => $reason ]; |
|
69 | + 'type' => $type, |
|
70 | + 'body' => $reason ]; |
|
71 | 71 | |
72 | 72 | $response = self::closeCurl($curl,$payload); |
73 | 73 | $afterDecoding = json_decode($response); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
126 | 126 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
127 | 127 | curl_setopt($ch, CURLOPT_HTTPHEADER,["X-Api-Key:{$api_key}", |
128 | - "X-Auth-Token:{$api_token}"]); |
|
128 | + "X-Auth-Token:{$api_token}"]); |
|
129 | 129 | return $ch; |
130 | 130 | |
131 | 131 | } |
@@ -85,29 +85,17 @@ discard block |
||
85 | 85 | { |
86 | 86 | if (!config('laravelmojo.key')) { |
87 | 87 | throw new Exception('Please set the Instamojo API key in your env file'); |
88 | - } |
|
89 | - |
|
90 | - elseif(!config('laravelmojo.token')) { |
|
88 | + } elseif(!config('laravelmojo.token')) { |
|
91 | 89 | throw new Exception('Please set the Instamojo token in your env file'); |
92 | - } |
|
93 | - |
|
94 | - elseif(!config('laravelmojo.redirect_url_after_payment')) { |
|
90 | + } elseif(!config('laravelmojo.redirect_url_after_payment')) { |
|
95 | 91 | throw new Exception('Please set the redirect url in your env file'); |
96 | - } |
|
97 | - |
|
98 | - elseif(!config('laravelmojo.subdomain_for_endpoints')) { |
|
92 | + } elseif(!config('laravelmojo.subdomain_for_endpoints')) { |
|
99 | 93 | throw new Exception('Please set the subdomain for Instamojo api endpoint in your env file'); |
100 | - } |
|
101 | - |
|
102 | - elseif(!config('laravelmojo.webhook_url')) { |
|
94 | + } elseif(!config('laravelmojo.webhook_url')) { |
|
103 | 95 | throw new Exception('Please set the webhook url in your env file'); |
104 | - } |
|
105 | - |
|
106 | - elseif(!config('laravelmojo.salt')) { |
|
96 | + } elseif(!config('laravelmojo.salt')) { |
|
107 | 97 | throw new Exception('Please set the instamojo salt in your env file'); |
108 | - } |
|
109 | - |
|
110 | - else { |
|
98 | + } else { |
|
111 | 99 | return true; |
112 | 100 | } |
113 | 101 | } |
@@ -128,8 +116,7 @@ discard block |
||
128 | 116 | "X-Auth-Token:{$api_token}"]); |
129 | 117 | return $ch; |
130 | 118 | |
131 | - } |
|
132 | - else { |
|
119 | + } else { |
|
133 | 120 | throw new Exception('CURL extension is not loaded'); |
134 | 121 | } |
135 | 122 | } |
@@ -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 | } |
@@ -8,35 +8,35 @@ |
||
8 | 8 | |
9 | 9 | class CreateMojoRefundDetailsTable extends Migration |
10 | 10 | { |
11 | - /** |
|
12 | - * Run the migrations. |
|
13 | - * |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function up() |
|
17 | - { |
|
18 | - Schema::create('mojo_refund_details', function (Blueprint $table) { |
|
19 | - $table->increments('id'); |
|
20 | - $table->integer('user_id')->unsigned(); |
|
21 | - $table->foreign('user_id')->references('id')->on('users'); |
|
22 | - $table->string('refund_id'); |
|
23 | - $table->string('payment_id'); |
|
24 | - $table->string('status'); |
|
25 | - $table->string('type'); |
|
26 | - $table->string('body'); |
|
27 | - $table->string('refund_amount'); |
|
28 | - $table->string('total_amount'); |
|
29 | - $table->timestamps(); |
|
30 | - }); |
|
31 | - } |
|
11 | + /** |
|
12 | + * Run the migrations. |
|
13 | + * |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function up() |
|
17 | + { |
|
18 | + Schema::create('mojo_refund_details', function (Blueprint $table) { |
|
19 | + $table->increments('id'); |
|
20 | + $table->integer('user_id')->unsigned(); |
|
21 | + $table->foreign('user_id')->references('id')->on('users'); |
|
22 | + $table->string('refund_id'); |
|
23 | + $table->string('payment_id'); |
|
24 | + $table->string('status'); |
|
25 | + $table->string('type'); |
|
26 | + $table->string('body'); |
|
27 | + $table->string('refund_amount'); |
|
28 | + $table->string('total_amount'); |
|
29 | + $table->timestamps(); |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Reverse the migrations. |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function down() |
|
39 | - { |
|
40 | - Schema::dropIfExists('mojo_refund_details'); |
|
41 | - } |
|
33 | + /** |
|
34 | + * Reverse the migrations. |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function down() |
|
39 | + { |
|
40 | + Schema::dropIfExists('mojo_refund_details'); |
|
41 | + } |
|
42 | 42 | } |
@@ -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'); |
@@ -8,41 +8,41 @@ |
||
8 | 8 | |
9 | 9 | class CreateMojoPaymentDetailsTable extends Migration |
10 | 10 | { |
11 | - /** |
|
12 | - * Run the migrations. |
|
13 | - * |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function up() |
|
17 | - { |
|
18 | - Schema::create('mojo_payment_details', function (Blueprint $table) { |
|
19 | - $table->increments('id'); |
|
20 | - $table->integer('user_id')->unsigned(); |
|
21 | - $table->foreign('user_id')->references('id')->on('users'); |
|
22 | - $table->string('buyer_email'); |
|
23 | - $table->string('buyer_name'); |
|
24 | - $table->string('buyer_phone'); |
|
25 | - $table->string('currency'); |
|
26 | - $table->string('amount'); |
|
27 | - $table->string('fees'); |
|
28 | - $table->string('longurl'); |
|
29 | - $table->string('payment_id'); |
|
30 | - $table->string('payment_request_id'); |
|
31 | - $table->string('purpose'); |
|
32 | - $table->string('shorturl')->nullable(); |
|
33 | - $table->string('request_status'); |
|
34 | - $table->string('payment_status'); |
|
35 | - $table->timestamps(); |
|
36 | - }); |
|
37 | - } |
|
11 | + /** |
|
12 | + * Run the migrations. |
|
13 | + * |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function up() |
|
17 | + { |
|
18 | + Schema::create('mojo_payment_details', function (Blueprint $table) { |
|
19 | + $table->increments('id'); |
|
20 | + $table->integer('user_id')->unsigned(); |
|
21 | + $table->foreign('user_id')->references('id')->on('users'); |
|
22 | + $table->string('buyer_email'); |
|
23 | + $table->string('buyer_name'); |
|
24 | + $table->string('buyer_phone'); |
|
25 | + $table->string('currency'); |
|
26 | + $table->string('amount'); |
|
27 | + $table->string('fees'); |
|
28 | + $table->string('longurl'); |
|
29 | + $table->string('payment_id'); |
|
30 | + $table->string('payment_request_id'); |
|
31 | + $table->string('purpose'); |
|
32 | + $table->string('shorturl')->nullable(); |
|
33 | + $table->string('request_status'); |
|
34 | + $table->string('payment_status'); |
|
35 | + $table->timestamps(); |
|
36 | + }); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Reverse the migrations. |
|
41 | - * |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function down() |
|
45 | - { |
|
46 | - Schema::dropIfExists('mojo_payment_details'); |
|
47 | - } |
|
39 | + /** |
|
40 | + * Reverse the migrations. |
|
41 | + * |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function down() |
|
45 | + { |
|
46 | + Schema::dropIfExists('mojo_payment_details'); |
|
47 | + } |
|
48 | 48 | } |
@@ -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'); |
@@ -8,14 +8,14 @@ |
||
8 | 8 | { |
9 | 9 | public function boot() |
10 | 10 | { |
11 | - $this->loadMigrationsFrom(__DIR__.'/../migrations'); |
|
11 | + $this->loadMigrationsFrom(__DIR__.'/../migrations'); |
|
12 | 12 | |
13 | - $this->publishes([ |
|
14 | - __DIR__.'/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
15 | - ]); |
|
13 | + $this->publishes([ |
|
14 | + __DIR__.'/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
15 | + ]); |
|
16 | 16 | } |
17 | - public function register() |
|
18 | - { |
|
17 | + public function register() |
|
18 | + { |
|
19 | 19 | |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -8,10 +8,10 @@ |
||
8 | 8 | { |
9 | 9 | public function boot() |
10 | 10 | { |
11 | - $this->loadMigrationsFrom(__DIR__.'/../migrations'); |
|
11 | + $this->loadMigrationsFrom(__DIR__ . '/../migrations'); |
|
12 | 12 | |
13 | 13 | $this->publishes([ |
14 | - __DIR__.'/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
14 | + __DIR__ . '/config/laravelmojo.php' => config_path('laravelmojo.php'), |
|
15 | 15 | ]); |
16 | 16 | } |
17 | 17 | public function register() |
@@ -2,24 +2,24 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | * Specify the Private AUTH KEY in your .env file provided |
7 | 7 | * by Instamojo in the API & Plugin's section |
8 | 8 | * of your account's integration page. |
9 | 9 | */ |
10 | 10 | |
11 | - 'key' => env('INSTAMOJO_KEY', null), |
|
11 | + 'key' => env('INSTAMOJO_KEY', null), |
|
12 | 12 | |
13 | - /* |
|
13 | + /* |
|
14 | 14 | * Specify your Private AUTH TOKEN in your .env file provided by Instamojo in the |
15 | 15 | * API & Plugins section of your integration page. |
16 | 16 | * Also I haven't watched a single episode of FRIENDS yet, please |
17 | 17 | * don't judge me for that. It's on my list. |
18 | 18 | */ |
19 | 19 | |
20 | - 'token' => env('INSTAMOJO_TOKEN', null), |
|
20 | + 'token' => env('INSTAMOJO_TOKEN', null), |
|
21 | 21 | |
22 | - /* |
|
22 | + /* |
|
23 | 23 | * The URL of your app to which the user will be redirected after the |
24 | 24 | * payment process at Instamojo's part will end. |
25 | 25 | * Tip : If you are testing on localhost , create a alias in your host |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * as your base URL. And add it to your routes. |
28 | 28 | */ |
29 | 29 | |
30 | - 'redirect_url_after_payment' => env('INSTAMOJO_REDIRECT_URL', null), |
|
30 | + 'redirect_url_after_payment' => env('INSTAMOJO_REDIRECT_URL', null), |
|
31 | 31 | |
32 | - /* |
|
32 | + /* |
|
33 | 33 | * These took me an hour to figure out , for testing purposers you will |
34 | 34 | * most probably use the instamojo sandbox testing account , if thats |
35 | 35 | * the case, then the subdomain for all your endpoints will be "test" |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | * then it will be "www" |
39 | 39 | */ |
40 | 40 | |
41 | - 'subdomain_for_endpoints' => env('INSTAMOJO_SUBDOMAIN', null), |
|
41 | + 'subdomain_for_endpoints' => env('INSTAMOJO_SUBDOMAIN', null), |
|
42 | 42 | |
43 | - /* |
|
43 | + /* |
|
44 | 44 | * WEBHOOK is your app's URL to which Instamojo sends |
45 | 45 | * payment details as a POST request. This package |
46 | 46 | * handles everything , you just have to define |
47 | 47 | * the POST route & add it your route's file |
48 | 48 | */ |
49 | 49 | |
50 | - 'webhook_url' => env('INSTAMOJO_WEBHOOK_URL', null), |
|
50 | + 'webhook_url' => env('INSTAMOJO_WEBHOOK_URL', null), |
|
51 | 51 | |
52 | - /* |
|
52 | + /* |
|
53 | 53 | * Specify the Private SALT in your .env file provided |
54 | 54 | * by Instamojo in the API & Plugin's section |
55 | 55 | * of your account's integration page. |
56 | 56 | */ |
57 | 57 | |
58 | - 'salt' => env('INSTAMOJO_SALT', null), |
|
58 | + 'salt' => env('INSTAMOJO_SALT', null), |
|
59 | 59 | |
60 | 60 | ]; |
@@ -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 | } |