diff --git a/src/Models/ProcessPayment.php b/src/Models/ProcessPayment.php new file mode 100644 index 0000000..04617e9 --- /dev/null +++ b/src/Models/ProcessPayment.php @@ -0,0 +1,15 @@ +code != 00) { return Utility::returnError(json_decode(Utility::PayfastErrorCodes($response->code)->getContent())->error_description,$response->code,Response::HTTP_BAD_REQUEST); } - return Utility::returnSuccess($response); + $options = [ + 'token' => json_decode(self::getAuthToken())->token, + 'data_3ds_secureid' => json_decode($response)->customer_validation->data_3ds_secureid, + 'transaction_id' => json_decode($response)->customer_validation->transaction_id, + 'payload' => json_encode(['customer_validate'=>json_decode($response)->customer_validation,'user_request'=>$data]), + 'requestData' => json_encode($data) + ]; + + $db = ProcessPayments::create($options); + Utility::LogData('Payfast','Database Storage Check', $db); + + return Utility::returnSuccess(['token'=>self::getAuthToken(),'customer_validate' => $response]); } @@ -234,15 +246,16 @@ public function RefundTransactionRequest($data) public function PayWithEasyPaisa($data){ + $data['order_date'] = Carbon::today()->toDateString(); - $data['bank_code'] = 13; // Change it according to your own Bank i.e. Easy Paisa / Jazz Cash / UPaisa + $data['bank_code'] = 13; return $this->ValidateWalletTransaction($data); } public function PayWithUPaisa($data) { $data['order_date'] = Carbon::today()->toDateString(); - $data['bank_code'] = 14; // Change it according to your own Bank i.e. Easy Paisa / Jazz Cash / UPaisa + $data['bank_code'] = 14; return $this->ValidateWalletTransaction($data); } diff --git a/src/Provider/PayFastServiceProvider.php b/src/Provider/PayFastServiceProvider.php index 2544754..59e739e 100644 --- a/src/Provider/PayFastServiceProvider.php +++ b/src/Provider/PayFastServiceProvider.php @@ -9,9 +9,17 @@ class PayFastServiceProvider extends \Illuminate\Support\ServiceProvider { public function boot() { if ($this->app->runningInConsole()) { +// Publishes Config file to the main config folder $this->publishes([ __DIR__.'/../../config/config.php' => config_path('payfast.php'), ], 'config'); + +// Publish Migrations to the database migration + $this->publishes([ + __DIR__.'/../database/2023_08_14_071018_create_process_payments_table_in_payfast.php' => database_path('migrations'), + ], 'payfast-migrations'); + + } } diff --git a/src/database/2023_08_14_071018_create_process_payments_table_in_payfast.php b/src/database/2023_08_14_071018_create_process_payments_table_in_payfast.php new file mode 100644 index 0000000..857b9fb --- /dev/null +++ b/src/database/2023_08_14_071018_create_process_payments_table_in_payfast.php @@ -0,0 +1,33 @@ +id(); + $table->string('token'); + $table->string('orderNo'); + $table->string('data_3ds_secureid'); + $table->string('transaction_id'); + $table->longText('payload'); + $table->longText('requestData'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('process_payments_table_in_payfast'); + } +};