protected void FinalizeOrUpdateOrder(Order order, Invoice invoice)
        {
            var amount       = CentsToDollars(invoice.AmountDue);
            var paymentState = invoice.Paid ? PaymentState.Captured : PaymentState.Authorized;

            if (!order.IsFinalized)
            {
                order.Finalize(amount, invoice.Id, paymentState);
            }
            else if (order.TransactionInformation.PaymentState != paymentState)
            {
                var currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                order.TransactionInformation.AmountAuthorized = new Amount(amount, currency);
                order.TransactionInformation.TransactionId    = invoice.Id;
                order.TransactionInformation.PaymentState     = paymentState;
                order.Save();
            }
        }
        protected void FinalizeOrUpdateOrder(Order order, PaymentIntent paymentIntent)
        {
            var amount        = CentsToDollars(paymentIntent.Amount.Value);
            var transactionId = GetTransactionId(paymentIntent);
            var paymentState  = GetPaymentState(paymentIntent);

            if (!order.IsFinalized && (paymentState == PaymentState.Authorized || paymentState == PaymentState.Captured))
            {
                order.Finalize(amount, transactionId, paymentState);
            }
            else
            {
                var currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                order.TransactionInformation.AmountAuthorized = new Amount(amount, currency);
                order.TransactionInformation.TransactionId    = transactionId;
                order.TransactionInformation.PaymentState     = paymentState;
                order.Save();
            }
        }