GithubHelp home page GithubHelp logo

cybersource-rest-client-php's Introduction

PHP Client SDK for CyberSource REST APIs

Description

The CyberSource PHP client provides convenient access to the CyberSource REST API from your PHP application.

Version

System Requirements

  • PHP 8.0.0+
  • cURL PHP Extension
  • JSON PHP Extension
  • OpenSSL PHP Extension
  • Zip PHP Extension
  • MBString PHP Extension
  • Sodium PHP Extension
  • PHP_APCU PHP Extension. You will need to download it for your platform (Windows/Linux/Mac)

Installation

Composer

We recommend using Composer. (Note: we never recommend you override the new secure-http default setting). Update your composer.json file as per the example below and then run composer update.

{
  "require": {
    "php": ">=8.0.0", 
    "cybersource/rest-client-php": "0.0.54"
  }
}

Account Registration & Configuration

  • Account Registration

Follow the first step mentioned in Getting Started with CyberSource REST SDKs to create a sandbox account.

  • Configuration

Follow the second step mentioned in Getting Started with CyberSource REST SDKs to configure the SDK by inputting your credentials.

Please note that this is for reference only. Ensure to store the credentials in a more secure manner.

How to Use

To get started using this SDK, it is highly recommended to download our sample code repository:

In that repository, we have comprehensive sample code for all common uses of our API:

Additionally, you can find details and examples of how our API is structured in our API Reference Guide:

The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.

To learn more about how to use CyberSource's REST API SDKs, please use Developer Center REST API SDKs.

Example using Sample Code Application

For more detailed examples, refer to the cybersource-rest-samples-php repository.

Switching between the sandbox environment and the production environment

CyberSource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the appropriate property in Resources\ExternalConfiguration.php.

For example:

   // For TESTING use
   // $this->runEnv = "apitest.cybersource.com";
   // For PRODUCTION use
   $this->runEnv = "api.cybersource.com";

The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.

Logging

Generic badge

Since v0.0.24, a new logging framework has been introduced in the SDK. This new logging framework makes use of Monolog, and standardizes the logging so that it can be integrated with the logging in the client application.

More information about this new logging framework can be found in this file : Logging.md

Features

MetaKey Support

A Meta Key is a single key that can be used by one, some, or all merchants (or accounts, if created by a Portfolio user) in the portfolio.

The Portfolio or Parent Account owns the key and is considered the transaction submitter when a Meta Key is used, while the merchant owns the transaction.

MIDs continue to be able to create keys for themselves, even if a Meta Key is generated.

Further information on MetaKey can be found in New Business Center User Guide.

Additional Information

PHP_APCU PHP Extension

Enable PHP_APCU PHP Extension in php.ini file. You will need to download it for your platform (Windows/Linux/Mac) and add in extensions.

Official PHP_APCU - https://pecl.php.net/package/APCu

For Windows:

  1. PHP v8.0: Download the applicable php_apcu dll version v5.1.19 from the official pecl site.
  2. PHP v8.1: Download the applicable php_acpu dll version v5.1.21 from the official pecl site.
  3. PHP v8.2: Download the applicable php_acpu dll version v5.1.22 from the official pecl site. But dll is missing on the pecl site for php v8.2 Alternatively, you can refer to this stackoverflow question, or you can download the php_apcu dll from here.

For Mac/Linux/Unix:

Download the php_apcu using pecl command: pecl install apcu. It will auto download the applicable apcu extension for the PHP v8.0, v8.1, v8.2.

How to Contribute

  • Fork the repo and create your branch from master.
  • If you've added code that should be tested, add tests.
  • Ensure the test suite passes.
  • Submit your pull request! (Ensure you have synced your fork with the original repository before initiating the PR).

Need Help?

For any help, you can reach out to us at our Discussion Forum.

Disclaimer

