/// <summary> /// Refer to <see cref="ReversePayment(int)"/>. /// <list type="bullet"> /// <item><term>Callback will return PaymentResult as null if another asyc command is still running.</term></item> /// </list> /// </summary> /// <param name="receiptNumber">Receipt-number of the transaction to be reversed.</param> /// <param name="callback">Callback to be executed when the operation is finished.</param> public void ReversePaymentAsync(int receiptNumber, Action <ZvtPaymentResult, Exception> callback) { if (IsAsyncCommandRunning) { callback?.Invoke(null, null); return; } ZvtPaymentResult result = null; RunCommandWorker(() => result = ReversePayment(receiptNumber), ex => callback?.Invoke(result, ex)); }
/// <summary> /// Refer to <see cref="Pay(uint)"/> /// <list type="bullet"> /// <item><term>Callback will return PaymentResult as null if another asyc command is still running.</term></item> /// </list> /// </summary> /// <param name="amount"></param> /// <param name="callback">Callback to be executed when the operation is finished.</param> public void PayAsync(uint amount, Action <ZvtPaymentResult, Exception> callback) { if (IsAsyncCommandRunning) { callback?.Invoke(null, null); return; } ZvtPaymentResult result = null; RunCommandWorker(() => result = Pay(amount), ex => callback?.Invoke(result, ex)); }
private void Log(ZvtPaymentResult result) { if (result == null) { Log("ZvtPaymentResult is NULL"); return; } Log($"Success: {result.Success}"); Log($"Status: {result.StatusInformation.Status}"); Log($"Status: {result.StatusInformation.PaymentType}"); propertyGrid1.SelectedObject = result.StatusInformation; if (result.ProtocolSpecificErrorCode != null) { Log($"ErrorCode: {result.ProtocolSpecificErrorCode} ErrorDescription: {result.ProtocolSpecificErrorDescription}"); } foreach (var printDocument in result.PrintDocuments) { foreach (var printLine in printDocument.PrintLines) { if (printLine.Commands.Any()) { foreach (var lineCommand in printLine.Commands) { Log(lineCommand.Text); } } else { Log(""); } } } }
private void ReverseAsyncCallback(ZvtPaymentResult result, Exception ex) { Log(result); Log(ex); }