Exemple #1
0
        /// <summary>
        /// Executes processing of the amex auth request.
        /// </summary>
        public ResultCode Execute()
        {
            ResultCode result = ResultCode.None;
            SharedAuthorizationLogic sharedAuthorizationLogic = new SharedAuthorizationLogic(Context, CommerceOperationsFactory.AuthorizationOperations(Context));
            Authorization            authorization            = new Authorization();

            Context[Key.Authorization] = authorization;
            Amex amex = new Amex(Context);

            amex.MarshalAuthorization();
            result = sharedAuthorizationLogic.AddAuthorization();

            // Build the response to send back to Amex based on the result of adding the Authorization.
            Context[Key.ResultCode] = result;
            amex.BuildAuthorizationResponse();
            if (result == ResultCode.Created)
            {
                Context.Log.Verbose("Authorization successfully persisted, now send notification");

                // Send notification.
                NotifyAuthorization notifyAuthorization = new NotifyAuthorization(Context);
                Context[Key.CardBrand] = CardBrand.AmericanExpress;
                notifyAuthorization.SendNotification();
                Context.Log.Verbose("Authorization notification sent");
            }

            return(result);
        }
        /// <summary>
        /// Executes processing of the authorization event info.
        /// </summary>
        public ResultCode Execute()
        {
            ResultCode result = ResultCode.None;

            SharedAuthorizationLogic sharedAuthorizationLogic = new SharedAuthorizationLogic(Context,
                                                                                             CommerceOperationsFactory.AuthorizationOperations(Context));

            // Marshal MasterCard Authorization request object into partner-agnostic model.
            Authorization authorization = new Authorization();

            Context[Key.Authorization] = authorization;
            MasterCard masterCard = new MasterCard(Context);

            masterCard.MarshalAuthorization();

            // Add the authorization even to the data store.
            result = sharedAuthorizationLogic.AddAuthorization();

            // Build the response to send back to MasterCard based on the result of adding the Authorization.
            Context[Key.ResultCode] = result;
            masterCard.BuildAuthorizationResponse();

            // If the authorization event was successfully committed to the data store, send user notifications.
            if (result == ResultCode.Created)
            {
                Context.Log.Verbose("MasterCard Authorization successfully persisted. Sending notifications asynchronously.");
                NotifyAuthorization notifyAuthorization = new NotifyAuthorization(Context);
                Context[Key.CardBrand] = CardBrand.MasterCard;
                Task.Run(new Action(notifyAuthorization.SendNotification));
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        ///     Executes processing of the request.
        /// </summary>
        public ResultCode Execute()
        {
            ResultCode                  result  = ResultCode.None;
            EndPointMessageRequest      request = (EndPointMessageRequest)Context[Key.Request];
            Dictionary <String, String> messageElementCollectionDictionary = new Dictionary <string, string>();

            foreach (MessageElementsCollection c in request.MessageElementsCollection)
            {
                messageElementCollectionDictionary.Add(c.Key, c.Value);
            }

            String requestType = messageElementCollectionDictionary[VisaEPMConstants.EventEventType];

            if (!string.Equals(requestType, VisaEPMConstants.OnAuthEventTypeValue, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("Wrong request message");
            }

            Dictionary <String, String> userDefinedFieldsCollectionDictionary = new Dictionary <string, string>();

            foreach (UserDefinedFieldsCollection c in request.UserDefinedFieldsCollection)
            {
                userDefinedFieldsCollectionDictionary.Add(c.Key, c.Value);
            }

            String cardId     = request.CardId;
            String merchantId = messageElementCollectionDictionary[VisaEPMConstants.TransactionVisaMerchantId];
            String storeId    = messageElementCollectionDictionary[VisaEPMConstants.TransactionVisaStoreId];

            SharedAuthorizationLogic sharedAuthorizationLogic = new SharedAuthorizationLogic(Context,
                                                                                             CommerceOperationsFactory.AuthorizationOperations(Context));

            Authorization authorization = new Authorization();

            Context[Key.Authorization] = authorization;

            // Populate the Authorization.
            String amount = messageElementCollectionDictionary[VisaEPMConstants.TransactionTransactionAmount];

            authorization.AuthorizationAmount = AmexUtilities.ParseAuthAmount(amount);
            authorization.Currency            = VisaConstants.CurrencyUSD;
            authorization.TransactionScopeId  = messageElementCollectionDictionary[VisaEPMConstants.TransactionVipTransactionId];
            authorization.TransactionId       =
                messageElementCollectionDictionary[VisaEPMConstants.TransactionTransactionID];
            String time = messageElementCollectionDictionary[VisaEPMConstants.TransactionTimeStampYYMMDD];

            // UTC time: 2013-12-05T07:25:06
            authorization.PurchaseDateTime = DateTime.Parse(time);
            authorization.PurchaseDateTime = DateTime.SpecifyKind(authorization.PurchaseDateTime, DateTimeKind.Utc);

            // Populate the Auth Info.
            Context[Key.PartnerCardId]     = cardId;
            Context[Key.PartnerMerchantId] = string.Format("{0};{1}", merchantId, storeId);

            string merchantCity       = messageElementCollectionDictionary.NullIfNotExist(VisaEPMConstants.MerchantCityString);
            string merchantState      = messageElementCollectionDictionary.NullIfNotExist(VisaEPMConstants.MerchantStateString);
            string merchantPostalCode = messageElementCollectionDictionary.NullIfNotExist(VisaEPMConstants.MerchantPostalCodeString);

            KeyTransactionData keyTransactionData = new KeyTransactionData
            {
                MerchantCity       = merchantCity,
                MerchantState      = merchantState,
                MerchantPostalCode = merchantPostalCode
            };

            Context[Key.PartnerData] = keyTransactionData.XmlSerialize();

            LogAuthorizationRequest(authorization, Context);

            result = sharedAuthorizationLogic.AddAuthorization();
            Context[Key.ResultCode] = result;

            if (result == ResultCode.Created)
            {
                // Send notification.
                var notifyAuthorization = new NotifyAuthorization(Context);
                Context[Key.CardBrand] = CardBrand.Visa;
                Task.Run(new Action(notifyAuthorization.SendNotification));
            }
            return(result);
        }