Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Aug 23, 2024
1 parent 3634eca commit 69cf14e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
10 changes: 5 additions & 5 deletions examples/OmiseCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
]);

$chargeFetched = OmiseCharge::retrieve($chargeCreated->toArray()['id']);
echo print_r($chargeFetched, true);
// 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 print_r($chargeFetched, true);
echo sprintf('Refund ID (TH): %s', $chargeRefund->toArray()['id']) . '\n\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";
31 changes: 20 additions & 11 deletions examples/OmiseSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
'charge[description]' => 'Testing schedule',
], $pkeyTH, $skeyTH);

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

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

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

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

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

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

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

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

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

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


// Fetching charge scedules

$resultTH = OmiseSchedule::retrieve($chargeScheduleIdTH, $pkeyTH, $skeyTH);

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

$resultMY = OmiseSchedule::retrieve($chargeScheduleIdMY, $pkeyMY, $skeyMY);

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

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

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

0 comments on commit 69cf14e

Please sign in to comment.