CyberSource may allow Customer to access, use, and/or test a CyberSource product or service that may still be in development or has not been market-tested (“Beta Product”) solely for the purpose of evaluating the functionality or marketability of the Beta Product (a “Beta Evaluation”). Notwithstanding any language to the contrary, the following terms shall apply with respect to Customer’s participation in any Beta Evaluation (and the Beta Product(s)) accessed thereunder): The Parties will enter into a separate form agreement detailing the scope of the Beta Evaluation, requirements, pricing, the length of the beta evaluation period (“Beta Product Form”). Beta Products are not, and may not become, Transaction Services and have not yet been publicly released and are offered for the sole purpose of internal testing and non-commercial evaluation. Customer’s use of the Beta Product shall be solely for the purpose of conducting the Beta Evaluation. Customer accepts all risks arising out of the access and use of the Beta Products. CyberSource may, in its sole discretion, at any time, terminate or discontinue the Beta Evaluation. Customer acknowledges and agrees that any Beta Product may still be in development and that Beta Product is provided “AS IS” and may not perform at the level of a commercially available service, may not operate as expected and may be modified prior to release. CYBERSOURCE SHALL NOT BE RESPONSIBLE OR LIABLE UNDER ANY CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE RELATING TO A BETA PRODUCT OR THE BETA EVALUATION (A) FOR LOSS OR INACCURACY OF DATA OR COST OF PROCUREMENT OF SUBSTITUTE GOODS, SERVICES OR TECHNOLOGY, (B) ANY CLAIM, LOSSES, DAMAGES, OR CAUSE OF ACTION ARISING IN CONNECTION WITH THE BETA PRODUCT; OR (C) FOR ANY INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, LOSS OF REVENUES AND LOSS OF PROFITS.

cybersource-rest-client-php's People

Contributors

ashtru avatar brianmc avatar chsriniv9 avatar gaubansa avatar gnongsie avatar kasperfranz avatar katterisharath avatar khaaldrogo avatar kikmak42 avatar monu-kumar-visa avatar rsachan8 avatar sachshet avatar santoshshanmugam avatar snavinch avatar ssethumavisa avatar syip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cybersource-rest-client-php's Issues

[Resolved]Reason code not present in the return[RESOLVED]

Hello, this is not a issue, is more like a support request(i really tried to research but didn't find anything), im creating a payment using the method createPayment() from the paymentsApi, i need the "reason code" number in the response, but i didn't find it, i got the $response->getErrorInformation()->getReason() that gives me a text, but i need the reason code number.

The payment is created correctly, i can see it in cybersource,and i can see reason code there too, but i cant find it in the API return, did you guys know where the reason code will be in the response? thanks :)

Double https:// in default configuration host

Bug

Description

As a developer attempting to use the rest client, I tried to make a request with the default configuration and get the error:

API call to https://https://apitest.cybersource.com/flex/v1/keys/ failed: Could not resolve host: https

Note the duplicate https:// at the beginning of the query url.

Solution

Note the two following files. The callApi method appends an https:// to the host URL. To fix, either remove the appended https:// from callApi or, perhaps more-backward compatibly use a regex to conditionally append the https:// IFF the host url does not contain https:// at the start of the string.

$url = GlobalParameter::HTTPS_PREFIX.$this->config->getHost() . $resourcePath;

protected $host = 'https://apitest.cybersource.com';

Notes

This probably needs unit test coverage as well.

setDebug methods removed from Authentication/Core/MerchantConfiguration

Hey guys, I noticed when combing through some logs in some of our Magento2 code that there are calls to a method setDebug that no longer exists. Our client code is calling this code to run reports, but it also seems that your code is still calling these non-existent methods as well.

If you look here at this older version of your code

You can see a setDebug did exist and you can see here on the most recent version of your code, that the method no longer exists but is still being called by other methods

$config = $config->setDebug($connectionDet->enableLog);

It seems to me that this was partially replaced by CyberSource/LogConfiguration class but I cannot tell for sure.

