/// <summary> /// Verifies the given invoice. /// </summary> /// <param name="onlinePayment"></param> /// <param name="invoice"></param> /// <exception cref="InvoiceNotFoundException"></exception> public static IPaymentVerifyResult Verify(this IOnlinePayment onlinePayment, IPaymentFetchResult invoice) { if (invoice == null) { throw new ArgumentNullException(nameof(invoice)); } return(onlinePayment.VerifyAsync(invoice.TrackingNumber).GetAwaiter().GetResult()); }
/// <summary> /// Cancels the given invoice. No Verifying request will be sent to the gateway. /// </summary> /// <param name="onlinePayment"></param> /// <param name="invoice"></param> /// <param name="cancellationReason">The reason for canceling the operation. It will be saved in Message field in database.</param> /// <exception cref="InvoiceNotFoundException"></exception> public static IPaymentCancelResult Cancel( this IOnlinePayment onlinePayment, IPaymentFetchResult invoice, string cancellationReason = null) { if (invoice == null) { throw new ArgumentNullException(nameof(invoice)); } return(onlinePayment.CancelAsync(invoice.TrackingNumber, cancellationReason).GetAwaiter().GetResult()); }
/// <summary> /// Verifies the given invoice. /// </summary> /// <param name="onlinePayment"></param> /// <param name="invoice"></param> /// <param name="cancellationToken"></param> /// <exception cref="InvoiceNotFoundException"></exception> public static Task <IPaymentVerifyResult> VerifyAsync( this IOnlinePayment onlinePayment, IPaymentFetchResult invoice, CancellationToken cancellationToken = default) { if (invoice == null) { throw new ArgumentNullException(nameof(invoice)); } return(onlinePayment.VerifyAsync(invoice.TrackingNumber, cancellationToken)); }
/// <summary> /// Cancels the given invoice. No Verifying request will be sent to the gateway. /// </summary> /// <param name="onlinePayment"></param> /// <param name="invoice"></param> /// <param name="cancellationReason">The reason for canceling the operation. It will be saved in Message field in database.</param> /// <param name="cancellationToken"></param> /// <exception cref="InvoiceNotFoundException"></exception> public static Task <IPaymentCancelResult> CancelAsync( this IOnlinePayment onlinePayment, IPaymentFetchResult invoice, string cancellationReason = null, CancellationToken cancellationToken = default) { if (invoice == null) { throw new ArgumentNullException(nameof(invoice)); } return(onlinePayment.CancelAsync(invoice.TrackingNumber, cancellationReason, cancellationToken)); }
public static void OnFetchResult( IPaymentFetchResult result, long expectedTrackingNumber, decimal expectedAmount, string expectedGatewayName) { Assert.IsNotNull(result); AssertFailWhenResultIsNotSucceed(result); Assert.IsTrue(result.IsSucceed); Assert.AreEqual(PaymentFetchResultStatus.ReadyForVerifying, result.Status); Assert.AreEqual(expectedTrackingNumber, result.TrackingNumber); Assert.AreEqual(expectedGatewayName, result.GatewayName); Assert.AreEqual(GatewayAccount.DefaultName, result.GatewayAccountName); Assert.AreEqual(result.Amount, expectedAmount); Assert.IsFalse(result.IsAlreadyVerified); }
public override Task <IPaymentFetchResult> FetchAsync(InvoiceContext context, CancellationToken cancellationToken = default) { IPaymentFetchResult result = PaymentFetchResult.ReadyForVerifying(); return(Task.FromResult(result)); }