Пример #1
0
        public virtual void PopulateForm(MultipartForm form)
        {
            foreach (var propInfo in GetType().GetRuntimeProperties())
            {
                var fieldName = string.Format("{0}{1}", Prefix, propInfo.Name);

                var value = propInfo.GetValue(this);
                if (value == null)
                {
                    form.Set(fieldName, DefaultForType(propInfo));
                }
                else
                {
                    if (value is Enum)
                    {
                        var description = value.GetType().GetRuntimeField(value.ToString()).GetCustomAttribute <DescriptionAttribute>();
                        form.Set(fieldName, description?.Description);
                    }
                    else
                    {
                        form.Set(fieldName, value.ToString());
                    }
                }
            }
        }
Пример #2
0
        public string Call(string endpoint, MultipartForm content)
        {
            content.Set("locID", LocationId);
            content.Set("token", SecurityToken);
            content.Set("sessionID", SessionId);

            try {
                var response = SendRequest(endpoint, content.Content);
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    //TODO: add some error handling here
                }
                return(response.RawResponse);
            }
            catch (GatewayException) {
                throw;
            }
            catch (Exception exc) {
                throw new GatewayException(exc.Message, exc);
            }
        }
Пример #3
0
        internal MultipartForm BuildForm()
        {
            var form = new MultipartForm(false);

            PopulateForm(form, MerchantInfo);
            if (LegalInfoSameAsMerchant)
            {
                LegalInfo = new LegalInfo {
                    CorporateName         = MerchantInfo?.MerchantDbaName,
                    CorporateStreet       = MerchantInfo?.MerchantStreet,
                    CorporateCity         = MerchantInfo?.MerchantCity,
                    CorporateStatesSelect = MerchantInfo?.MerchantStatesSelect,
                    CorporateZip          = MerchantInfo?.MerchantZip
                };
            }
            PopulateForm(form, LegalInfo);
            PopulateForm(form, BusinessInfo);

            // OPTIONALS
            Headquarters?.PopulateForm(form);
            SalesMethods?.PopulateForm(form);
            ProcessingMethod?.PopulateForm(form);
            FutureDeliveryInfo?.PopulateForm(form);
            GolfIndustry?.PopulateForm(form);
            SalonIndustry?.PopulateForm(form);
            LodgingResortInfo?.PopulateForm(form);
            TransactionInfo?.PopulateForm(form);
            EquipmentInfo?.PopulateForm(form);
            ShippingOptions?.PopulateForm(form);
            DepositOptions?.PopulateForm(form);
            StatementOptions?.PopulateForm(form);
            DisputeOptions?.PopulateForm(form);

            // owners/officers
            for (int i = 0; i < 10; i++)
            {
                OwnerOfficer owner = new OwnerOfficer();
                if (i < OwnerOfficers.Count)
                {
                    owner = OwnerOfficers[i];
                }

                owner.Prefix = string.Format("OwnerOfficer{0}_", i + 1);
                PopulateForm(form, owner);

                // signers
                form.Set(string.Format("Signer{0}Email", i + 1), owner.EmailAddress ?? " ");
                form.Set(string.Format("Signer{0}FullName", i + 1), owner.FullName ?? " ");
            }

            // banking info
            PopulateForm(form, BankingInfo);
            if (BankingInfo != null)
            {
                foreach (var account in BankingInfo.BankAccounts)
                {
                    account.Prefix = string.Format("MerchantAccount{0}_", BankingInfo.BankAccounts.IndexOf(account) + 1);
                    account.PopulateForm(form);
                }
            }

            return(form);
        }