I Was wondering if you guys could provide any insight or code fix for this. This snippet of code below is what we have written for running our reports it essentially news up a CyberSource/Authentication/Core/MerchantConfiguration class and sets these methods (the first 3 of which do not seem to exist any longer)

          $merchantConfig->setDebug($enableLog);
            $merchantConfig->setLogSize(trim($logSize));
            $merchantConfig->setDebugFile(trim($logFile));
            $merchantConfig->setLogFileName(trim($logFilename));
            $merchantConfig->setauthenticationType($authenticationType);
            $merchantConfig->setMerchantID(trim($merchantID));
            $merchantConfig->setApiKeyID($apiKeyID);
            $merchantConfig->setSecretKey($secretKey);
            $merchantConfig->setKeyFileName(trim($keyFilename));
            $merchantConfig->setKeyAlias($keyAlias);
            $merchantConfig->setKeyPassword($keyPass);
            $merchantConfig->setKeysDirectory($keyDirectory);
            $merchantConfig->setRunEnvironment($runEnv);
            $merchantConfig->validateMerchantData();

I was wondering what a replacement for these methods might be as they are causing our report code to fail.

Thanks!

Why is APCU a requirement?

Looking at the dependencies, there seems to be a hard requirement for APCU for this library to work. However, it doesn't seem to be used outside of lib/Authentication/Jwt/JsonWebTokenHeader.php.

Related, there's a dependency for cache/apcu-adapter in composer.json, but I can't find any place where the class from that package is used. Is it used anywhere?

Longer term, why are you dictacting a caching back end? The REST client could use a PSR-6 Caching compatible implementation and then leave the choice of back ends to the end user.

Old version of web-token/jwt-framework

Hi,

I can see you have just included the package web-token/jwt-framework in the latest release.

Would you be able to update to use v3 instead of v2? (or allow both at the same time).

version 2 is using symfony/console ^4.2|^5.0
version 3 allows ^5.4|^6.0.

Symfony 4.4 is out of security support in November this year https://symfony.com/releases/4.4

Thank you

SDK License missing

It appears that the LICENSE file is missing from this particular library, as it exists in all the other language SDK's that CyberSource provides ... including the PHP SOAP SDK: https://github.com/CyberSource/cybersource-sdk-php/blob/master/LICENSE

It would appear, I assume, that this is an oversight. However before we continue moving forward in using this client. It would be good for the license to be merged/copied into this Client Library as well, giving people permission to use it properly.

Thanks

SDK error handling the $responseCode when calling PtsV2PaymentsPost201ResponseProcessorInformation.

Hi, we have some troubles with the SDK, is throwing an error when we are making some API calls to Cybersource

this is the information we collected when the exception was catched.

File:
vendor/cybersource/rest-client-php/lib/Model/PtsV2PaymentsPost201ResponseProcessorInformation.php

Exception Message:
invalid length for $responseCode when calling PtsV2PaymentsPost201ResponseProcessorInformation., must be smaller than or equal to 10.

Hard coded ExternalConfiguration path in ApiClient.php::callAuthenticationHeader

    public function callAuthenticationHeader($method, $postData, $resourcePath)
    {
        require_once './Resources/ExternalConfiguration.php';
        $ExternalConfigurationObj = new ExternalConfiguration();
        $merchantConfig = $ExternalConfigurationObj->merchantConfigObject();

It assumes that there will be a Resources directory under project root and the path is not configurable.

The ExternalConfiguration should be pass as function params rather than requiring it in callAuthenticationHeader.

Documented Return Type of CyberSource\Api\KeyGenerationApi:: generatePublicKey is incorrect

Bug

Description

As a developer attempting to use the rest client, I expect the return types of functions to match the actual return types listed in doc blocks.

public function generatePublicKey($generatePublicKeyRequest = null)

Fatal error: Uncaught TypeError: Argument 1 passed to MyClass::transform() must be an instance of CyberSource\Model\FlexV1KeysPost200Response, array given

Solution

Fix the return type to array, if it is actually an array, otherwise make the return type a CyberSource\Model\FlexV1KeysPost200Response

Notes

This probably needs unit test coverage as well.

Monolog Attempts to write files when "disabled".

On our server, even when setting enableLogging(false) in the merchant config, we sometimes see attempts to write to MonoLog files.

It looks like the constructor for MerchantConfiguration sets it's own static logger before the logConfig has been set so this one is always using default settings.

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->tempFolderPath = sys_get_temp_dir();
        $this->logConfig = new LogConfiguration();

        if (self::$logger === null) {
            self::$logger = (new LogFactory())->getLogger(\CyberSource\Utilities\Helpers\ClassHelper::getClassName(get_class()), $this->logConfig);
        }
    }

