CyberSource / cybersource-inapp-samples-android

Sample application demonstrating the CyberSource Android SDK
MIT License
1 stars 0 forks source link

Code : 1005,"Security Data : UsernameToken authentication failed" #2

Open zdivyesh opened 4 years ago

zdivyesh commented 4 years ago

Screenshot_1584348058

I am facing this issue while encrypting card detail while running this sample.

Any help with this will be appreciated. Thank you.

frantoqui commented 4 years ago

You need to add the SOAP key in the encryption

ravi-python-mss commented 3 years ago

Facing same issue, can you please check? or guide where I need to update what

ratiebareeng commented 3 years ago

You need to add the SOAP key in the encryption

I am using the SOAP transaction key and getting the same error. Any idea what I should use for api_login_id field? as found here: https://github.com/CyberSource/cybersource-android-sdk

ratiebareeng commented 3 years ago

You need to add the SOAP key in the encryption

I am using the SOAP transaction key and getting the same error. Any idea what I should use for api_login_id field? as found here: https://github.com/CyberSource/cybersource-android-sdk

Managed to successfully encrypt card details. The api_login_id is your Merchant ID which you can get from the business center

priya-inx commented 3 years ago

I am getting same error when I am adding amount variable in 'MessageSignature'. I checked out this repo and just performed basic transaction using this code. In the transaction dashboard, I can see the transaction details but not able to see amount and currency. So in the 'generateSignature' method, while creating string 'signatureComponents' I added amount. On clicking 'Encrypt' its giving this Error Code 1005

 ```
    String signatureComponents = stringHmacSha1
            + loginId + transactionObject.getMerchantReferenceCode()   
            + amount    // ----------------- Adding this is giving error 1005 --------------------------------------
            + timeStamp;


Kindly let me know, if this is correct way to see amount in transactions. 
ratiebareeng commented 3 years ago

I am getting same error when I am adding amount variable in 'MessageSignature'. I checked out this repo and just performed basic transaction using this code. In the transaction dashboard, I can see the transaction details but not able to see amount and currency. So in the 'generateSignature' method, while creating string 'signatureComponents' I added amount. On clicking 'Encrypt' its giving this Error Code 1005

String signatureComponents = stringHmacSha1
        + loginId + transactionObject.getMerchantReferenceCode()   
        + amount    // ----------------- Adding this is giving error 1005 --------------------------------------
        + timeStamp;

Kindly let me know, if this is correct way to see amount in transactions.

This is an authentication error. In order to make a successful call to the api you have to generate a signature to sign your call to the api.

After getting user card and billing data, use the inapp sdk to encrypt the user data before passing it to your server for transaction processing, this will help reduce your PCI burden.

To encrypt the data you have to create a message signature (server side) using:

  1. Your soap transaction key, get this from your sandbox/live environment
  2. Merchant ID/API Login Id,
  3. Merchant reference code (this can be any significant string like project name)
  4. UTC timestamp of the transaction.

First create a HMAC-SHA1 of the soap transaction key. Then create a string concatenation of the HMAC-SHA1, your Merchant ID, a Merchant reference code and UTC timestamp:

String signatureComponents = transactionKeySha1 + Merchant Id + Merchant reference code + timestamp;

Next create a HMAC-SHA256 of the signatureComponents String. The result is your message signature.

The MessageSignature class in the inapp sdk samples shows you how to generate the signature in java so you can transform the code to whichever language you need for your server. In my case I did it in PHP.

After generating a signature you can make a call to the api to encrypt card data passing in your signature:

apiClient.performApi(InAppSDKApiClient.Api.API_ENCRYPTION, transactionObject, signature);

If your signature is valid your call will be authenticated and processed.

I hope this helps.

ratiebareeng commented 3 years ago

I am getting same error when I am adding amount variable in 'MessageSignature'. I checked out this repo and just performed basic transaction using this code. In the transaction dashboard, I can see the transaction details but not able to see amount and currency. So in the 'generateSignature' method, while creating string 'signatureComponents' I added amount. On clicking 'Encrypt' its giving this Error Code 1005

String signatureComponents = stringHmacSha1
        + loginId + transactionObject.getMerchantReferenceCode()   
        + amount    // ----------------- Adding this is giving error 1005 --------------------------------------
        + timeStamp;

Kindly let me know, if this is correct way to see amount in transactions.

You don't need to add amount. If you look carefully in the MessageSignature.java, you will see that they did not use amount.