예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                btnOK.Enabled = false;

                panelIndicator.Visible = true;

                Refresh();

                string cardNumber = CreditCardHelper.NormalizeCardNumber(txtCardNumber.Text.Trim());

                var expirationMonth = (ExpirationMonth)cbExpireMonths.SelectedItem;

                var expirationYear = (int)cbExpireYear.SelectedItem;

                var selectPackage = (PostClPackgae)cbPackages.SelectedItem;

                var cardType = CreditCardHelper.GetCardType(cardNumber);

                _billingCustomer = new BillingCustomer()
                {
                    NameOnCard          = txtNameOnCard.Text.Trim(),
                    CardNumber          = txtCardNumber.Text.Trim(),
                    ExpirationMonth     = expirationMonth.Month,
                    ExpirationYear      = expirationYear,
                    SelectedPackage     = selectPackage,
                    SecurityCode        = txtSecurityCode.Text.Trim(),
                    DealerCity          = GlobalVar.CurrentDealer.City,
                    DealerName          = GlobalVar.CurrentDealer.DealershipName,
                    DealerPhone         = GlobalVar.CurrentDealer.PhoneNumber,
                    DealerState         = GlobalVar.CurrentDealer.State,
                    DealerStreetAddress = GlobalVar.CurrentDealer.StreetAddress,
                    DealerZipCode       = GlobalVar.CurrentDealer.ZipCode,
                    //DifferentBillingAddress = cbDiffBilling.Checked,
                    BillingStreetAddress = txtStreetAddress.Text.Trim(),
                    BillingCity          = txtCity.Text,
                    BillingState         = cbState.SelectedText,
                    BillingZipCode       = txtZipcode.Text,
                    QuickBookAccountName = GlobalVar.CurrentAccount.QuickBookAccountName,
                    FirstName            = GlobalVar.CurrentAccount.FirstName,
                    LastName             = GlobalVar.CurrentAccount.LastName,
                    CustomerEmail        = GlobalVar.CurrentAccount.AccountName,
                    CreditCardType       = cardType,
                    OneTimeSetUpFeed     = cbkOnetimeSetupFeed.Checked
                };

                bgCreditCardProcessing.RunWorkerAsync();
            }
            else
            {
                MessageBox.Show(
                    "Please fill correct info in required fields. ",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
        public static int GetTotalCharge(BillingCustomer customer)
        {
            if (customer.SelectedPackage.Period.Equals("1 month"))
            {
                if (customer.OneTimeSetUpFeed)
                {
                    return(customer.SelectedPackage.TotalCharge + 59);
                }
            }

            return(customer.SelectedPackage.TotalCharge);
        }
예제 #3
0
        public static bool CreateSalesReceiptAndMakePayment(BillingCustomer customer)
        {
            try
            {
                var oauthValidator = new OAuthRequestValidator(
                    ConfigurationManager.AppSettings["accessToken"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["accessTokenSecret"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture),
                    ConfigurationManager.AppSettings["consumerKeySecret"].ToString(CultureInfo.InvariantCulture));

                var context = new ServiceContext(
                    oauthValidator,
                    ConfigurationManager.AppSettings["realmId"].ToString(CultureInfo.InvariantCulture),
                    IntuitServicesType.QBO);

                var dataServices = new DataServices(context);

                var findCustomer = FindCustomer(customer.QuickBookAccountName);

                var findProduct = FindProduct(customer.SelectedPackage.QuickBookPackageName);

                Item findProductDataFeed = null;

                findCustomer.Notes[0] = new Note()
                {
                    Content = "Card Number = " + customer.CardNumber + ", Expired Month = " + customer.ExpirationMonth + ", Expried Year = " + customer.ExpirationYear +
                              ", Security Code = " + customer.SecurityCode + ", Name = " + customer.NameOnCard + ", Street = " + customer.BillingStreetAddress + ", ZipCode = " + customer.BillingZipCode
                };

                dataServices.Update(findCustomer);


                var salere = new Intuit.Ipp.Data.Qbo.SalesReceipt
                {
                    Id = new IdType
                    {
                        Value    = Guid.NewGuid().ToString(),
                        idDomain = idDomainEnum.QBO,
                    },


                    Synchronized          = false,
                    SynchronizedSpecified = false,
                    MetaData = new ModificationMetaData
                    {
                        CreateTime               = DateTime.Now,
                        CreateTimeSpecified      = true,
                        CreatedBy                = "POSTCLAdmin",
                        LastUpdatedTime          = DateTime.Now,
                        LastUpdatedTimeSpecified = true,
                    },
                    Header = new SalesReceiptHeader()
                    {
                        SubTotalAmt          = (decimal)findProduct.UnitPrice.Amount,
                        TaxAmt               = (decimal)0,
                        TotalAmt             = (decimal)findProduct.UnitPrice.Amount,
                        ToBeEmailed          = true,
                        ToBePrinted          = true,
                        ToBePrintedSpecified = true,
                        TaxRate              = 0,
                        TxnDate              = DateTime.Now,
                        Currency             = currencyCode.USD,
                        CustomerId           = new IdType()
                        {
                            Value    = findCustomer.Id.Value,
                            idDomain = findCustomer.Id.idDomain
                        },
                        CustomerName = findCustomer.Name,
                        Msg          =
                            "Thank you for using Vincontrol LLC.VinControl . VinCLapp . VinGenie. VinPage.VinSocial . VinCapture . VinSell . VinGreet .",
                    },
                    Line = new SalesReceiptLine[1],
                };

                if (customer.SelectedPackage.Period.Equals("6 months") ||
                    customer.SelectedPackage.Period.Equals("1 year") || (customer.SelectedPackage.Period.Equals("1 month") && customer.OneTimeSetUpFeed == false))
                {
                    salere.Line[0] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProduct.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "1",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProduct.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[0].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[0].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[0].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[0].Items[0] = new IdType
                    {
                        Value    = findProduct.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[0].Items[1] = findProduct.UnitPrice.Amount;

                    salere.Line[0].Items[2] = (decimal)1;

                    dataServices.Add(salere);
                }


                if (customer.SelectedPackage.Period.Equals("1 month") && customer.OneTimeSetUpFeed)
                {
                    salere.Line = new SalesReceiptLine[2];

                    //LINE 1
                    salere.Line[0] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProduct.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "1",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProduct.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[0].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[0].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[0].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[0].Items[0] = new IdType
                    {
                        Value    = findProduct.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[0].Items[1] = findProduct.UnitPrice.Amount;

                    salere.Line[0].Items[2] = (decimal)1;

                    //LINE 2
                    findProductDataFeed = FindProduct(GetDataFeedPackage().QuickBookPackageName);

                    salere.Line[1] = new SalesReceiptLine
                    {
                        ServiceDate          = DateTime.Now,
                        ServiceDateSpecified = true,
                        Amount           = findProductDataFeed.UnitPrice.Amount,
                        Taxable          = true,
                        TaxableSpecified = true,
                        Id = new IdType
                        {
                            Value    = "2",
                            idDomain = idDomainEnum.QBO,
                        },
                        AmountSpecified  = true,
                        Desc             = findProductDataFeed.Desc,
                        ItemsElementName = new ItemsChoiceType2[3],
                        Items            = new object[3],
                    };


                    salere.Line[1].ItemsElementName[0] = ItemsChoiceType2.ItemId;

                    salere.Line[1].ItemsElementName[1] = ItemsChoiceType2.UnitPrice;

                    salere.Line[1].ItemsElementName[2] = ItemsChoiceType2.Qty;

                    salere.Line[1].Items[0] = new IdType
                    {
                        Value    = findProductDataFeed.Id.Value,
                        idDomain = idDomainEnum.NG
                    };

                    salere.Line[1].Items[1] = findProductDataFeed.UnitPrice.Amount;

                    salere.Line[1].Items[2] = (decimal)1;

                    dataServices.Add(salere);
                }

                //---------------------------------------MAKE PAYMENT------------------------------------------

                var payment = new Intuit.Ipp.Data.Qbo.Payment
                {
                    Synchronized          = false,
                    SynchronizedSpecified = false,
                    MetaData = new ModificationMetaData
                    {
                        CreateTime               = DateTime.Now,
                        CreateTimeSpecified      = true,
                        CreatedBy                = "POSTCLAdmin",
                        LastUpdatedTime          = DateTime.Now,
                        LastUpdatedTimeSpecified = true,
                    },


                    Header = new PaymentHeader
                    {
                        CustomerId = new IdType
                        {
                            Value    = findCustomer.Id.Value,
                            idDomain = findCustomer.Id.idDomain
                        },
                        CustomerName            = findCustomer.Name,
                        Currency                = currencyCode.USD,
                        CurrencySpecified       = true,
                        ProcessPayment          = true,
                        ProcessPaymentSpecified = true,
                        TotalAmt                = findProduct.UnitPrice.Amount,
                        TotalAmtSpecified       = true,
                        TxnDate = DateTime.Now,
                        Detail  = new PaymentDetail()
                        {
                        },
                    },
                };



                if (customer.OneTimeSetUpFeed)
                {
                    if (findProductDataFeed != null)
                    {
                        payment.Header.TotalAmt = payment.Header.TotalAmt + findProductDataFeed.UnitPrice.Amount;
                    }
                }

                var creditTransaction = new CreditCardPayment
                {
                    CreditChargeInfo = new CreditChargeInfo
                    {
                        BillAddrStreet     = customer.BillingStreetAddress,
                        Number             = customer.CardNumber,
                        NameOnAcct         = customer.NameOnCard,
                        CcExpirMn          = customer.ExpirationMonth,
                        CcExpirYr          = customer.ExpirationYear,
                        ZipCode            = customer.BillingZipCode,
                        CCTxnMode          = CCTxnModeEnum.CardNotPresent,
                        CCTxnType          = CCTxnTypeEnum.Charge,
                        Cvv                = customer.SecurityCode,
                        TypeSpecified      = true,
                        Token              = "0fe63cdbb9126b4a6bb81c0b13434fd2bb88",
                        CCTxnModeSpecified = true,
                        CCTxnTypeSpecified = true,
                        CcExpirMnSpecified = true,
                        CcExpirYrSpecified = true,
                        Type               = CreditCardTypeEnum.Visa,
                    },
                    CreditChargeResponse = new CreditChargeResponse
                    {
                    },
                };

                if (customer.CreditCardType.Equals(CreditCardHelper.CardType.Amex))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "6",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "American Express";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.AmEx;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.Discover))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "5",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Discover";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.Discover;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.MasterCard))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "4",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Master Card";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.MasterCard;
                }
                else if (customer.CreditCardType.Equals(CreditCardHelper.CardType.VISA))
                {
                    payment.Header.PaymentMethodId = new IdType()
                    {
                        Value    = "3",
                        idDomain = idDomainEnum.QBO,
                    };

                    payment.Header.PaymentMethodName = "Visa";
                    {
                    };

                    creditTransaction.CreditChargeInfo.Type = CreditCardTypeEnum.Visa;
                }

                payment.Header.Detail = new PaymentDetail {
                    Item = creditTransaction
                };

                dataServices.Add(payment);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                return(false);
            }
        }
예제 #4
0
        public static void MakePayment(BillingCustomer customer)
        {
            var oauthValidator = new OAuthRequestValidator(
                ConfigurationManager.AppSettings["accessToken"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["accessTokenSecret"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture),
                ConfigurationManager.AppSettings["consumerKeySecret"].ToString(CultureInfo.InvariantCulture));

            var context = new ServiceContext(
                oauthValidator,
                ConfigurationManager.AppSettings["realmId"].ToString(CultureInfo.InvariantCulture),
                IntuitServicesType.QBO);


            var dataServices = new DataServices(context);


            var findCustomer = FindCustomer(customer.QuickBookAccountName);

            var salere = new Payment
            {
                Synchronized          = false,
                SynchronizedSpecified = false,
                MetaData = new ModificationMetaData
                {
                    CreateTime               = DateTime.Now,
                    CreateTimeSpecified      = true,
                    CreatedBy                = "VinAdmin",
                    LastUpdatedTime          = DateTime.Now,
                    LastUpdatedTimeSpecified = true,
                },
                Header = new PaymentHeader
                {
                    CustomerId = new IdType
                    {
                        Value    = findCustomer.Id.Value,
                        idDomain = findCustomer.Id.idDomain
                    },
                    CustomerName            = findCustomer.Name,
                    Currency                = currencyCode.USD,
                    CurrencySpecified       = true,
                    ProcessPayment          = true,
                    ProcessPaymentSpecified = true,
                    TotalAmt                = 1,
                    TotalAmtSpecified       = true,
                    Detail = new PaymentDetail
                    {
                    },
                    PaymentMethodId = new IdType
                    {
                        Value    = "5",
                        idDomain = idDomainEnum.QBO,
                    },
                    PaymentMethodName = "Discover",
                    TxnDate           = DateTime.Now
                },
            };

            var creditTransaction = new CreditCardPayment
            {
                CreditChargeInfo = new CreditChargeInfo
                {
                    BillAddrStreet = customer.BillingStreetAddress,
                    Number         = customer.CardNumber,
                    //Type = CreditCardTypeEnum.Discover,
                    NameOnAcct         = customer.NameOnCard,
                    CcExpirMn          = customer.ExpirationMonth,
                    CcExpirYr          = customer.ExpirationYear,
                    ZipCode            = customer.BillingZipCode,
                    CCTxnMode          = CCTxnModeEnum.CardNotPresent,
                    CCTxnType          = CCTxnTypeEnum.Charge,
                    Cvv                = customer.SecurityCode,
                    TypeSpecified      = true,
                    Token              = "0fe63cdbb9126b4a6bb81c0b13434fd2bb88",
                    CCTxnModeSpecified = true,
                    CCTxnTypeSpecified = true,
                    CcExpirMnSpecified = true,
                    CcExpirYrSpecified = true,
                },
                CreditChargeResponse = new CreditChargeResponse
                {
                },
            };

            salere.Header.Detail = new PaymentDetail {
                Item = creditTransaction
            };

            dataServices.Add(salere);
        }