示例#1
0
        public bool DeleteProfile()
        {
            var serviceCtx = new ServiceProcessContext();
            var response   = serviceCtx.Service.DeleteCustomerProfile(serviceCtx.MerchantAuthenticationType, this.ProfileId);

            return(response.resultCode == MessageTypeEnum.Ok);
        }
示例#2
0
        public CIMResponse AuthCapture(Int64 profileId, Int64 paymentProfileId, int orderNumber, decimal amount)
        {
            ServiceProcessContext serviceCtx = new ServiceProcessContext();

            var orderType           = ServiceTools.CreateOrderExType(orderNumber.ToString(), string.Empty, string.Empty);
            var authTransactionType = ServiceTools.CreateProfileTransAuthCaptureType(profileId, paymentProfileId, orderType, amount);
            var transactionType     = ServiceTools.CreateProfileTransactionType(authTransactionType);

            var transactionResponse = serviceCtx.Service.CreateCustomerProfileTransaction(serviceCtx.MerchantAuthenticationType, transactionType, string.Empty);

            Trace.WriteLine(transactionResponse.directResponse);

            foreach (var message in transactionResponse.messages)
            {
                Trace.WriteLine(string.Format("{0}: {1}", message.code, message.text));
            }

            if (transactionResponse.directResponse == null)
            {
                //if directResponse is empty, the first message will say why
                return(new CIMResponse()
                {
                    AuthMessage = transactionResponse.messages[0].text,
                    Success = false
                });
            }
            else
            {
                return(ServiceTools.ParseDirectResponse(transactionResponse.directResponse));
            }
        }
示例#3
0
        public bool UpdateProfile(string newEmail, string profileDescription)
        {
            var serviceCtx = new ServiceProcessContext();

            var customerProfile = ServiceTools.CreateCustomerProfileExType(this.ProfileId, this.CustomerId, newEmail, profileDescription);
            var response        = serviceCtx.Service.UpdateCustomerProfile(serviceCtx.MerchantAuthenticationType, customerProfile);

            return(response.resultCode == MessageTypeEnum.Ok);
        }
示例#4
0
        public CIMResponse UpdatePaymentProfile(long paymentProfileId, CustomerAddressType address, string creditCardNumber, string cardCode, Int32 expMonth, Int32 expYear)
        {
            var serviceCtx = new ServiceProcessContext();

            string expDate            = ServiceTools.GetAuthNetExpirationDate(expMonth, expYear);
            var    paymentType        = ServiceTools.CreatePaymentType(creditCardNumber, cardCode, expDate);
            var    paymentProfileType = ServiceTools.CreatePaymentProfileExType(paymentProfileId, address, paymentType);

            var response = serviceCtx.Service.UpdateCustomerPaymentProfile(serviceCtx.MerchantAuthenticationType, this.ProfileId, paymentProfileType, ValidationMode);

            return(ServiceTools.ParseDirectResponse(response.validationDirectResponse));
        }
示例#5
0
        public CustomerPaymentProfileMaskedType GetPaymentProfile(long paymentProfileId)
        {
            var serviceCtx = new ServiceProcessContext();

            var response = serviceCtx.Service.GetCustomerPaymentProfile(serviceCtx.MerchantAuthenticationType, this.ProfileId, paymentProfileId, false);

            if (response.resultCode == MessageTypeEnum.Error)
            {
                return(null);
            }

            return(response.paymentProfile);
        }
示例#6
0
        public static ProfileManager CreateProfile(int customerId, string email, out string errorMessage)
        {
            errorMessage = string.Empty;

            //force profileDescription to always be the same
            string profileDescription = GetProfileDescription(storeName: string.Empty);
            var    customerProfile    = ServiceTools.CreateCustomerProfileType(customerId, email, profileDescription);

            var serviceCtx = new ServiceProcessContext();
            var response   = serviceCtx.Service.CreateCustomerProfile(serviceCtx.MerchantAuthenticationType, customerProfile, ValidationModeEnum.none);

            ProfileManager profile = null;

            //If we have a duplicate customer record try to delete it and re-create
            //This should solve issues caused by auth.net accounts being switched for the site
            if (response.resultCode == MessageTypeEnum.Error && response.messages[0].code.ToUpper() == "E00039")
            {
                //if we have a duplicate account try to get the account profile from the error message
                string[] strAry = response.messages[0].text.Split(' ');
                foreach (string str in strAry)
                {
                    long custProfId;
                    if (long.TryParse(str, out custProfId))
                    {
                        //if we have an existing profile then delete it and start over
                        profile = new ProfileManager(customerId, email, custProfId);
                        if (profile.DeleteProfile())
                        {
                            response = serviceCtx.Service.CreateCustomerProfile(serviceCtx.MerchantAuthenticationType, customerProfile, ValidationModeEnum.none);
                        }

                        //reset our profile for normal processing below
                        profile = null;
                    }
                }
            }

            if (response.resultCode == MessageTypeEnum.Ok)
            {
                profile = new ProfileManager(customerId, email, response.customerProfileId);
            }
            else if (response.resultCode == MessageTypeEnum.Error)
            {
                errorMessage = response.messages[0].text;
            }

            return(profile);
        }
示例#7
0
        public CIMResponse Capture(Int64 profileId, Int64 paymentProfileId, string authCode, decimal amount)
        {
            ServiceProcessContext serviceCtx = new ServiceProcessContext();

            var profileTransactionType = ServiceTools.CreateProfileTransCaptureOnlyType(profileId, paymentProfileId, authCode, amount);
            var transactionType        = ServiceTools.CreateProfileTransactionType(profileTransactionType);

            var transactionResponse = serviceCtx.Service.CreateCustomerProfileTransaction(serviceCtx.MerchantAuthenticationType, transactionType, string.Empty);

            Trace.WriteLine(transactionResponse.directResponse);

            foreach (var message in transactionResponse.messages)
            {
                Trace.WriteLine(string.Format("{0}: {1}", message.code, message.text));
            }

            return(ServiceTools.ParseDirectResponse(transactionResponse.directResponse));
        }
示例#8
0
        public CIMResponse CreatePaymentProfile(CustomerAddressType address, string creditCardNumber, string cardCode, Int32 expMonth, Int32 expYear)
        {
            var serviceCtx = new ServiceProcessContext();

            string expDate            = ServiceTools.GetAuthNetExpirationDate(expMonth, expYear);
            var    paymentType        = ServiceTools.CreatePaymentType(creditCardNumber, cardCode, expDate);
            var    paymentProfileType = ServiceTools.CreatePaymentProfileType(address, paymentType);

            var response = serviceCtx.Service.CreateCustomerPaymentProfile(serviceCtx.MerchantAuthenticationType, this.ProfileId, paymentProfileType, ValidationMode);

            var retResponse = ServiceTools.ParseDirectResponse(response.validationDirectResponse);

            if (response.resultCode == MessageTypeEnum.Error)
            {
                retResponse.ErrorMessage = response.messages[0].text;
                retResponse.ErrorCode    = response.messages[0].code;
                retResponse.Success      = false;
            }
            retResponse.PaymentProfileId = response.customerPaymentProfileId;
            return(retResponse);
        }