From 69cf14e1a838ba306b06d3e24e7698bcf066c762 Mon Sep 17 00:00:00 2001 From: Aashish Date: Fri, 23 Aug 2024 12:12:48 +0700 Subject: [PATCH] Update examples --- examples/OmiseCharge.php | 10 +++++----- examples/OmiseSchedule.php | 31 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/examples/OmiseCharge.php b/examples/OmiseCharge.php index b507f9f..40f3654 100644 --- a/examples/OmiseCharge.php +++ b/examples/OmiseCharge.php @@ -31,7 +31,7 @@ ]); $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]); @@ -39,7 +39,7 @@ // 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"; diff --git a/examples/OmiseSchedule.php b/examples/OmiseSchedule.php index 4e2cd08..22214b8 100644 --- a/examples/OmiseSchedule.php +++ b/examples/OmiseSchedule.php @@ -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([ @@ -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([ @@ -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";