So when we do

$logConfiguration = new LogConfiguration();
$logConfiguration->enableLogging(false);
$merchantConfig->setLogConfiguration($logConfiguration);

It's too late to stop all log messages.

UnexpectedValueException: There is no existing directory at 
 "/mnt/www/html/xxx/vendor/cybersource/rest-client-php/lib/Logging/../../../../../Log"
 and it could not be created: Permission denied in Monolog\Handler\StreamHandler->createDir()
 (line 216 of /mnt/www/html/xxx/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php)

Our filesystem is read-only. How can we totally disable Monolog?

Get Transaction details fails when CC is American Express

Hi all,

I got this error only when CC used for the transaction in America express

PHP Fatal error: Uncaught InvalidArgumentException: invalid length for $paymentSolution when calling TssV2TransactionsGet200ResponseProcessingInformation., must be smaller than or equal to 12.

cybersource/rest-client-php/lib/Api/TransactionDetailsApi.php

thx

Issue with ApplePay & Amex on production

Hello,

On one of the projects we are working we are blocked on an issue where Amex ( American express ) cards are not going through with Live credentials ( it works with ApplePay sandbox and CyberSource sandbox ) but when we switched to live then we are hitting error

Invalid Request Data
Unsupported ECI type. e_commerce_indicator=AESK

I can confirm for Visa and Mastercard everything works but it is related only to AMEX

it sounds like CyberSource doesn't like the ECI parameter AESK ? but what ECI parameter is expected for AMEX ?

Please advice ?

in our code we have :

$processingInformation = new Ptsv2paymentsProcessingInformation([ 'commerceIndicator' => 'internet', 'paymentSolution' => '001' ]);

has commerceIndicator and paymentSolution needs to be different for AMEX ?

Many thanks
Sergiu

Exception invalid length for $paymentSolution

Hi,

While testing TransactionDetailsApi api to track Paypal alternative payment through cybersource I'm facing a validation exception :
Exception when calling TransactionDetailsApi->getTransaction: invalid length for $paymentSolution when calling TssV2TransactionsGet200ResponseProcessingInformation., must be smaller than or equal to 12.

I checked quickly an this is due to 'paymentSolution' = 'Alternative Payment Paypal' (length=26) :

object(CyberSource\Model\TssV2TransactionsGet200ResponseProcessingInformation)[81]
protected 'container' =>
array (size=5)
'paymentSolution' => string 'Alternative Payment Paypal' (length=26)
'commerceIndicator' => null
'businessApplicationId' => null
'authorizationOptions' =>
object(CyberSource\Model\TssV2TransactionsGet200ResponseProcessingInformationAuthorizationOptions)[82]
protected 'container' =>
array (size=1)
'authType' => null
'bankTransferOptions' =>
object(CyberSource\Model\TssV2TransactionsGet200ResponseProcessingInformationBankTransferOptions)[83]
protected 'container' =>
array (size=1)
'secCode' => null

I guess the 12 size constraint should be modified as for alternative payments we have at least 26 chars ..., this is a critical bug which blocks transactions details check for altPay transactions.

In order to fix it in m project I made the following change in vendor/cybersource/rest-client-php/lib/Model/TssV2TransactionsGet200ResponseProcessingInformation.php:215 :

public function setPaymentSolution($paymentSolution)
{
if (!is_null($paymentSolution) && (strlen($paymentSolution) > 28)) { // value was 12
throw new \InvalidArgumentException('invalid length for $paymentSolution when calling TssV2TransactionsGet200ResponseProcessingInformation., must be smaller than or equal to 28.');
}
$this->container['paymentSolution'] = $paymentSolution;
return $this;
}

Could you check ?

Thanks in advance.
Mohamed GHARBI

Issue with PHP 5.6

Hello, I have an error when I'm trying to do a request (with PHP 5.6.40 and cybersource/rest-client-php 0.0.29)

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /usr/src/myapp/vendor/cybersource/rest-client-php/lib/ApiClient.php on line 338

