Moustafa Mahmoud
Moustafa Mahmoud

Reputation: 151

hash in Montypay for flutter

After reading this docs I stuck on certain field "hash" how to generate it like the wanted

enter image description here

      String orderNumber = "order-1234";
      String orderAmount = "0.19";
      String orderCurrency = "usd";
      String orderDescription = "Important gift";
      String merchantPass = "merchantPass";
      final inputString =
          '$orderNumber$orderAmount$orderCurrency$orderDescription$merchantPass';
      final utf8Bytes = utf8.encode(inputString);
      final hash = md5.convert(utf8Bytes);
      final hashString = bytesToHex(hash.bytes).toUpperCase();


String bytesToHex(List<int> bytes) {
const hexDigits = '0123456789ABCDEF';
return bytes
    .map((byte) => hexDigits[(byte & 0xff) >> 4] + hexDigits[byte & 0x0f])
    .join('');

}

I'm trying to put hashString in hash field, but every time the response is

{
"error_code": 0,
"error_message": "Request data is invalid.",
"errors": [
    {
        "error_code": 100000,
        "error_message": "hash: Hash is not valid."
    }
]

}

and this from postman

enter image description here

also in collection there is pre request how I can take hash from it enter image description here

Any ideas how to make it in the app?

Upvotes: 0

Views: 102

Answers (2)

Zekra
Zekra

Reputation: 1

you need to Set up and select Environment for Checkout, which contains information on host, keys and hash. Environment settings can be updated manually or by importing JSON-format file. JSON file and/or values (CHECKOUT_HOST, merch1_pass_post, variable_key) are provided by Account manager or created manually in the Merchants section of your dashboard . checkout this pdf:https://montypay.com/Postman-Request-Sending.pdf

Upvotes: 0

Alexander Farkas
Alexander Farkas

Reputation: 698

It should be uppercased first

Example from their docs in PHP: Example from their docs in PHP

Example: Must be SHA1 of MD5 encoded string (uppercased): order_number

  • order_amount + order_currency + order_description + password

Upvotes: 0

Related Questions