예제 #1
0
        public static bool CreateNewCustomerPaymentProfile(SiteDT site, CustomerDT customer, string cardNumber, string expirationDate, out long paymentProfile, out string message)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            using (ServiceSoapClient client = new ServiceSoapClient())
            {
                paymentProfile = 0;
                message        = string.Empty;

                var merchant = new MerchantAuthenticationType()
                {
                    name           = site.AuthorizeLoginId,
                    transactionKey = site.AuthorizeTransactionKey
                };

                CustomerPaymentProfileType customerPPT = new CustomerPaymentProfileType();
                customerPPT.customerType          = CustomerTypeEnum.individual;
                customerPPT.customerTypeSpecified = true;
                customerPPT.billTo = new CustomerAddressType()
                {
                    firstName = customer.FirstName,
                    lastName  = customer.LastName,
                    address   = customer.Address,
                    city      = customer.City,
                    country   = "USA",
                    state     = customer.StateId,
                    zip       = customer.ZipCode
                };

                CreditCardType ccT = new CreditCardType();
                ccT.cardNumber     = cardNumber;
                ccT.expirationDate = expirationDate;
                ccT.cardCode       = string.Empty;

                PaymentType payment = new PaymentType();
                payment.Item = ccT;

                customerPPT.payment = payment;

                var resp = client.CreateCustomerPaymentProfile(merchant, customer.AuthorizeProfileId, customerPPT, ValidationModeEnum.testMode);

                if (resp.resultCode == MessageTypeEnum.Ok)
                {
                    paymentProfile = resp.customerPaymentProfileId;
                    return(true);
                }
                else
                {
                    message = resp.messages.Select(x => x.code + ": " + x.text).Aggregate((a, b) => a + "\n" + b);
                }

                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Creates the customer payment profile.
        /// </summary>
        /// <param name="profile_id">The profile_id.</param>
        /// <param name="ccNumber">The cc number.</param>
        /// <param name="expire_date">The expire_date.</param>
        /// <returns></returns>
        public static long CreateCustomerPaymentProfile(long profile_id, string ccNumber, string expire_date, string firstName, string lastName, string zipCode)
        {
            long customerPaymentProfileId = 0;

            try
            {
                CustomerPaymentProfileType new_payment_profile = new CustomerPaymentProfileType();
                PaymentType    new_payment = new PaymentType();
                CreditCardType new_card    = new CreditCardType();
                new_card.cardNumber         = ccNumber;
                new_card.expirationDate     = expire_date;
                new_payment.Item            = new_card;
                new_payment_profile.payment = new_payment;
                new_payment_profile.billTo  = new CustomerAddressType
                {
                    firstName = firstName,
                    lastName  = lastName,
                    zip       = zipCode
                };

                CreateCustomerPaymentProfileResponseType response = ServiceSoapClient.CreateCustomerPaymentProfile(MerchantAuthentication, profile_id, new_payment_profile, ValidationModeEnum.testMode);
                customerPaymentProfileId = response.customerPaymentProfileId;

                if (response.resultCode == MessageTypeEnum.Error)
                {
                    throw new Exception(string.Format("Could not create customer payment profile for profile id: {0}.", profile_id));
                }
            }

            catch (Exception ex)
            {
                throw;
            }

            return(customerPaymentProfileId);
        }
예제 #3
0
        public static bool CreateCustomerProfile(SiteDT site, CustomerDT customer, CreditCardDT cc, out long customerProfileId, out long customerPaymentProfileId)
        {
            // if (1 == 0) {
            MerchantAuthenticationType merchantAT = new MerchantAuthenticationType();

            merchantAT.name           = site.AuthorizeLoginId;
            merchantAT.transactionKey = site.AuthorizeTransactionKey;

            CustomerProfileType customerPT = new CustomerProfileType();

            customerPT.merchantCustomerId = customer.Id.ToString();
            customerPT.email           = customer.Email;
            customerPT.paymentProfiles = new CustomerPaymentProfileType[1];

            CustomerPaymentProfileType customerPPT = new CustomerPaymentProfileType();

            customerPPT.customerType          = CustomerTypeEnum.individual;
            customerPPT.customerTypeSpecified = true;
            customerPPT.billTo = new CustomerAddressType()
            {
                firstName = customer.FirstName,
                lastName  = customer.LastName,
                address   = customer.Address,
                city      = customer.City,
                country   = "USA",
                state     = customer.StateId,
                zip       = customer.ZipCode
            };

            CreditCardType ccT = new CreditCardType();

            ccT.cardNumber     = cc.CardNumber;
            ccT.expirationDate = cc.ExpDate;
            ccT.cardCode       = cc.CVV;

            PaymentType payment = new PaymentType();

            payment.Item = ccT;

            customerPPT.payment                  = payment;
            customerPT.paymentProfiles[0]        = customerPPT;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServiceSoapClient client = new ServiceSoapClient();
            CreateCustomerProfileResponseType resp = client.CreateCustomerProfile(merchantAT, customerPT, ValidationModeEnum.testMode);

            customerProfileId        = resp.customerProfileId;
            customerPaymentProfileId = resp.customerPaymentProfileIdList.Length == 1 ? resp.customerPaymentProfileIdList[0] : 0;
            if (resp.resultCode != MessageTypeEnum.Ok)
            {
                string errorValidate = resp.validationDirectResponseList != null && resp.validationDirectResponseList.Count() > 0 ? resp.validationDirectResponseList.ToList().Aggregate((a, b) => a + " || " + b) : string.Empty;
                string error         = resp.messages != null && resp.messages.Count() > 0 ? resp.messages.ToList().Select(a => a.text).Aggregate((a, b) => a + " || " + b) : string.Empty;
                LoggingUtilities.Logger.LogEntry("Resp Error code:" + resp.resultCode.ToString() + ". Errors: " + error + "Error V: " + errorValidate);
            }

            return(resp.resultCode == MessageTypeEnum.Ok);


            /* }
             *
             * else
             * {
             *  customerProfileId = 1;
             *   customerPaymentProfileId = 1;
             *   return true;
             * }*/
        }