@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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'], |