コード例 #1
0
        public void Should_Initialize_CheckoutForm()
        {
            string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            InitializeCheckoutFormRequest request = new InitializeCheckoutFormRequest
            {
                Locale   = Locale.TR.ToString(),
                Customer = new CheckoutFormCustomer
                {
                    Email          = $"iyzico-{randomString}@iyzico.com",
                    Name           = "customer-name",
                    Surname        = "customer-surname",
                    BillingAddress = new Address
                    {
                        City        = "İstanbul",
                        Country     = "Türkiye",
                        Description = "billing-address-description",
                        ContactName = "billing-contact-name",
                        ZipCode     = "010101"
                    },
                    ShippingAddress = new Address
                    {
                        City        = "İstanbul",
                        Country     = "Türkiye",
                        Description = "shipping-address-description",
                        ContactName = "shipping-contact-name",
                        ZipCode     = "010102"
                    },
                    GsmNumber      = "+905350000000",
                    IdentityNumber = "55555555555",
                },
                CallbackUrl               = "https://www.google.com",
                ConversationId            = "123456789",
                PricingPlanReferenceCode  = "pricingPlanReferenceCode",
                SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString()
            };

            CheckoutFormResource response = Subscription.InitializeCheckoutForm(request, options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.IsNotNull(response.CheckoutFormContent);
            Assert.IsNotNull(response.Token);
            Assert.IsNotNull(response.TokenExpireTime);
            Assert.Null(response.ErrorMessage);
        }
コード例 #2
0
        public void Should_Initialize_CheckoutForm()
        {
            string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            CreateProductRequest createProductRequest = new CreateProductRequest
            {
                Description    = "product-description",
                Locale         = Locale.TR.ToString(),
                Name           = $"product-name-{randomString}",
                ConversationId = "123456789"
            };

            ResponseData <ProductResource> createProductResponse = Product.Create(createProductRequest, _options);

            CreatePlanRequest createPlanRequest = new CreatePlanRequest()
            {
                Locale               = Locale.TR.ToString(),
                Name                 = $"plan-name-{randomString}",
                ConversationId       = "123456789",
                TrialPeriodDays      = 3,
                Price                = "5.23",
                CurrencyCode         = Currency.TRY.ToString(),
                PaymentInterval      = PaymentInterval.WEEKLY.ToString(),
                RecurrenceCount      = 12,
                PaymentIntervalCount = 1,
                PlanPaymentType      = PlanPaymentType.RECURRING.ToString(),
                ProductReferenceCode = createProductResponse.Data.ReferenceCode
            };

            PlanResource planResource = Plan.Create(createPlanRequest, _options).Data;

            InitializeCheckoutFormRequest request = new InitializeCheckoutFormRequest
            {
                Locale   = Locale.TR.ToString(),
                Customer = new CheckoutFormCustomer
                {
                    Email          = $"iyzico-{randomString}@iyzico.com",
                    Name           = "customer-name",
                    Surname        = "customer-surname",
                    BillingAddress = new Address
                    {
                        City        = "İstanbul",
                        Country     = "Türkiye",
                        Description = "billing-address-description",
                        ContactName = "billing-contact-name",
                        ZipCode     = "010101"
                    },
                    ShippingAddress = new Address
                    {
                        City        = "İstanbul",
                        Country     = "Türkiye",
                        Description = "shipping-address-description",
                        ContactName = "shipping-contact-name",
                        ZipCode     = "010102"
                    },
                    GsmNumber      = "+905350000000",
                    IdentityNumber = "55555555555",
                },
                CallbackUrl               = "https://www.google.com",
                ConversationId            = "123456789",
                PricingPlanReferenceCode  = planResource.ReferenceCode,
                SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString()
            };

            CheckoutFormResource response = Subscription.InitializeCheckoutForm(request, _options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.IsNotNull(response.CheckoutFormContent);
            Assert.IsNotNull(response.Token);
            Assert.IsNotNull(response.TokenExpireTime);
            Assert.Null(response.ErrorMessage);
        }
コード例 #3
0
        public static CheckoutFormResource InitializeCheckoutForm(InitializeCheckoutFormRequest request, Options options)
        {
            string uri = $"{options.BaseUrl}/v2/subscription/checkoutform/initialize";

            return(RestHttpClientV2.Create().Post <CheckoutFormResource>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request));
        }