public PaymentCompleteResult Complete(PaymentMethod currentPayment, string orderRef)
        {
            PaymentCompleteResult result = new PaymentCompleteResult() { Success = false }; 
            
            if (currentPayment.RequireAddressUpdate)
            {
                Log.Info("MasterPass is using best practice flow");
                Log.InfoFormat("Finalizing transaction for payment with ID:{0} belonging to order with ID: {1}",
                    currentPayment.Payment.Id, currentPayment.OrderGroupId);
                var total = currentPayment.Cart.Total.RoundToLong();
                var totalVat = currentPayment.Cart.TaxTotal.RoundToLong();
                var finalizeTransactionResult = _paymentManager.FinalizeTransaction(orderRef, total, totalVat,
                    currentPayment.Payment.ClientIpAddress);
                
                if (!finalizeTransactionResult.Success)
                {
                    Log.InfoFormat(
                        "Finalize transaction failed for payment with ID:{0} belonging to order with ID: {1}. Reason ErrorCode: {2} Description: {3}",
                        currentPayment.Payment.Id, currentPayment.OrderGroupId,
                        finalizeTransactionResult.Status.ErrorCode,
                        finalizeTransactionResult.Status.Description);
                    return result;
                }

                Log.InfoFormat(
                    "Successfully called finalize transaction for payment with ID:{0} belonging to order with ID: {1}",
                    currentPayment.Payment.Id, currentPayment.OrderGroupId);
            }
            else
            {
                Log.Info("MasterPass is using redirect flow");
            }

            if (_paymentCompleter != null)
                result = _paymentCompleter.Complete(currentPayment, orderRef);

            return result;
        }
コード例 #2
0
        public PaymentCompleteResult Complete(PaymentMethod currentPayment, string orderRef)
        {
            Log.InfoFormat("Completing payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
            CompleteResult completeResult = _paymentManager.Complete(orderRef);
            if (!completeResult.Success || string.IsNullOrWhiteSpace(completeResult.TransactionNumber))
                return new PaymentCompleteResult { TransactionErrorCode = completeResult.ErrorDetails != null ? completeResult.ErrorDetails.TransactionErrorCode : string.Empty };

            if (completeResult.GetTransactionDetails)
            {
                Log.InfoFormat("Retrieving transaction details for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
                if (_paymentCompleter == null)
                    _paymentCompleter = new UpdateTransactionDetails(null, _paymentManager);
                _paymentCompleter = new UpdateTransactionDetails(_paymentCompleter, _paymentManager);
            }

            _paymentActions.UpdatePaymentInformation(currentPayment, completeResult.TransactionNumber, completeResult.PaymentMethod);

            PaymentCompleteResult result = new PaymentCompleteResult { Success = true };
            if (_paymentCompleter != null)
                result = _paymentCompleter.Complete(currentPayment, orderRef);

            Log.InfoFormat("Successfully completed payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
            return result;
        }