public static object CreateRequestData(Invoice invoice, MelliGatewayOptions options) { var signedData = SignRequestData(options.TerminalId, options.TerminalKey, invoice.TrackingNumber, invoice.Amount); return(new { TerminalId = options.TerminalId, MerchantId = options.MerchantId, Amount = (long)invoice.Amount, SignData = signedData, ReturnUrl = invoice.CallbackUrl, LocalDateTime = DateTime.Now, OrderId = invoice.TrackingNumber }); }
public static MelliCallbackResult CreateCallbackResult(Payment payment, HttpRequest httpRequest, MelliGatewayOptions options, MessagesOptions messagesOptions) { httpRequest.TryGetParamAs <int>("ResCode", out var apiResponseCode); if (apiResponseCode != SuccessCode) { return(new MelliCallbackResult { IsSucceed = false, Result = PaymentVerifyResult.Failed(messagesOptions.PaymentFailed) }); } httpRequest.TryGetParam("Token", out var apiToken); httpRequest.TryGetParamAs <long>("OrderId", out var apiOrderId); if (apiOrderId != payment.TrackingNumber) { return(new MelliCallbackResult { IsSucceed = false, Token = apiToken, Result = PaymentVerifyResult.Failed(messagesOptions.InvalidDataReceivedFromGateway) }); } var signedData = SignVerifyData(options.TerminalKey, apiToken); var dataToVerify = new { token = apiToken, SignData = signedData }; return(new MelliCallbackResult { IsSucceed = true, Token = apiToken, JsonDataToVerify = dataToVerify, Result = null }); }