Completed
Push — master ( 2f361f...005dad )
by Harish
02:47
created
src/Mojo.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.