private Native.Error handleResult(Mpos mpos, TaskCompletionSource <PaymentResult> source, int err) { if (err != 0) { var result = new PaymentResult(); result.BuildErrored(err); source.SetResult(result); mpos.OnPaymentProcessed(null, err); return(Native.Error.Ok); } mpos.HandlePaymentCallback(err, info).ContinueWith(t => { if (t.Status == TaskStatus.Faulted) { source.SetException(t.Exception); } else { source.SetResult(t.Result); } mpos.OnPaymentProcessed(t.Result, err); }); return(Native.Error.Ok); }