DateTime Not Supported For ReportDownloadsApi Rest Api

Issue

Passing a DateTime object as the $reportDate parameter into CyberSource\Api\ReportDownloadsApi::downloadReport($reportDate, $reportName, $organizationId = null) produces an error, despite it being a valid parameter type.

Seems to be due to the the CyberSource\ObjectSerializer formatting the date as \DateTime::ATOM which does not appear to be supported. Only date format that worked was a string value in the format of YYYY-MM-DD, which your examples do show.

Related Issue

I only bring this up because I'm converting a client to the Rest API to continue to receive their daily reports. The main issue I've been running into is that the transaction dates in at least the ConversionDetailReport_Daily_Classic report are coming back inconsistently when I pass the same date for US/CA/UK cybersource accounts. The UK report is returning transaction dates for two days ago instead of the previous day.

Example:
If I passed 2019-10-25 for US/CA/UK accounts I get the following transaction start/end dates in the reports:

US:
ReportStartDate="2019-10-24T07:00:00Z-08:00"
ReportEndDate="2019-10-25T07:00:00Z-08:00"

CA:
ReportStartDate="2019-10-24T00:00:00Z+00:00"
ReportEndDate="2019-10-25T00:00:00Z+00:00"

UK:
ReportStartDate="2019-10-23T23:00:00Z+00:00"
ReportEndDate="2019-10-24T23:00:00Z+00:00"

Known Affected Reports

  • ConversionDetailReport_Daily_Classic
  • PaymentBatchDetailReport_Daily_Classic
  • TransactionDetailReport_Daily_Classic

return $value->format(\DateTime::ATOM);

Issue updating from 0.0.7 to 0.0.21

When I try to require version 0.0.21, I get the following error

Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: cache/apcu-adapter[1.1.0, 1.0.0].
    - Can only install one of: cache/apcu-adapter[1.1.0, 1.0.0].
    - cybersource/rest-client-php 0.0.23 requires cache/apcu-adapter 1.1.0 -> satisfiable by cache/apcu-adapter[1.1.0].
    - Installation request for cybersource/rest-client-php ^0.0.23 -> satisfiable by cybersource/rest-client-php[0.0.23].
    - Installation request for cache/apcu-adapter (locked at 1.0.0) -> satisfiable by cache/apcu-adapter[1.0.0].


Installation failed, reverting ./composer.json to its original content.

I cannot seem to get my app to accept the new version.

Not compatible with Composer v2 (not psr-4 autoloading standard)

Class CyberSource\Model\Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction located in ./vendor/cybersource/rest-client-php/lib/Model/Ptsv2paymentsMerchantInitiatedTransaction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0

BTW, Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionv is quite a class name...

firebase/php-jwt Version Conflict

Problem 1
- Root composer.json requires firebase/php-jwt ^5.0, found firebase/php-jwt[v5.0.0, ..., v5.5.1] but the package is fixed to v6.3.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Problem 2
- Root composer.json requires cybersource/rest-client-php v0.0.31 -> satisfiable by cybersource/rest-client-php[0.0.31].
- cybersource/rest-client-php 0.0.31 requires firebase/php-jwt ^5.0.0 -> found firebase/php-jwt[v5.0.0, ..., v5.5.1] but the package is fixed to v6.3.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Change the firebase/php-jwt version requirement to ^5.0

