1. Go to this page and download the library: Download cybersource/rest-client-php 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/ */
cybersource / rest-client-php example snippets
// For TESTING use
// $this->runEnv = "apitest.cybersource.com";
// For PRODUCTION use
$this->runEnv = "api.cybersource.com";
$config = new CyberSource\Authentication\Core\MerchantConfiguration();
$config->setAuthenticationType('JWT');
$config->setMerchantID('your_merchant_id');
$config->setRunEnvironment('apitest.cybersource.com');
// jwtKeyType defaults to P12 if omitted
$config->setKeyAlias('your_merchant_id');
$config->setKeyPassword('your_merchant_id');
$config->setKeyFileName('your_merchant_id');
$config->setKeysDirectory('/path/to/p12/directory');
$config = new CyberSource\Authentication\Core\MerchantConfiguration();
$config->setAuthenticationType('JWT');
$config->setMerchantID('your_merchant_id');
$config->setRunEnvironment('apitest.cybersource.com');
$config->setJwtKeyType('SHARED_SECRET');
$config->setApiKeyID('your_key_id');
$config->setSecretKey('your_base64_encoded_shared_secret');
// BEFORE (HTTP Signature — deprecated)
$config->setAuthenticationType('HTTP_SIGNATURE');
$config->setApiKeyID('your_key_id');
$config->setSecretKey('your_shared_secret');
// AFTER (JWT with Shared Secret / HS256 HMAC-SHA256 — recommended)
$config->setAuthenticationType('JWT'); // changed
$config->setJwtKeyType('SHARED_SECRET'); // added — uses HS256 (HMAC-SHA256)
$config->setApiKeyID('your_key_id'); // same
$config->setSecretKey('your_shared_secret'); // same
$config = new CyberSource\Authentication\Core\MerchantConfiguration();
$config->setAuthenticationType('JWT');
$config->setMerchantID('your_merchant_id');
$config->setRunEnvironment('apitest.cybersource.com');
$config->setJwtKeyType('SHARED_SECRET');
$config->setApiKeyID('your_key_id');
$config->setSecretKey('your_base64_encoded_shared_secret');
// Request MLE configuration
$config->setEnableRequestMLEForOptionalApisGlobally(true);
$config->setMleForRequestPublicCertPath('/path/to/mle/public/cert.pem');
// Response MLE is also supported — see MLE.md for full configuration
// $config->setEnableResponseMleGlobally(true);
// $config->setResponseMlePrivateKeyFilePath('/path/to/private/key.p12');
// $config->setResponseMlePrivateKeyFilePassword('password');
$config = new CyberSource\Authentication\Core\MerchantConfiguration();
$config->setAuthenticationType('JWT');
$config->setJwtKeyType('SHARED_SECRET');
$config->setMerchantID('your_transacting_merchant_id');
$config->setApiKeyID('your_metakey_portfolio_KeyId');
$config->setSecretKey('your_metakey_portfolio_shared_secret_key');
$config->setPortfolioID('your_portfolio_id');
$config->setUseMetaKey(true);
$config->setRunEnvironment('apitest.cybersource.com');
// Response MLE — use the portfolio's response MLE key, not the transacting merchant's
$config->setEnableResponseMleGlobally(true);
$config->setResponseMlePrivateKeyFilePath('/path/to/portfolio/response/mle/private/key.p12');
$config->setResponseMlePrivateKeyFilePassword('portfolio_private_key_password');
// responseMleKID is optional when using a CyberSource-generated P12 file (auto-fetched from P12)
// Required when using PEM files or responseMlePrivateKey object
// $config->setResponseMleKID('your_portfolio_response_mle_kid');
// For TESTING use
$config->setRunEnvironment('api-matest.cybersource.com');
// For PRODUCTION use
// $config->setRunEnvironment('api-ma.cybersource.com');