generateCheckMerchantFormData method

Map<String, dynamic> generateCheckMerchantFormData(
  1. PaywayPartnerCheckMerchant requestData, {
  2. String? requestTime,
})

generateCheckMerchantFormData

allow to pre generate the correct data for form submit when send create request check merchant info

Example

request_time: 20200211050440

request_data: a/lHnhQ9Sa4zf9feh9TeVUExcEPiztzyjZd0aoWay+98lPXgNRbDBt42qi4wy2wGIPKWTif4Ha6kkrrmhDq5tVtdADCjP0DOJFassV4cehXuZHfWuFXXUymmCFk0n+C26YliIDLEv0y03t7bRHusBi6YbW/O05pyIk5LOVi0ybA=

partner_id: /GHeWRMQa2l9H1+TkclWuw==

hash: 43bde1fdf5b631897172a956c029aa24b57679f75b5ed9a56a10b1b6d799dbb1

Implementation

Map<String, dynamic> generateCheckMerchantFormData(
    PaywayPartnerCheckMerchant requestData,
    {String? requestTime}) {
  final request_data =
      opensslEncrypt(requestData.toMap(), partner.partnerPublicKey);

  final _requestTime =
      requestTime ?? DateFormat("yMddhhmmss").format(DateTime.now());
  if (_requestTime.length != 14) {
    print("_requestTime $_requestTime");
  }

  /// show the error if incorrect request time format size
  assert(_requestTime.length == 14);

  final clientService = PaywayPartnerClientService(partner);
  final str = clientService.getStr(
      request_time: _requestTime, request_data: request_data);
  final hash = clientService.getHash(str);

  var map = {
    "request_time": _requestTime.toString(),
    "request_data": request_data.toString(),
    "partner_id": partner.partnerID.toString(),
    "hash": hash.toString(),
  };
  return map;
}