CyberSource / cybersource-rest-client-php

PHP client library for the CyberSource REST API
29 stars 65 forks source link

Capture Context fails if masking enabled #94

Open omerida opened 2 years ago

omerida commented 2 years ago

\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.

omerida commented 2 years ago

This happens if you follow cybersource-flex-samples-php generatekey.php/[php-microform] example.

The correct way to do this is not pass in a bare array but instead call it like this:

    $keyRequest = new GeneratePublicKeyRequest([
        "encryptionType" => "RsaOaep256",
        "targetOrigin" => $targetOrigin,
    ]);
    // Generating Flex .11 capture context 
       $keyResponse = $api_instance->generatePublicKey($format = 'JWT', $keyRequest);