Giter Site home page Giter Site logo

hipay / hipay-fullservice-sdk-php Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 12.0 9.83 MB

Official repository of the HiPay Fullservice SDK for PHP.

Home Page: https://developer.hipay.com/doc/hipay-fullservice-sdk-php/

License: Apache License 2.0

PHP 100.00%

hipay-fullservice-sdk-php's People

Contributors

ahfeel avatar etiennelandais avatar hipaybot avatar jbaptistelvt avatar jibriss avatar jprotin avatar jtiret avatar kmarques avatar legithubdeaymeric avatar ryneczko avatar sirateck avatar thibautgdt avatar tviardin avatar vdechenaux avatar vdossantos-hipay avatar

Stargazers

 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

hipay-fullservice-sdk-php's Issues

Open /token API to SDK

In a context where we have to check cardCountry before applying fees on a transaction, we're not able to use the PHP SDK to call this API.
Would be very useful to have this API available in the SDK.
A Pull Request have been made (partially) to covers this, but nothing happened in the meantime (#51 ).
Any chance to have this in a future release ?

Mapping issue : undefined index['mid']

Hello,

In case of error while requesting operation (like maintenance), if an error occured on the hipay API, it seems that the mid is not returned. As a result there is a php error on the OperationMapper.php , because the mid is not checked. (Juste a ? which does not perform an isset).

What are the workaround, we do not want to copy the sdk to our source code.

Use of outdated package ramsey/uuid

Hello,

I tried updating the package to version 2.15.0 but we're having compatibility issues with the ramsey/uuid package because the version added in 2.15.0 is 3.9.7 of ramsey which is from September 2021 (last version that supports php 7).

Issue is that we are already using a more recent version of ramsey/uuid and composer can't handle having two versions of the same package at the same time. Meaning we can't upgrade to 2.15.0 until the ramsey version is not updated.

Results of toArray and json_decode(toJson) are not equal

Hello,

As you can see from image, toArray doesn't perform recursively toArray transform.

Also notable when executed toJson, it hides some properties info, as order, paymentMethod, fraudScoring, as a consequence those both arrays aren't equal. Main problem is, that there is no way to save data as it is in database, using toJson - not full info is saved, using toArray need manually perform recursive walk, either database will perform toString which also will hide that mentioned info.

image

soft_descriptor is missing in OrderRequest class

I wanted to add statement descriptor, which will appear in the client's banking application, so I looked in the documentation and found that their is variable soft_descriptor which is used to add statement descriptor. But in OrderRequest class the variable is missing and I'm unable to add it.

So is their any other way to add the statement descriptor

Here is the link of documentation where it is mentioned
https://support.hipay.com/hc/en-us/articles/360010582280-HiPay-Enterprise-Hosted-Fields-with-JavaScript-SDK-and-order-API

and screenshot of it.
image

Thanks

Tokenization removal reason

Hello,
Why was decided to remove tokenization endpoints? I understand, generation and update can be fully performed via js library, but I'm talking about requestLookupToken, which provides usefull information about card. Should it be removed completely from api or is it mistake?

requestMaintenanceOperation is marked as deprecated but the suggested replacement does not exist

Hello,

In lib/HiPay/Fullservice/Gateway/Client/GatewayClientInterface.php the requestMaintenanceOperation function is marked as deprecated.

In lib/HiPay/Fullservice/Gateway/Client/GatewayClient.php the implemented function requestMaintenanceOperation tells to see \HiPay\Fullservice\Gateway\Client\GatewayClientInterface::requestMaintenanceTransaction() but requestMaintenanceTransaction does not exist.

Is requestMaintenanceOperation really deprecated ?
Do you have an example for replacement ?

Regards

User deprecated function: This construction method is deprecated

using php 7.3 I receive the following error:
User deprecated function: This construction method is deprecated. Please use an array to create your configuration. in HiPay\Fullservice\HTTP\Configuration\Configuration->__constructDirect() (line 551 of /var/www/html/vendor/hipay/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/HTTP/Configuration/Configuration.php).

Update list

Hello,

I guess it was long time since update this list
There are some mistakes also, ex.:
"bank-transfert", -> bank-transfer
"webmoney-transfert", -> webmoney-transfer
"klarna" -> now it exists as klarnainvoice and klarnacheckout
"postfinance-card" according site is Debit Card, not "category":"realtime-banking",
"aura" is Credit Card not "category":"realtime-banking",
and missing other supported payments

OrderRequest field paymentMethod usage.

If the current payment method is different from Astropay/CartToken/IDeal/Qiwi/SEPA/3X/4X (which have a corresponding Gateway\Request\PaymentMethod\*PaymentMethod class) what value the
\HiPay\Fullservice\Gateway\Request\Order\OrderRequest::$paymentMethod should assume?

P.S. There is a dead link in the README:

HiPay Support Center β€” To get technical help from HiPay

which points to a not working site http://help.hipay.com/

Update tokenize PaymentCardToken model

Related with #42

Hello,

OLD tokenization v1:

{
  "token": "467826c081633eebca0793ac83966de1bccfc93bd3be168ac4d545abf8005597",
  "request_id": "0",
  "brand": "visa",
  "pan": "400000******0002",
  "card_holder": "Cathy Doe",
  "card_expiry_month": "12",
  "card_expiry_year": "2025",
  "issuer": "",
  "country": "US",
  "domesticNetwork": ""
}

NEW tokenization v2:

{
  "token": "2991f82432550782312e0c8075d2c956d90b54dc5683f8547fe0cc4f66314cc6",
  "request_id": "0",
  "card_hash": "ce5f096fa6bc05989c170e7c96f94432660491bd",
  "card_id": "96ada09f-a844-4956-9593-cb758630dac2",
  "brand": "VISA",
  "pan": "400000xxxxxx0002",
  "card_holder": "Cathy Doe",
  "card_expiry_month": "12",
  "card_expiry_year": "2025",
  "country": "US",
  "card_type": "CREDIT",
  "forbidden_issuer_country": false
}

Currently using this sdk it is imposible to extract card_hash which was as token in v1 unique value per card.

Also I see there were added new fields such as card_id, card_type, forbidden_issuer_country, card_category (maybe there are more secret fields) which were unmentioned in https://developer.hipay.com/doc-api/enterprise/token/#!/tokenization/createToken

json_decode() expects parameter 1 to be string, bool given

Since we updated library, this error occured within SimpleHTTPClient class

json_decode() expects parameter 1 to be string, bool given


because of

        if ((false === $result) && !$isData) {
            throw new CurlException(curl_error($this->_httpClient), curl_errno($this->_httpClient));
        }

when PIDataClient asserts that sendData never fails with curl errors

PHPCompatibility result : PHP has reserved all method names with a double underscore prefix for future use.

result of phpcs with phpcompatibility :

FILE: /var/www/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Gateway/Model/Cart/Item.php
-------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------------
 315 | WARNING | Method name "Item::__constructItem" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.
-------------------------------------------------------------------------------------------------------------------------------------------------------

how to reproduce :

git clone https://github.com/hipay/hipay-fullservice-sdk-php.git
cd hipay-fullservice-sdk-php/
composer require --dev phpcompatibility/php-compatibility  dealerdirect/phpcodesniffer-composer-installer 
#run test
vendor/bin/phpcs -p --standard=PHPCompatibility lib/ tests/

Transaction->getReason() returns wrong type

The function getReason in lib/HiPay/Fullservice/Gateway/Model/Transaction.php should return a string

/**
 * @return string
 */
public function getReason()
{
    return $this->_reason;
}

When we use the function, the data returned seems to be an array.

array:2 [
  "code" => "4000002"
  "message" => "Declined"
]

I think the $reason attribute should be changed to array.

Regards,

3DS1 sunset

Hello,

We have a question, do you allow to control 3ds version to 2 (3DS2)?

3D Secure 1 authentication protocol will be sunset (decommissioned) on the 15th of October 2022 for Visa and the 18th of October for Mastercard respectively. After these dates, 3DS1 authentication will no longer work. Are you aware of this?

DSP2 and browser_info serialization is broken with isJavaEnabled & isJavascriptEnabled

Hi,

this is a regression from the 2.8.2 package version (this bug is not present in the 2.8.0)

When i populate the BrowserInfo with these values (i masked the ipaddr) :

{
    "ipaddr": "xxx.xxx.xxx.xxx",
    "http_accept": "application\/json, text\/plain, *\/*",
    "http_user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.93 Safari\/537.36",
    "java_enabled": false,
    "javascript_enabled": true,
    "language": "fr-FR",
    "color_depth": 24,
    "screen_height": 1440,
    "screen_width": 3440,
    "timezone": "-120"
}

The serialization process before the request remove the "java_enabled" and "javascript_enabled" properties :

{"ipaddr":"172.18.0.1","httpAccept":"application\/json, text\/plain, *\/*","httpUserAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.93 Safari\/537.36","language":"fr-FR","colorDepth":24,"screenHeight":1440,"screenWidth":3440,"timezone":"-120"}

The main bug is inside the AbstractModel serialization function "toArray" :

        foreach ($classRef->getMethods() as $method) {
            if (substr($method->name, 0, 3) == 'get') {
                //clean key name
                $key = lcfirst(substr($method->name, 3));

                //Call getter to get the value
                $val = $method->invoke($this);
                if (is_object($val) && is_a($val, AbstractModel::class)) {
                    $array[$key] = $val->toArray();
                } elseif ($val !== null) {
                    $array[$key] = $val;
                }
            }
        }

The 2 properties for java_enabled et javascript_enabled are name with "isJavascriptEnabled" and "isJavaEnabled", so the result of these 2 functions are not parsed... and the requestOrder failed with DSP2...

So the fix must be :

  • change the isJavaEnabled & isJavascriptEnabled to getJavaEnabled & getJavascriptEnabled
  • or do a in_array with ['get','is'] for the substr

CardTokenPaymentMethod class is assigned to PaymentMethod attribute in OrderRequest

Hi,

The documentation tells us to do the following :

$paymentMethod = new \HiPay\Fullservice\Gateway\Request\PaymentMethod\CardTokenPaymentMethod();   
$paymentMethod->cardtoken = "61f92d7a135db52dbd583b2aad208e73978196392357f674bacf39f549042f14";
$paymentMethod->eci = 7;
$paymentMethod->authentication_indicator = 0;
 
$orderRequest->paymentMethod = $paymentMethod;

But I get an error from psalm, which seems to be right :

$orderRequest->paymentMethod with declared type HiPay\Fullservice\Gateway\Model\PaymentMethod cannot be assigned type HiPay\Fullservice\Gateway\Request\PaymentMethod\CardTokenPaymentMethod

Can we avoid this error ? Maybe it's a bug ?

Regards,

Undefined index: msisdn

Somewhere exists data mismatch (either api either lib), which causes undefined index.
Here is the sample of requestOrderTransactionInformation endpoint response

{
    "transaction": {
        ....
        "order": {
            ....
            "shippingAddress": {
                "firstname": "",
                "lastname": "",
                "streetAddress": "",
                "locality": "",
                "postalCode": "",
                "country": ""
            },

and PersonalInformationMapper object source visual:
image

stacktrace:

#0 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Gateway/Mapper/PersonalInformationMapper.php(51): Symfony\Component\Debug\ErrorHandler->handleError(8, 'Undefined index...', '/var/www/applic...', 51, Array)
#1 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Mapper/AbstractMapper.php(74): HiPay\Fullservice\Gateway\Mapper\PersonalInformationMapper->mapResponseToModel()
#2 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Gateway/Mapper/OrderMapper.php(58): HiPay\Fullservice\Mapper\AbstractMapper->getModelObjectMapped()
#3 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Mapper/AbstractMapper.php(74): HiPay\Fullservice\Gateway\Mapper\OrderMapper->mapResponseToModel()
#4 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Gateway/Mapper/TransactionMapper.php(98): HiPay\Fullservice\Mapper\AbstractMapper->getModelObjectMapped()
#5 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Mapper/AbstractMapper.php(74): HiPay\Fullservice\Gateway\Mapper\TransactionMapper->mapResponseToModel()
#6 /var/www/application/hipay-fullservice-sdk-php/lib/HiPay/Fullservice/Gateway/Client/GatewayClient.php(253): HiPay\Fullservice\Mapper\AbstractMapper->getModelObjectMapped()

Bug in comparison

Recently I had to debug, how code works, and something caught my attention:
https://github.com/hipay/hipay-fullservice-sdk-php/blob/master/lib/HiPay/Fullservice/Gateway/Client/GatewayClient.php#L195

        if (!is_null($amount)) {
            if (!is_float($amount) && !($amount > 0.01)) {
                throw new InvalidArgumentException("Amount must be a float type and greater than 0.01");
            } else {
                $maintenanceRequest->amount = $amount;
            }
        }

this condition doesn't work with really invalid values: for example 0.002 https://3v4l.org/17kOX, but exception declares supposed to work.

More over, why $maintenanceRequest->operation = $operationType has no option to be passed within $maintenanceRequest itself like amount, operation_id?

Empty transaction basket

When I get a transaction via the PHP SDK, it doesn't include the basket.

$transactionId = A_TRANSACTION_REFERENCE_HERE;

$config = new Configuration([
    //...
]);

$clientProvider = new SimpleHTTPClient($config);

$gatewayClient = new GatewayClient($clientProvider);

$transaction = $gatewayClient->requestTransactionInformation($transactionId);

$basket = $transaction->getBasket(); // $basket is empty.

If we make direct API call to get the transaction, the basket info is available.

$transactionId = A_TRANSACTION_REFERENCE_HERE;

$url = "https://stage-secure-gateway.hipay-tpp.com/rest/v1/transaction/$transactionId";

$headers = [
    //...
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);

$response = json_decode($response);

print_r($response);

We get the basket:

stdClass Object
(
    [transaction] => stdClass Object
        (
            ...
        )
    [basket] => stdClass Object
        (
            [item] => stdClass Object
                (
                    [type] => good
                    [productReference] => ...
                    [quantity] => ...
                    [unitPrice] => ...
                    [name] => ...
                    [totalAmount] => ...
                )

        )

)

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.