From 7deafac10ead6d0bb8c2748abd429b99f01c4c9d 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 | 37 +++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 19 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..704a502 100644 --- a/examples/OmiseSchedule.php +++ b/examples/OmiseSchedule.php @@ -11,15 +11,15 @@ define('OMISE_SECRET_KEY', $_ENV['SECRET_KEY_SG']); // test customer key -$customerSG = 'cust_xxxx'; +$customerSG = 'cust_test_60owl03ul8bzdk0h5ph'; $pkeyTH = $_ENV['PUBLIC_KEY_TH']; $skeyTH = $_ENV['SECRET_KEY_TH']; -$customerTH = 'cust_xxxx'; +$customerTH = 'cust_test_60ilwqkl9khiex66p4s'; $pkeyMY = $_ENV['PUBLIC_KEY_MY']; $skeyMY = $_ENV['SECRET_KEY_MY']; -$customerMY = 'cust_xxxx'; +$customerMY = 'cust_5u4m6n6tlhduy9savs8'; // Create schedule under TH PSP $createResultTH = OmiseSchedule::create([ @@ -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";