You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.1 KiB
PHP
124 lines
3.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Config for PayPal specific values
|
|
*/
|
|
|
|
// Urls
|
|
if (isset($_SERVER['SERVER_NAME'])) {
|
|
$url = @($_SERVER["HTTPS"] != 'on') ? 'http://' . $_SERVER["SERVER_NAME"] : 'https://' . $_SERVER["SERVER_NAME"];
|
|
$url .= ($_SERVER["SERVER_PORT"] !== 80) ? ":" . $_SERVER["SERVER_PORT"] : "";
|
|
$url .= $_SERVER["REQUEST_URI"];
|
|
} else {
|
|
$url = "";
|
|
}
|
|
|
|
define("URL", array(
|
|
|
|
"current" => $url,
|
|
|
|
"services" => array(
|
|
"orderCreate" => 'api/createOrder.php',
|
|
"orderGet" => 'api/getOrderDetails.php',
|
|
"orderPatch" => 'api/patchOrder.php',
|
|
"orderCapture" => 'api/captureOrder.php'
|
|
),
|
|
|
|
"redirectUrls" => array(
|
|
"returnUrl" => 'pages/success.php',
|
|
"cancelUrl" => 'pages/cancel.php',
|
|
)
|
|
));
|
|
|
|
// PayPal Environment
|
|
|
|
// PayPal REST API endpoints
|
|
define("PAYPAL_ENDPOINTS", array(
|
|
"sandbox" => "https://api.sandbox.paypal.com",
|
|
"production" => "https://api.paypal.com"
|
|
));
|
|
|
|
// PayPal REST App credentials
|
|
define("PAYPAL_CREDENTIALS", array(
|
|
"sandbox" => [
|
|
"client_id" => "AXvbGR8Rn8chRnZlvq76bfdvKMJtns3GClHMPfO2eBrBUpqw1x0lfGawBOmq2_frf7aCPHY05cRbm8hC",
|
|
"client_secret" => "EA03KQG90shENZ5NcXWjsGz1mPe8yDj7TSyNKRymW_UYWpuitUp-GaB4dn6uDJvEgkBO1lvalwN9rEww"
|
|
],
|
|
"production" => [
|
|
"client_id" => "AYnubAOOsssl7I0abnpC4940XkdSwf4h3Lvr7RxSizq_tzeyn2O_cpT5lPtIGMOIN9t9mpd1ygcmHDuY",
|
|
"client_secret" => "EHlickQCYw3xBCIFe180ICREME0J5TZ7NaYhFxiuCyI643DwLoHxayyRGGcT6a2WAObp7qryBHFWyL_7"
|
|
]
|
|
));
|
|
|
|
// PayPal REST API version
|
|
define("PAYPAL_REST_VERSION", "v2");
|
|
|
|
// ButtonSource Tracker Code
|
|
define("SBN_CODE", "PP-DemoPortal-EC-Psdk-ORDv2-php");
|
|
|
|
function readEnv($file)
|
|
{
|
|
if (!file_exists($file)) {
|
|
throw new Exception('Cannot find env file');
|
|
}
|
|
|
|
$lines = file($file, FILE_IGNORE_NEW_LINES);
|
|
$env = [];
|
|
foreach ($lines as $line) {
|
|
if (!trim($line) || strpos(trim($line), '#') === 0) {
|
|
continue; // 忽略注释
|
|
}
|
|
|
|
list($name, $value) = explode('=', $line, 2);
|
|
$name = trim($name);
|
|
$value = trim($value);
|
|
define($name, $value);
|
|
}
|
|
|
|
return $env;
|
|
}
|
|
$path = __DIR__ . '/../../.env';
|
|
$envArray = readEnv($path);
|
|
|
|
const GAME_DB = [
|
|
'host' => GAME_HOSTNAME,
|
|
'db' => GAME_DATABASE,
|
|
'user' => GAME_USERNAME,
|
|
'pass' => GAME_PASSWORD,
|
|
'port' => GAME_HOSTPORT,
|
|
];
|
|
const GAMESDK_DB = [
|
|
'host' => GAME_SDK_HOSTNAME,
|
|
'db' => GAME_SDK_DATABASE,
|
|
'user' => GAME_SDK_USERNAME,
|
|
'pass' => GAME_SDK_PASSWORD,
|
|
'port' => GAME_SDK_HOSTPORT,
|
|
];
|
|
|
|
const LAN = [
|
|
'en' => [
|
|
'gift' => 'Gift package content',
|
|
'price' => 'Total price',
|
|
'loading' => 'Order confirmation, please be later',
|
|
'success' => 'Pay successfully, please go back to the game',
|
|
'error' => 'Payment has failed, please try again later',
|
|
'btn' => 'Back to the game',
|
|
],
|
|
'tw' => [
|
|
'gift' => '禮包內容',
|
|
'price' => '總價',
|
|
'loading' => '訂單確認中,請稍後',
|
|
'success' => '支付成功,請回到遊戲查看',
|
|
'error' => '支付失敗,請稍後再試',
|
|
'btn' => '返回遊戲',
|
|
],
|
|
'zh' => [
|
|
'gift' => '礼包内容',
|
|
'price' => '总价',
|
|
'loading' => '订单确认中,请稍后',
|
|
'success' => '支付成功,请回到游戏查看',
|
|
'error' => '支付失败,请稍后再试',
|
|
'btn' => '返回游戏',
|
|
],
|
|
];
|