Skip to content

Commit

Permalink
database and migration added
Browse files Browse the repository at this point in the history
  • Loading branch information
zfhassaan committed Aug 14, 2023
1 parent 55ac59c commit a50826a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Models/ProcessPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace zfhassaan\Payfast\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProcessPayment extends Model
{
use HasFactory;

protected $fillable = [
'token','orderNo','data_3ds_secureid','transaction_id','payload','requestData'
];
}
19 changes: 16 additions & 3 deletions src/PayFast.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\HttpFoundation\Response as ResponseAlias;
use zfhassaan\Payfast\Payment;
use zfhassaan\Payfast\helper\Utility;
use zfhassaan\Payfast\Models\ProcessPayment;
use Illuminate\Support\Facades\Validator;

/**
Expand Down Expand Up @@ -143,7 +144,18 @@ public function GetOTPScreen($data): JsonResponse
if($response->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]);
}


Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions src/Provider/PayFastServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');


}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('process_payments_table_in_payfast', function (Blueprint $table) {
$table->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');
}
};

0 comments on commit a50826a

Please sign in to comment.