Completed
Push — master ( 8bb85e...49a3ee )
by Harish
04:35
created
src/Mojo.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 		
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * To process the refund's
60 60
 	 */
61 61
 
62
-	public static function refund($payment_id,$type,$reason)
62
+	public static function refund($payment_id, $type, $reason)
63 63
 	{
64 64
 		$sub = config('laravelmojo.subdomain_for_endpoints');
65 65
 
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$payload = ['payment_id' => $payment_id,
69 69
 				    'type' => $type,
70
-				    'body' => $reason ];
70
+				    'body' => $reason];
71 71
 
72
-		$response = self::closeCurl($curl,$payload);
72
+		$response = self::closeCurl($curl, $payload);
73 73
 		$afterDecoding = json_decode($response);
74 74
 		$refund = $afterDecoding->refund;
75 75
 
76
-		$transaction = MojoPaymentDetails::where('payment_id',$payment_id)->first();
76
+		$transaction = MojoPaymentDetails::where('payment_id', $payment_id)->first();
77 77
 		$user_id = $transaction->user_id;
78 78
 
79
-		$refund_record = self::createRefundInDB($user_id,$refund,$payment_id);
79
+		$refund_record = self::createRefundInDB($user_id, $refund, $payment_id);
80 80
 			
81 81
 		return $refund_record;
82 82
 	}
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
 			throw new Exception('Please set the Instamojo API key in your env file');
88 88
 		}
89 89
 
90
-		elseif(!config('laravelmojo.token')) {
90
+		elseif (!config('laravelmojo.token')) {
91 91
 			throw new Exception('Please set the Instamojo token in your env file');
92 92
 		}
93 93
 
94
-		elseif(!config('laravelmojo.redirect_url_after_payment')) {
94
+		elseif (!config('laravelmojo.redirect_url_after_payment')) {
95 95
 			throw new Exception('Please set the redirect url in your env file');
96 96
 		}
97 97
 
98
-		elseif(!config('laravelmojo.subdomain_for_endpoints')) {
98
+		elseif (!config('laravelmojo.subdomain_for_endpoints')) {
99 99
 			throw new Exception('Please set the subdomain for Instamojo api endpoint in your env file');
100 100
 		}
101 101
 
102
-		elseif(!config('laravelmojo.webhook_url')) {
102
+		elseif (!config('laravelmojo.webhook_url')) {
103 103
 			throw new Exception('Please set the webhook url in your env file');
104 104
 		}
105 105
 
106
-		elseif(!config('laravelmojo.salt')) {
106
+		elseif (!config('laravelmojo.salt')) {
107 107
 			throw new Exception('Please set the instamojo salt in your env file');
108 108
 		}
109 109
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 			curl_setopt($ch, CURLOPT_HEADER, FALSE);
125 125
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
126 126
 			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
127
-			curl_setopt($ch, CURLOPT_HTTPHEADER,["X-Api-Key:{$api_key}",
127
+			curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-Api-Key:{$api_key}",
128 128
 			                                     "X-Auth-Token:{$api_token}"]);
129 129
 			return $ch;
130 130
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		}
135 135
 	}
136 136
 
137
-	private static function closeCurl($curl,$payload)
137
+	private static function closeCurl($curl, $payload)
138 138
 	{
139 139
 		curl_setopt($curl, CURLOPT_POST, true);
140 140
 		curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($payload));
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 	private static function createPaymentPayload(User $user, $amount, $purpose, $phone = null)
148 148
 	{
149
-		if(is_null($phone)) {
149
+		if (is_null($phone)) {
150 150
 			$phone = $user->phone;
151 151
 		}
152 152
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 					'webhook' => config('laravelmojo.webhook_url'),
160 160
 					'send_sms' => false,
161 161
 					'email' => $user->email,
162
-					'allow_repeated_payments' => false ];
162
+					'allow_repeated_payments' => false];
163 163
 
164 164
 		return $payload;
165 165
 	} 
166 166
 
167
-	private static function createRefundInDB($user_id,$refund,$payment_id)
167
+	private static function createRefundInDB($user_id, $refund, $payment_id)
168 168
 	{
169 169
 		$refund_record = MojoRefundDetails::create(['user_id' => $user_id,
170 170
 												   'refund_id' => $refund->id,
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	}
186 186
 	public static function allPaymentsFor(User $user)
187 187
 	{
188
-		return MojoPaymentDetails::where('user_id',$user->id)->get();
188
+		return MojoPaymentDetails::where('user_id', $user->id)->get();
189 189
 	}
190 190
 	public static function failedPayments()
191 191
 	{
192
-		return MojoPaymentDetails::where('payment_status','!=','credit')->get();
192
+		return MojoPaymentDetails::where('payment_status', '!=', 'credit')->get();
193 193
 	}
194 194
 	public static function successfulPayments()
195 195
 	{
196
-		return MojoPaymentDetails::where('payment_status','credit')->get();
196
+		return MojoPaymentDetails::where('payment_status', 'credit')->get();
197 197
 	}
198 198
 	public static function myAndMojosIncome()
199 199
 	{
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 	public static function allRefundsFor(User $user)
218 218
 	{
219
-		return MojoRefundDetails::where('user_id',$user->id)->get();
219
+		return MojoRefundDetails::where('user_id', $user->id)->get();
220 220
 	}
221 221
 
222 222
 }
Please login to merge, or discard this patch.
src/controllers/WebhookController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 		$ver = explode('.', phpversion());
19 19
 		$major = (int) $ver[0];
20 20
 		$minor = (int) $ver[1];
21
-		if($major >= 5 and $minor >= 4){
21
+		if ($major >= 5 and $minor >= 4) {
22 22
 		     ksort($data, SORT_STRING | SORT_FLAG_CASE);
23 23
 		}
24
-		else{
24
+		else {
25 25
 		     uksort($data, 'strcasecmp');
26 26
 		}
27 27
 		
28 28
 		$mac_calculated = hash_hmac("sha1", implode("|", $data), config('laravelmojo.salt'));
29
-		if($mac_provided == $mac_calculated){
30
-		    if($data['status'] == "Credit"){
29
+		if ($mac_provided == $mac_calculated) {
30
+		    if ($data['status'] == "Credit") {
31 31
 
32
-		    $user = User::where('email',$data['buyer'])->first();
32
+		    $user = User::where('email', $data['buyer'])->first();
33 33
 			$user_id = $user->id;
34 34
 	    	MojoPaymentDetails::create(['user_id' => $user_id,
35 35
 									   'buyer_email' => $data['buyer'],
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 									 ]);
49 49
 		    }
50 50
 
51
-		    else{
51
+		    else {
52 52
 		        
53
-		    	$user = User::where('email',$data['buyer'])->first();
53
+		    	$user = User::where('email', $data['buyer'])->first();
54 54
 				$user_id = $user->id;
55 55
 		    	MojoPaymentDetails::create(['user_id' => $user_id,
56 56
 										   'buyer_email' => $data['buyer'],
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		    }
72 72
 		}
73
-		else{
73
+		else {
74 74
 		    echo "MAC mismatch";
75 75
 		}
76 76
 	}
Please login to merge, or discard this patch.
src/MojoServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
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()
Please login to merge, or discard this patch.