This module forces an explicit dependency on php-jwt 5.0.0 even though subsequent versions of php-jwt above 5.0.0 but less than 6.0.0 should not introduce any breaking changes (assuming it conforms to semantic versioning, which I'd expect). The problem this creates is I have other dependencies in my project that require php-jwt ^5.0, meaning Composer has already installed 5.2.0 in my codebase and believes reverting to 5.0.0 to satisfy this library's requirement is a conflict.

If there's no explicit reason to require 5.0.0 for this library, can we update the requirement to ^5.0 to erase this conflict for myself and others. That should literally just have the affect of ensuring projects using this package have access to any bugfixes in php-jwt represented in those new minor versions.

Monolog version conflict with Laravel

Hey,

The latest version of Laravel has moved to monolog 2, but this project requires Monolog 1 for some reason. This doesn't appear to be an issue in 0.0.23, but it does for the subsequent releases.

Is this able to be resolved please? We are stuck on 0.0.23 until this resolves.

  Problem 1
    - Root composer.json requires cybersource/rest-client-php ^0.0.25 -> satisfiable by cybersource/rest-client-php[0.0.25].
    - Conclusion: don't install monolog/monolog 2.0.1 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.25.1 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.0.2 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.25.2 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.1.0 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.25.3 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.1.1 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.25.4 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.2.0 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.25.5 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.3.0 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.26.0 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.3.1 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 1.26.1 (conflict analysis result)
    - Conclusion: don't install monolog/monolog 2.3.2 (conflict analysis result)
    - laravel/framework[v8.0.0, ..., 8.x-dev] require monolog/monolog ^2.0 -> satisfiable by monolog/monolog[2.0.0-beta1, ..., 2.x-dev (alias of dev-main)].
    - monolog/monolog 2.x-dev is an alias of monolog/monolog dev-main and thus requires it to be installed too.
    - You can only install one version of a package, so only one of these can be installed: monolog/monolog[dev-main, 1.25.0, ..., 1.x-dev, 2.0.0-beta1, ..., 2.3.2].
    - cybersource/rest-client-php 0.0.25 requires monolog/monolog ^1.25.0 -> satisfiable by monolog/monolog[1.25.0, ..., 1.x-dev].
    - Conclusion: don't install monolog/monolog 1.25.0 (conflict analysis result)
    - Root composer.json requires laravel/framework ^8.0 -> satisfiable by laravel/framework[v8.0.0, ..., 8.x-dev].

Cheers,

Tom

Monolog usage is restricted to the filesystem

The way the client is currently instantiated, there's a hard coded dependency on using Monolog's filesystem logger. The monolog project offers multiple backends. Ideally, the rest client could use any of them (the interface is stable) and it should be injected when the client is configured.

Flex Model KeyParameters is missing targetOrigin and other parameters

In the PHP samples and also in my code which uses this PHP Client, the model class for KeyParameters (https://github.com/CyberSource/cybersource-rest-client-php/blob/master/lib/Model/KeyParameters.php) is not serializing all the parameters into the JSON payload. Specifically targetOrigin is missing so when you add that to the sample code at https://github.com/CyberSource/cybersource-rest-samples-php/blob/master/Samples/Flex/CoreServices/GenerateKey.php as below, the parameter never makes it to the payload, as you can see from the log.

$flexRequestArr = [
"encryptionType" => "RsaOaep256",
"targetOrigin" => "http://localhost:8000",
];
$flexRequest = new CyberSource\Model\KeyParameters($flexRequestArr);

Issue with PHP 8.1

Getting below error when using PHP 8.1,

offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/cybersource/rest-client-php/lib/Model/GeneratePublicKeyRequest.php on line 221

is there any other LIB i need to use ?

Some classes doesn't comply with psr-4

Class CyberSource\Model\Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction located in ./vendor/cybersource/rest-client-php/lib/Model/Ptsv2paymentsMerchantInitiatedTransaction.php does not comply with psr-4 autoloading standard. Skipping.

sdk version: 0.0.20

ApiClient.php does not work when composer's "vendor-dir" is not "vendor"

File: cybersource/rest-client-php/lib/ApiClient.php
Function: getClientId()

This code has hardcoded "vendor" dir name, but composer has the ability to override it with vendor-dir directive, and when it happens, lib will stop working rendering file not found message. Also, what if I do not use composer?

$packages = json_decode(file_get_contents(DIR . "/../../../../vendor/composer/installed.json"), true);

proper code (does not go outside of the "vendor" folder):

$packages = json_decode(file_get_contents(DIR . "/../../../composer/installed.json"), true);

Fixable compatibility issues with PHP 8.2-8.3

Hi,

I'm using v0.0.47 of the SDK but the following seems to be an issue also on the latest version. Some classes seem to assign properties dynamically without declaring them. This has been deprecated in PHP 8.2 (resulting in thrown deprecation notices) and will result in fatal errors in future versions.

https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.dynamic-properties

Here's a partial list of notices I've seen:

  • vendor/cybersource/rest-client-php/lib/Authentication/Core/MerchantConfiguration.php on line 228
  • vendor/cybersource/rest-client-php/lib/ApiClient.php on line 108
  • vendor/cybersource/rest-client-php/lib/ApiClient.php on line 240
  • vendor/cybersource/rest-client-php/lib/Authentication/PayloadDigest/PayloadDigest.php on line 47
  • vendor/cybersource/rest-client-php/lib/Authentication/Http/HttpSignatureGenerator.php on line 78
  • vendor/cybersource/rest-client-php/lib/Authentication/PayloadDigest/PayloadDigest.php on line 47

there might be more

A quick workaround for this could be to add a #[AllowDynamicProperties] attribute at the start of the affected classes until a more robust handling is in place.

https://www.php.net/manual/en/class.allowdynamicproperties.php

Having : invalid length for $code when calling PtsV2PaymentsPost201ResponseProcessorInformationAvs., must be smaller than or equal to 1.

When using getTransaction API, i got an issue with AVS result code which is received from cybersource as "2 " and in the setCode method we have a check on code lenght > 1
which is the case for the non trimmed string.

I guess the fix should be like :
vendor/cybersource/rest-client-php/lib/Model/PtsV2PaymentsPost201ResponseProcessorInformationAvs.php:199

public function setCode($code) { $code = trim($code); // remove eventual spaces if (!is_null($code) && (strlen($code) > 1)) { throw new \InvalidArgumentException('invalid length for $code when calling PtsV2PaymentsPost201ResponseProcessorInformationAvs., must be smaller than or equal to 1.'); }

Composer found a Security Vulnerability

Good day!

While installing your package, Composer told me that there's a security vulnerability. When I ran the composer audit, it showed me this:

image

Hopefully, someone can upgrade the version of firebase/php-jwt to ^6.0.

Have a nice day ahead!

Capture Context fails if masking enabled

\CyberSource\Api\KeyGenerationApi::generatePublicKey() will fail if masking is enabled.

The code fails in cybersource/rest-client-php/lib/Api/KeyGenerationApi.php, line 172 because $httpBody is an array and \CyberSource\Utilities\Helpers\DataMasker::maskData expects to be passed a JSON string.

- The requested package cybersource/global-payment-management could not be found in any version, there may be a typo in the package name.

Hello,

We are one of your clients and we pay money every year.
We launched a new website, developed in Magento 2, and the extension provided is not working:

Check Component Dependency
We found conflicting component dependencies. Hide detail

Command "update" failed: Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package cybersource/global-payment-management could not be found in any version, there may be a typo in the package name.

Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

For additional assistance, see component dependency help .

I tried to contact cybersource magento support via email but NO ANSWER.

What can I do to use the extension? Why is so hard to contact someone from tech team to help us?

Regards,
Radu

Fails with Composer v2

This package assumes vendor/composer/installed.json is in a Composer v1 format.

Here is a sample snippet of the Composer 2 version of this file:

{
    "packages": [
        {
            "name": "altek/accountant",
            "version": "v2.0.3",
            "version_normalized": "2.0.3.0",
            // ...
        }
  ]
}

However, the function CyberSource\ApiClient::getClientId assumes that packages is at the top level, which is no longer the case in the format listed above.

It fails at this line approx 155 where it tries to retrieve the property name:

            if (strcmp($package['name'], "cybersource/rest-client-php") == 0)

Method CyberSource\Model\CheckPayerAuthEnrollmentRequest::__toString() must return a string value

Hi,

I have some transactions in use with the PHP SDK returning this message that shows an error inside the lib. What can be wrong in the implementation?

{
  "code": 0,
  "trace": "#0 /app/vendor/cybersource/rest-client-php/lib/Api/PayerAuthenticationApi.php(109): CyberSource\\Api\\PayerAuthenticationApi->checkPayerAuthEnrollmentWithHttpInfo()\n#1",
  "message": "Method CyberSource\\Model\\CheckPayerAuthEnrollmentRequest::__toString() must return a string value"
}

And my code just sends the requestObj:
image

And then it performs payer authentication (line 204 where the error warns) :
image

PS.: only a few transactions point to this error (~2% - ~4%), so the implementation works.

MicroformIntegrationApi - Only variables should be passed by reference

Hello,

I seem to be having an issue with the MicroformIntegrationApi class when invoking the generateCaptureContext method.

Here is a small snipped of the exception.

"message": "Only variables should be passed by reference", "exception": "ErrorException", "file": "/var/www/html/vendor/cybersource/rest-client-php/lib/Api/MicroformIntegrationApi.php", "line": 153, "trace": [

The issue appears to be within this bit of code end(explode('\\', '\CyberSource\Model\GenerateCaptureContextRequest')

The "end" PHP method expects the array passed to it to be passed by [reference] (https://www.php.net/manual/en/function.end.php)

This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

However, you are passing a function returning an array.

My application is running PHP 8.0 currently.

Please do let me know if that is not the issue and maybe a pointer to what I am doing wrong because I could not see anything wrong with my implantation based on example here.

However, if this is the issue could I please get an update on a timeline of when this can be fixed. I have to upgrade to Microform V2 by the end of January and this is significantly threatening my timescale.

Thank you.

No API for Chargeback Reports or Summaries

In lib/Api/, there are no APIs provided for the following:

Where {urlPrefix} is "api.cybersource.com" or "apitest.cybersource.com", and {startTime}/{endTime} are ISO 8601 timestamps like "2017-10-01T10:10:10+05:00"

Since these two endpoints have different parameters and URIs than the regular report downloads (/reporting/v3/report-downloads) in lib/Api/ReportDownloadsApi.php, that one cannot be used.

I kept trying to use ReportDownloadsApi.php mistakenly and kept getting a resource not found error. The Servlet to REST API Migration Guide says the Chargeback reports are retired.

However, I eventually tracked down a PDF called Reporting_API_WellsFargoPaymentGateway.pdf that reveals they are not in fact retired, and gives the required URI and parameters.

I think it would be very helpful to include API classes for Chargeback Details and Summaries reports.

dependency error with firebase/php-jwt and other packages

I am not able to install the package because of dependency version error with many packages.

Problem 1
   - cybersource/rest-client-php[dev-december-release-2023, dev-master, dev-adding-disclaimer-in-beta-apis, 0.0.41, ..., 0.0.46] require cache/apcu-adapter >=1.1.0 -> satisfiable by cache/apcu-adapter[1.1.0, 1.1.x-dev, 1.2.0, 1.3.0].
   - cybersource/rest-client-php[dev-generator-with-logging-and-masking, 0.0.1, ..., 0.0.16] require firebase/php-jwt 5.0.0 -> found firebase/php-jwt[v5.0.0] but the package is fixed to v6.10.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - cybersource/rest-client-php[dev-test-fix-empty-body-param, dev-travis-trial, dev-transient_token, dev-masking-fix, dev-sensitive-logging, dev-logging-issue, 0.0.17, ..., 0.0.40] require firebase/php-jwt ^5.0.0 -> found firebase/php-jwt[v5.0.0, ..., v5.5.1] but the package is fixed to v6.10.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - cache/apcu-adapter 1.1.0 requires psr/cache ^1.0 -> found psr/cache[1.0.0, 1.0.1] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - cache/apcu-adapter[1.1.x-dev, ..., 1.3.0] require psr/cache ^1.0 || ^2.0 -> found psr/cache[1.0.0, 1.0.1, 2.0.0] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - Root composer.json requires cybersource/rest-client-php * -> satisfiable by cybersource/rest-client-php[dev-generator-with-logging-and-masking, dev-test-fix-empty-body-param, dev-masking-fix, dev-sensitive-logging, dev-logging-issue, dev-transient_token, dev-travis-trial, dev-december-release-2023, dev-master, dev-adding-disclaimer-in-beta-apis, 0.0.1, ..., 0.0.46, 9999999-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require cybersource/rest-client-php:*" to figure out if any version is installable, or "composer require cybersource/rest-client-php:^2.1" if you know which you need.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.