1. Go to this page and download the library: Download sanmai/gmopg library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
\GMO\API\Defaults::setShopID($shopId);
\GMO\API\Defaults::setShopName($shopName);
\GMO\API\Defaults::setPassword($shopPassword);
// When using a test password, this constant is mandatory
//define('GMO_TRIAL_MODE', true);
define('GMO_TRIAL_MODE', true);
// A wrapper object that does everything for you.
$payment = new \GMO\ImmediatePayment();
// Unique ID for every payment; probably should be taken from an auto-increment field from the database.
$payment->paymentId = 123;
$payment->amount = 1000;
// This card number can be used for tests.
$payment->cardNumber = '4111111111111111';
// A date in the future.
$payment->cardYear = '2020';
$payment->cardMonth = '7';
$payment->cardCode = '123';
// Returns false on an error.
if (!$payment->execute()) {
$errors = $payment->getErrors();
foreach ($errors as $errorCode => $errorDescription) {
// Show an error code and a description to the customer? Your choice.
// Probably you want to log the error too.
}
return;
}
// Success!
$response = $payment->getResponse();
/** @var \GMO\API\Response\ExecTranResponse $response */
// You would probably want to save the response in the database for future reference.
// The response can be used to query details about a transaction, make refunds and so on.
$payment = new \GMO\ImmediatePayment();
$payment->paymentId = 123; // Unique ID for every payment; see above
$payment->amount = 1000;
// Card details are unnecessary in this case
$payment->token = $_POST['token'];
if (!$payment->execute()) {
// ... same as above
}
// ... same as above
$searchTrade = new \GMO\API\Call\SearchTrade();
$searchTrade->OrderID = $payment->getResponse()->OrderID;
// Copy credential from the original payment
$payment->setupOther($searchTrade);
$response = $searchTrade->dispatch();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.