Skip to content

Commit

Permalink
Resolve issue raised by PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Aug 22, 2024
1 parent f8f3274 commit 1cc4db5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
16 changes: 10 additions & 6 deletions examples/OmiseCharge.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<?php
require_once '../vendor/autoload.php';
require_once "../lib/Omise.php";
require_once 'vendor/autoload.php';
require_once 'lib/Omise.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->load();
Expand All @@ -26,15 +26,19 @@
'amount' => 100000,
'currency' => 'thb',
'return_uri' => 'http://www.example.com',
"card" => $token->toArray()['id']
'card' => $token->toArray()['id']
]);

$chargeFetched = OmiseCharge::retrieve($chargeCreated->toArray()['id']);
echo print_r($chargeFetched, true);

// Capture the amount
$chargeFetched->capture(['capture_amount' => 100000 / 2]);

// Refund the amount
$chargeRefund = $chargeFetched->refunds()->create(['amount' => 100000]);

echo sprintf("New Charge ID (TH): %s", $chargeCreated->toArray()['id']) . "\n";
echo sprintf("Fetched Charge ID (TH): %s", $chargeFetched->toArray()['id']) . "\n";
echo sprintf('New Charge ID (TH): %s', $chargeCreated->toArray()['id']) . '\n';
echo sprintf('Fetched Charge ID (TH): %s', $chargeFetched->toArray()['id']) . '\n';
echo print_r($chargeFetched, true);
echo sprintf("Refund ID (TH): %s", $chargeRefund->toArray()['id']) . "\n\n";
echo sprintf('Refund ID (TH): %s', $chargeRefund->toArray()['id']) . '\n\n';
Empty file removed examples/OmiseRefund.php
Empty file.
14 changes: 7 additions & 7 deletions examples/OmiseSchedule.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<?php
require_once 'vendor/autoload.php';
require_once "lib/Omise.php";
require_once 'lib/Omise.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->load();
Expand Down Expand Up @@ -32,11 +32,11 @@
'charge[description]' => 'Testing schedule',
], $pkeyTH, $skeyTH);

echo sprintf("Created schedule ID (TH): %s", $createResultTH->toArray()['id']) . "\n";
echo sprintf('Created schedule ID (TH): %s', $createResultTH->toArray()['id']) . '\n';

$resultTH = OmiseSchedule::retrieve($createResultTH->toArray()['id'], $pkeyTH, $skeyTH);

echo sprintf("Fetched schedule ID (TH): %s", $resultTH->toArray()['id']) . "\n\n";
echo sprintf('Fetched schedule ID (TH): %s', $resultTH->toArray()['id']) . '\n\n';

// Create schedule under MY PSP
$createResultMY = OmiseSchedule::create([
Expand All @@ -49,11 +49,11 @@
'charge[description]' => 'Testing schedule',
], $pkeyMY, $skeyMY);

echo sprintf("Created schedule ID (MY): %s", $createResultMY->toArray()['id']) . "\n";
echo sprintf('Created schedule ID (MY): %s', $createResultMY->toArray()['id']) . '\n';

$resultMY = OmiseSchedule::retrieve($createResultMY->toArray()['id'], $pkeyMY, $skeyMY);

echo sprintf("Fetched schedule ID (MY): %s", $resultMY->toArray()['id']) . "\n\n";
echo sprintf('Fetched schedule ID (MY): %s', $resultMY->toArray()['id']) . '\n\n';

// Create schedule under SG PSP
$createResultSG = OmiseSchedule::create([
Expand All @@ -66,8 +66,8 @@
'charge[description]' => 'Testing schedule',
]);

echo sprintf("Created schedule ID (SG): %s", $createResultSG->toArray()['id']) . "\n";
echo sprintf('Created schedule ID (SG): %s', $createResultSG->toArray()['id']) . '\n';

$resultSG = OmiseSchedule::retrieve($createResultSG->toArray()['id']);

echo sprintf("Fetched schedule ID (SG): %s", $resultSG->toArray()['id']) . "\n\n";
echo sprintf('Fetched schedule ID (SG): %s', $resultSG->toArray()['id']) . '\n\n';
1 change: 1 addition & 0 deletions lib/omise/OmiseCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function ($backend) {
},
$this['payment_backends']
);

// return backends (filtered if requested)
return ($filters = func_get_args()) ? array_filter($backends, self::combineFilters(self::argsToVariadic($filters))) : $backends;
}
Expand Down
1 change: 1 addition & 0 deletions lib/omise/res/OmiseApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected static function getInstance($publickey = null, $secretkey = null)
$className = get_class($resource);
if (!isset(self::$instances[$className])) {
static::$instances[$className] = $resource;

return static::$instances[$className];
}

Expand Down

0 comments on commit 1cc4db5

Please sign in to comment.