Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ php artisan vendor:publish --tag="fastpay"
FASTPAY_ENVIRONMENT=""
FASTPAY_STORE_ID=""
FASTPAY_STORE_PASSWORD=""
FASTPAY_REFUND_SECRET_KEY=""
```

**ملاحظة:** تأكد من ضبط المتغير "FASTPAY_ENVIRONMENT" في ملف ".env" إما على "staging" أو "production" بناءً على متطلباتك.
Expand Down
1 change: 1 addition & 0 deletions README.ku.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ php artisan vendor:publish --tag="fastpay"
FASTPAY_ENVIRONMENT=""
FASTPAY_STORE_ID=""
FASTPAY_STORE_PASSWORD=""
FASTPAY_REFUND_SECRET_KEY=""
```

**تێبینی:** دڵنیابە لە ڕێکخستنی گۆڕاوەی `FASTPAY_ENVIRONMENT` لە پەڕگەی `.env` ـەکەتدا بۆ "staging" یان "production" بە پشتبەستن بە پێداویستییەکانتان.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ After installing the package, make sure to add the following environment variabl
FASTPAY_ENVIRONMENT=""
FASTPAY_STORE_ID=""
FASTPAY_STORE_PASSWORD=""
FASTPAY_REFUND_SECRET_KEY=""
```

**Note:** Ensure to set the `FASTPAY_ENVIRONMENT` variable in your `.env` file to either "staging" or "production" based on your requirements.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"type": "library",
"license": "MIT",
"require": {
"php": "^8.1",
"illuminate/support": "^10.16"
"php": "^8.1|^8.2",
"laravel/framework": "^10.0|^11.0"
},
"authors": [
{
Expand Down
3 changes: 3 additions & 0 deletions config/fastpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/

'environment' => env('FASTPAY_ENVIRONMENT', 'staging'),
'staging_base_url' => env('FASTPAY_STAGING_BASE_URL', 'https://staging-apigw-merchant.fast-pay.iq'),
'production_base_url' => env('FASTPAY_PRODUCTION_BASE_URL', 'https://apigw-merchant.fast-pay.iq'),

/*
|--------------------------------------------------------------------------
Expand All @@ -24,4 +26,5 @@

"store_id" => env('FASTPAY_STORE_ID'),
"store_password" => env('FASTPAY_STORE_PASSWORD'),
"refund_secret_key" => env('FASTPAY_REFUND_SECRET_KEY'),
];
19 changes: 0 additions & 19 deletions database/migrations/create_fastpay_table.php.stub

This file was deleted.

46 changes: 26 additions & 20 deletions src/Fastpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

class Fastpay extends FastpayBaseClass
{
public static function initiate($orderId, $cart) : JsonResponse
public static function initiate($orderId, $cart): JsonResponse
{
try {
// validate incoming parameters
$validator = Validator::make(
[
'order_id' => $orderId,
Expand Down Expand Up @@ -53,7 +52,7 @@ public static function initiate($orderId, $cart) : JsonResponse
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/initiation', [
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $orderId,
"order_id" => $orderId,
"bill_amount" => $billAmount,
"currency" => "IQD",
"cart" => $cart,
Expand All @@ -73,11 +72,13 @@ public static function initiate($orderId, $cart) : JsonResponse
public static function validate($merchantOrderId): JsonResponse
{
try {
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/validate', [
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $merchantOrderId,
])->json();
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/validate',
[
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $merchantOrderId,
])
->json();

return response()->json($response);
} catch (\Throwable $th) {
Expand All @@ -88,13 +89,16 @@ public static function validate($merchantOrderId): JsonResponse
public static function refund(string $merchantOrderId, string $msisdn, float $amount): JsonResponse
{
try {
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/refund', [
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $merchantOrderId,
"msisdn" => $msisdn,
"amount" => $amount,
])->json();
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/refund',
[
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"refund_secret_key" => config("fastpay.refund_secret_key"),
"order_id" => $merchantOrderId,
"msisdn" => $msisdn,
"amount" => $amount,
])
->json();

return response()->json($response);
} catch (\Throwable $th) {
Expand All @@ -109,11 +113,13 @@ public static function refund(string $merchantOrderId, string $msisdn, float $am
public static function refundValidate(string $merchantOrderId): JsonResponse
{
try {
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/refund/validation', [
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $merchantOrderId,
])->json();
$response = Http::post(self::baseUrl() . '/api/v1/public/pgw/payment/refund/validation',
[
"store_id" => config("fastpay.store_id"),
"store_password" => config("fastpay.store_password"),
"order_id" => $merchantOrderId,
])
->json();

return response()->json($response);
} catch (\Throwable $th) {
Expand Down
8 changes: 5 additions & 3 deletions src/FastpayBaseClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

class FastpayBaseClass
{
protected static function baseUrl() :string
{
return config("fastpay.environment") == "production" ? "https://apigw-merchant.fast-pay.iq": "https://staging-apigw-merchant.fast-pay.iq";
protected static function baseUrl(): string
{
return config("fastpay.environment") == "production" ?
config('fastpay.production_base_url') ?? "https://apigw-merchant.fast-pay.iq" :
config('fastpay.staging_base_url') ?? "https://staging-apigw-merchant.fast-pay.iq";
}
}