Skip to content

[Bug]: Unable to decrypt data #821

Description

@ramssessoftpoint

Description

Adyen checkout payment API returns 422 - Unable to decrypt data

Steps to reproduce

I'm using JWE with the x509 to encrypt the card data and sending the encryptedCard property and I'm getting the "Unable to decrypt data" message as response

    $certFile = 'public/adyen/sandbox/X509_cse_cert.pem';
    $certPath = Storage::path($certFile);

    $jwk = JWKFactory::createFromKeyFile(
        $certPath,
        null,
        [
            'alg' => 'RSA-OAEP-256',
            'use' => 'enc',
        ]
    );

    $algManager = new AlgorithmManager([ new RSAOAEP256() ]);
    $contentManager = new AlgorithmManager([ new A256GCM() ]);

    $jweBuilder = new JWEBuilder($algManager, $contentManager);

    $cardData['number'] = "4111111111111111";
    $cardData['cvc'] = "737";
    $cardData['expiryMonth'] = "03";
    $cardData['expiryYear'] = "2030";
    $cardData['generationtime'] = (new DateTime('now'))->format('Y-m-d\TH:i:s.v\Z');

    $jwe = $jweBuilder
        ->create()
        ->withPayload($cardData)
        ->withSharedProtectedHeader([
            'alg' => 'RSA-OAEP-256',
            'enc' => 'A256GCM',
        ])
        ->addRecipient($jwk)
        ->build();

    $serializer = new CompactSerializer();
    $encryptedParams = $serializer->serialize($jwe, 0);
    $payload['paymentMethod']['encryptedCard'] = $encryptedParams;

It actually works when I use the test encryption card data

$payload['paymentMethod']['encryptedCardNumber'] = "test_4111111111111111";

Actual behavior

API return 422 - Unable to decrypt data

Expected behavior

Should be a 200 code with successful payment response

Code snippet or screenshots (if applicable)

No response

Adyen PHP API Library version

28.2.0

PHP version

8.2

Operating System

Linux

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions