Пример #1
0
            /// <summary>
            /// Make reversal/void a payment.
            /// </summary>
            /// <param name="amount">The amount.</param>
            /// <param name="currency">The currency.</param>
            /// <param name="paymentPropertiesXml">The payment properties of the authorization response.</param>
            /// <param name="extensionTransactionProperties">Optional extension transaction properties.</param>
            /// <returns>A task that can await until the void has completed.</returns>
            public virtual async Task <PaymentInfo> VoidPaymentAsync(decimal amount, string currency, string paymentPropertiesXml, ExtensionTransaction extensionTransactionProperties)
            {
                PaymentProperty[] properties = CardPaymentManager.ToLocalProperties(paymentPropertiesXml);

                try
                {
                    return(await this.paymentDevice.VoidPaymentAsync(amount, currency, properties, extensionTransactionProperties));
                }
                catch (PaymentException paymentException)
                {
                    // When payment is already voided, treat it as success.
                    if (paymentException.PaymentSdkErrors != null &&
                        paymentException.PaymentSdkErrors.Count == 1 &&
                        paymentException.PaymentSdkErrors[0].Code == ErrorCode.AuthorizationIsVoided)
                    {
                        PaymentInfo paymentInfo = new PaymentInfo();
                        paymentInfo.IsApproved = true;

                        return(await Task.FromResult <PaymentInfo>(paymentInfo));
                    }
                    else
                    {
                        throw paymentException;
                    }
                }
            }
Пример #2
0
 /// <summary>
 ///  Begins the transaction.
 /// </summary>
 /// <param name="paymentConnectorName">The payment connector name for the peripheral device.</param>
 /// <param name="merchantPaymentPropertiesXml">The merchant provider payment properties for the peripheral device.</param>
 /// <param name="invoiceNumber">The invoice number associated with the transaction (6 characters long).</param>
 /// <param name="isTestMode">Is test mode for payments enabled for the peripheral device.</param>
 /// <returns>A task that can be awaited until the begin transaction screen is displayed.</returns>
 public virtual async Task BeginTransactionAsync(string paymentConnectorName, string merchantPaymentPropertiesXml, string invoiceNumber, bool isTestMode)
 {
     await this.Execute(async() =>
     {
         // Get the payment connector properties
         PaymentProperty[] merchantProperties = CardPaymentManager.ToLocalProperties(merchantPaymentPropertiesXml);
         await this.paymentDevice.BeginTransactionAsync(merchantProperties, paymentConnectorName, invoiceNumber, isTestMode);
     });
 }