Ejemplo n.º 1
0
        protected void submit(object sender, System.EventArgs e)
        {
            string apiKey        = System.Configuration.ConfigurationManager.AppSettings["ApiKey"];
            string apiSecret     = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"];
            string accountNumber = System.Configuration.ConfigurationManager.AppSettings["accountNumber"];
            int    currencyBaseUnitsMultiplier = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CurrencyBaseUnitsMultiplier"]);

            PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber);
            Authorization    auth   = client.cardPaymentService().authorize(Authorization.Builder()
                                                                            .merchantRefNum(Request.Form["merchant_ref_num"])
                                                                            .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]) * currencyBaseUnitsMultiplier))
                                                                            .settleWithAuth(true)
                                                                            .card()
                                                                            .cardNum(Request.Form["card_number"])
                                                                            .cvv(Request.Form["card_cvv"])
                                                                            .cardExpiry()
                                                                            .month(Convert.ToInt32(Request.Form["card_expiry_month"]))
                                                                            .year(Convert.ToInt32(Request.Form["card_expiry_year"]))
                                                                            .Done()
                                                                            .Done()
                                                                            .billingDetails()
                                                                            .street(Request.Form["street"])
                                                                            .city(Request.Form["city"])
                                                                            .state(Request.Form["state"])
                                                                            .country(Request.Form["country"])
                                                                            .zip(Request.Form["zip"])
                                                                            .Done()
                                                                            .Build());

            this.payment_id = auth.id();
        }
        protected void submit(object sender, System.EventArgs e)
        {
            string apiKey        = System.Configuration.ConfigurationManager.AppSettings["ApiKey"];
            string apiSecret     = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"];
            string accountNumber = System.Configuration.ConfigurationManager.AppSettings["accountNumber"];
            int    currencyBaseUnitsMultiplier = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CurrencyBaseUnitsMultiplier"]);

            PaysafeApiClient client  = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber);
            Profile          profile = client.customerVaultService().create(Profile.Builder()
                                                                            .merchantCustomerId(Request.Form["merchant_customer_id"])
                                                                            .locale("en_US")
                                                                            .firstName(Request.Form["first_name"])
                                                                            .lastName(Request.Form["last_name"])
                                                                            .email(Request.Form["email"])
                                                                            .Build());
            Address address = client.customerVaultService().create(Address.Builder()
                                                                   .nickName("home")
                                                                   .street(Request.Form["street"])
                                                                   .city(Request.Form["city"])
                                                                   .state(Request.Form["state"])
                                                                   .country(Request.Form["country"])
                                                                   .zip(Request.Form["zip"])
                                                                   .profileId(profile.id())
                                                                   .Build());
            Card card = client.customerVaultService().create(Card.Builder()
                                                             .cardNum(Request.Form["card_number"])
                                                             .cardExpiry()
                                                             .month(Convert.ToInt32(Request.Form["card_expiry_month"]))
                                                             .year(Convert.ToInt32(Request.Form["card_expiry_year"]))
                                                             .Done()
                                                             .billingAddressId(address.id())
                                                             .profileId(profile.id())
                                                             .Build());
            Authorization auth = client.cardPaymentService().authorize(Authorization.Builder()
                                                                       .merchantRefNum(Request.Form["merchant_ref_num"])
                                                                       .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]) * currencyBaseUnitsMultiplier))
                                                                       .settleWithAuth(true)
                                                                       .card()
                                                                       .paymentToken(card.paymentToken())
                                                                       .Done()
                                                                       .Build());

            this.payment_id = auth.id();
        }