-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve issue of keys passed to method not being used (#172)
## Description Resolve issue of keys passed to method not being used Related issue: #161 ## Rollback procedure `default rollback procedure`
- Loading branch information
1 parent
498d04e
commit c5cb7da
Showing
10 changed files
with
165 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
php-version: | ||
- "7.1" | ||
- "7.2" | ||
- "7.3" | ||
- "7.4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
<?php | ||
require_once 'vendor/autoload.php'; | ||
require_once 'lib/Omise.php'; | ||
|
||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); | ||
$dotenv->load(); | ||
|
||
// setting default keys | ||
define('OMISE_PUBLIC_KEY', $_ENV['PUBLIC_KEY_TH']); | ||
define('OMISE_SECRET_KEY', $_ENV['SECRET_KEY_TH']); | ||
|
||
$token = OmiseToken::create([ | ||
'card' => [ | ||
'name' => 'Omise', | ||
'number' => '4242424242424242', | ||
'expiration_month' => 10, | ||
'expiration_year' => 2042, | ||
'city' => 'Bangkok', | ||
'postal_code' => '10320', | ||
'security_code' => 123 | ||
] | ||
]); | ||
|
||
$chargeCreated = OmiseCharge::create([ | ||
'amount' => 100000, | ||
'currency' => 'thb', | ||
'return_uri' => 'http://www.example.com', | ||
'card' => $token->toArray()['id'], | ||
'capture' => false | ||
]); | ||
|
||
$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 print_r($chargeFetched, true); | ||
echo sprintf('Refund ID (TH): %s', $chargeRefund->toArray()['id']) . "\n\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
<?php | ||
require_once 'vendor/autoload.php'; | ||
require_once 'lib/Omise.php'; | ||
|
||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); | ||
$dotenv->load(); | ||
|
||
// setting default keys | ||
define('OMISE_PUBLIC_KEY', $_ENV['PUBLIC_KEY_SG']); | ||
define('OMISE_SECRET_KEY', $_ENV['SECRET_KEY_SG']); | ||
|
||
// test customer key | ||
$customerSG = 'cust_xxxx'; | ||
|
||
$pkeyTH = $_ENV['PUBLIC_KEY_TH']; | ||
$skeyTH = $_ENV['SECRET_KEY_TH']; | ||
$customerTH = 'cust_xxxx'; | ||
|
||
$pkeyMY = $_ENV['PUBLIC_KEY_MY']; | ||
$skeyMY = $_ENV['SECRET_KEY_MY']; | ||
$customerMY = 'cust_xxxx'; | ||
|
||
// Create schedule under TH PSP | ||
$createResultTH = OmiseSchedule::create([ | ||
'every' => 15, | ||
'period' => 'day', | ||
'start_date' => '2025-01-01', | ||
'end_date' => '2025-03-31', | ||
'charge[customer]' => $customerTH, | ||
'charge[amount]' => 100000, | ||
'charge[description]' => 'Testing schedule', | ||
], $pkeyTH, $skeyTH); | ||
|
||
$chargeScheduleIdTH = $createResultTH->toArray()['id']; | ||
|
||
echo sprintf('Created schedule ID (TH): %s', $chargeScheduleIdTH) . "\n"; | ||
|
||
// Create schedule under MY PSP | ||
$createResultMY = OmiseSchedule::create([ | ||
'every' => 15, | ||
'period' => 'day', | ||
'start_date' => '2025-01-01', | ||
'end_date' => '2025-03-31', | ||
'charge[customer]' => $customerMY, | ||
'charge[amount]' => 100000, | ||
'charge[description]' => 'Testing schedule', | ||
], $pkeyMY, $skeyMY); | ||
|
||
$chargeScheduleIdMY = $createResultMY->toArray()['id']; | ||
|
||
echo sprintf('Created schedule ID (MY): %s', $createResultMY->toArray()['id']) . "\n\n"; | ||
|
||
// Create schedule under SG PSP | ||
$createResultSG = OmiseSchedule::create([ | ||
'every' => 15, | ||
'period' => 'day', | ||
'start_date' => '2025-01-01', | ||
'end_date' => '2025-03-31', | ||
'charge[customer]' => $customerSG, | ||
'charge[amount]' => 100000, | ||
'charge[description]' => 'Testing schedule', | ||
]); | ||
|
||
$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($chargeScheduleIdSG); | ||
|
||
echo sprintf('Fetched schedule ID (SG): %s', $resultSG->toArray()['id']) . "\n\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters