Adyen / adyen-cse-web

[DEPRECATED] Client-side encryption on JavaScript
MIT License
15 stars 39 forks source link

Why i get 'false' used in React Native? #56

Closed MoNodin closed 5 years ago

MoNodin commented 7 years ago

source code:
import adyenEncrypt from 'adyen-cse-web'; ...... const cseInstance = adyenEncrypt.createEncryption(PUBLIC_KEY_DEV, options); postData['adyen-encrypted-data'] = cseInstance.encrypt(cardData);

result: Object {adyen-encrypted-data: false}

ArnoudAdyen commented 7 years ago

Hi,

Instead of doing the creation of the encryption and the encryption directly following each other, it is advised to instantiate the encryption object earlier in the flow.

The engine needs time to gather random data . If there is not enough random data the encryption will fail.

Best,

Arnoud

MoNodin commented 7 years ago

Ok,I will check it and then feedback

kbonnin commented 7 years ago

@MoNodin I'm in the exact same spot. Have you find a working solution yet?

Nevermind, my problem was with generationtime I assumed it was a unix timestamp since format was not documented, but looking at the library comments it should be in the same format as new Date().toISOString();

sandor-anyvan commented 7 years ago

We got false result for these cards ( first 6 digit only ) 450875 454742 475117 543698 454742 448952 492181 529932 492181 598824 589433 454142 475121 465359 492181 443273 454638 546946 465904 465942 464154 475129 542011 518991 464941 465859 495944 455638 492942 454617 475129 465922 512687 465858 446261 557349 542011 465859 465902 552157 475130 475141 465848 465859 465941 462910 552157 475130 276367 444447 529930 465861 454313 465858 476242 513652 575129 552157

The cseInstance was built before we try to encrypt. The cseInstance.validate(cardData) returns with number incorrect error. Meanwhile we get processed few of these cards manually without error. Please advise.

chocnut commented 6 years ago

are you guys able to run the library on React Native?

chocnut commented 6 years ago

Anyways, If anyone want this in react-native I just released for react-native https://github.com/chocnut/RNAdyenCse

MoNodin commented 6 years ago

@kbonnin @chocnut @sandor-anyvan

Finally, I resolved it by using the Ayden Native Module created by our team, just like the library given by @chocnut Thank you guy, chocnut.