feat: add CreditCall transaction status streaming
This commit is contained in:
@@ -25,6 +25,10 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
public TaskCompletionSource<Dictionary<string, string>> TransactionCompletionSource { get; set; }
|
||||
|
||||
internal readonly TransactionProgressTap Progress = new TransactionProgressTap();
|
||||
|
||||
public void SuppressUncertainProgress() { Progress.Suppress(); }
|
||||
|
||||
private volatile bool voiceReferralRequired;
|
||||
private volatile bool voiceReferralDone;
|
||||
private readonly bool saveReceipt;
|
||||
@@ -241,11 +245,13 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
parameters.Add(GetExtraParams("StartTransaction"));
|
||||
Console.WriteLine(parameters.ToString());
|
||||
Progress.Begin(reference);
|
||||
Response response = chipDnaClientLib.StartTransaction(parameters);
|
||||
|
||||
string errors;
|
||||
if (response.GetValue(ParameterKeys.Errors, out errors) && !string.IsNullOrEmpty(errors))
|
||||
{
|
||||
Progress.StartFailed(errors);
|
||||
var result = new Dictionary<string, string>
|
||||
{
|
||||
{ ParameterKeys.Errors, errors },
|
||||
@@ -1301,6 +1307,7 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
private void ChipDnaClientLibOnTransactionFinished(object sender, EventParameters transactionFinishedEventArgs)
|
||||
{
|
||||
Progress.End();
|
||||
var result = new Dictionary<string, string>();
|
||||
var transactionFinishedStringBuilder = new StringBuilder();
|
||||
transactionFinishedStringBuilder.Append("Transaction Finished Event Parameters: ");
|
||||
@@ -1371,6 +1378,7 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
private void ChipDnaClientLibOnSignatureVerificationRequested(object sender, EventParameters signatureVerificationRequestedEventArgs)
|
||||
{
|
||||
Progress.Report("SIGNATURE", signatureVerificationRequestedEventArgs);
|
||||
var transactionFinishedStringBuilder = new StringBuilder();
|
||||
transactionFinishedStringBuilder.Append("Signature Verification Requested Event Parameters: ");
|
||||
string reference = null;
|
||||
@@ -1426,17 +1434,20 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
private void ChipDnaClientLibOnTransactionPause(object sender, EventParameters transactionPauseEventArgs)
|
||||
{
|
||||
Progress.Report("PAUSE", transactionPauseEventArgs);
|
||||
Console.WriteLine("Transaction Pause Event Parameters: {0}{1} *Waiting For Continue Command --> Press 'L' To Continue*",
|
||||
transactionPauseEventArgs, "\n");
|
||||
}
|
||||
|
||||
private void ChipDnaClientLibOnTransactionUpdate(object sender, EventParameters transactionUpdateEventArgs)
|
||||
{
|
||||
Progress.Report("UPDATE", transactionUpdateEventArgs);
|
||||
Console.WriteLine("Transaction Update Event Parameters: {0}", transactionUpdateEventArgs);
|
||||
}
|
||||
|
||||
private void ChipDnaClientLibOnCardNotification(object sender, EventParameters cardNotificationEventArgs)
|
||||
{
|
||||
Progress.Report("CARD_STATUS", cardNotificationEventArgs);
|
||||
Console.WriteLine("Card Notification Event Parameters: {0}", cardNotificationEventArgs);
|
||||
}
|
||||
|
||||
@@ -1507,6 +1518,7 @@ namespace Creditcall.ChipDna.Client
|
||||
|
||||
private void ChipDnaClientLibOnErrorEvent(object sender, ClientHelperErrorEventArgs errorEventArgs)
|
||||
{
|
||||
Progress.SuppressIfActive();
|
||||
var result = new Dictionary<string, string>
|
||||
{
|
||||
{ ParameterKeys.Errors, errorEventArgs.RaisedException.Message}
|
||||
|
||||
Reference in New Issue
Block a user