58 lines
2.9 KiB
PHP
58 lines
2.9 KiB
PHP
<?php
|
|
// Basic configuration for PayPal integration.
|
|
// Fill in your Sandbox (or Live) credentials from developer.paypal.com
|
|
|
|
// Compute a runtime base URL if no explicit override is provided (supports multi-tenant subdomains).
|
|
$envBaseUrl = getenv('PAYP_BASE_URL');
|
|
if ($envBaseUrl && is_string($envBaseUrl)) {
|
|
$computedBaseUrl = rtrim($envBaseUrl, '/');
|
|
} else {
|
|
$scheme = 'http';
|
|
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
|
|
$scheme = 'https';
|
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
|
$scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'];
|
|
}
|
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
// e.g., /payp from /payp/index.php
|
|
$scriptDir = isset($_SERVER['SCRIPT_NAME']) ? str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])) : '';
|
|
$scriptDir = rtrim($scriptDir, '/');
|
|
$computedBaseUrl = $scheme . '://' . $host . ($scriptDir ?: '');
|
|
}
|
|
|
|
return [
|
|
// 'sandbox' or 'live'
|
|
'env' => 'sandbox',
|
|
|
|
// PayPal REST App credentials for your Partner (platform) app
|
|
'client_id' => 'ASQZdduObsa_SOb-ls0n4OfUK4tLqGTpI4AMJH_QgX1f6IjwBnomcrMceCncY4y4_xlnLS4rM3jC7eS8',
|
|
'client_secret' => 'EHHn_pdtB7PjWhn4GKEWcAgK1z_hcgVt3ruGsdkiXEKGCofY0wYHFCYuSi2kSPrnajOmOtzr76zucDBL',
|
|
|
|
// Your Partner's PayPal Merchant ID (aka Payer ID). Required to look up merchant info by tracking_id
|
|
// Find this in Business Profile > Account IDs in your PayPal dashboard (sandbox or live as appropriate)
|
|
'partner_merchant_id' => 'WVCTUHZHST2FJ',
|
|
|
|
// Base URL used by browser redirects (auto-detected; override via PAYP_BASE_URL env if needed)
|
|
'base_url' => $computedBaseUrl,
|
|
|
|
// Storage path (must be writable by Apache/PHP)
|
|
'storage_path' => __DIR__ . DIRECTORY_SEPARATOR . 'data',
|
|
|
|
// CA bundle for cURL TLS verification. Some environments (notably Windows
|
|
// PHP builds) ship without a configured curl.cainfo, which makes every
|
|
// HTTPS call to PayPal fail with "unable to get local issuer certificate".
|
|
// We bundle a Mozilla CA file next to this config and use it when present;
|
|
// on servers with a system bundle already configured this is simply ignored.
|
|
'curl_ca_bundle' => is_file(__DIR__ . '/cacert.pem') ? __DIR__ . '/cacert.pem' : null,
|
|
// Pay Later promotional messaging ("Pay in 4 payments of $X") in the
|
|
// checkout widget and paypal-paylater-message.php. Set to false if the
|
|
// SDK's messaging component throws unhandled PAGE_TYPE exceptions —
|
|
// buttons and wallet payments are unaffected by turning this off.
|
|
'paylater_messaging' => false,
|
|
// Webhook ID from PayPal Developer Dashboard → Your App → Webhooks.
|
|
// Register webhook.php as the endpoint URL, then paste the generated ID here.
|
|
// Events to subscribe: MERCHANT.PARTNER-CONSENT.REVOKED
|
|
// CUSTOMER.MERCHANT-INTEGRATION.PRODUCT-SUBSCRIPTION-UPDATED
|
|
'webhook_id' => '8X0726325N7595153',
|
|
];
|