public void Should_Initialize_Subscription()
        {
            string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            SubscriptionInitializeRequest request = new SubscriptionInitializeRequest
            {
                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"
                },
                PaymentCard = new CardInfo
                {
                    CardNumber           = "5528790000000008",
                    CardHolderName       = "iyzico",
                    ExpireMonth          = "12",
                    ExpireYear           = "2029",
                    Cvc                  = "123",
                    RegisterConsumerCard = true
                },
                ConversationId           = "123456789",
                PricingPlanReferenceCode = "pricingPlanReferenceCode"
            };

            ResponseData <SubscriptionCreatedResource> response = Subscription.Initialize(request, options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
            Assert.NotNull(response.Data.ReferenceCode);
            Assert.NotNull(response.Data.ParentReferenceCode);
            Assert.AreEqual("pricingPlanReferenceCode", response.Data.PricingPlanReferenceCode);
            Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.SubscriptionStatus);
            Assert.AreEqual(3, response.Data.TrialDays);
            Assert.NotNull(response.Data.TrialStartDate);
            Assert.NotNull(response.Data.TrialEndDate);
            Assert.NotNull(response.Data.StartDate);
        }
예제 #2
0
        public void Should_Initialize_Subscription()
        {
            var meData = DataBase.MEMBER_DATA_GETIR()[0];
            var ad     = "";
            var soyad  = "";
            var ay     = "";
            var yil    = "";

            var ayyilbol = SKT.Text.Split("/");

            ay  = ayyilbol[0];
            yil = "20" + ayyilbol[1];

            var Bol = KartuzerindekiIsim.Text.Split(" ");

            for (int i = 0; i < Bol.Length; i++)
            {
                if (i == Bol.Length - 1)
                {
                    soyad = Bol[i];
                }
                else
                {
                    ad = ad + Bol[i];
                }
            }

            if (ad == "")
            {
                ad = soyad;
            }

            // string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            SubscriptionInitializeRequest request = new SubscriptionInitializeRequest
            {
                Locale   = Locale.TR.ToString(),
                Customer = new CheckoutFormCustomer
                {
                    Email          = meData.email,
                    Name           = ad,
                    Surname        = soyad,
                    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      = "+905415670793",
                    IdentityNumber = meData.id.ToString()
                },
                PaymentCard = new CardInfo
                {
                    CardNumber           = KartNumarasiText.Text.Trim(),
                    CardHolderName       = KartuzerindekiIsim.Text.Trim(),
                    ExpireMonth          = ay,
                    ExpireYear           = yil,
                    Cvc                  = CVC.Text.Trim(),
                    RegisterConsumerCard = true
                },
                ConversationId           = "123456789",
                PricingPlanReferenceCode = OdemePaketleriBaseActivity_Helper.PricingPlanReferenceCode
            };

            response = Subscription.Initialize(request, Contento_Resources_Helper.options);
            var a = response;

            if (response.StatusCode != 200)
            {
                Toast.MakeText(this, response.ErrorMessage, ToastLength.Long).Show();
                //AlertHelper.AlertGoster(response.ErrorMessage, this);
            }
            else
            {
                ShowLoading.Show(this);
                new System.Threading.Thread(new System.Threading.ThreadStart(delegate
                {
                    OdemeGecmisiOlustur();
                })).Start();
            }
        }
예제 #3
0
        public void Should_Initialize_Subscription()
        {
            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;

            SubscriptionInitializeRequest request = new SubscriptionInitializeRequest
            {
                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"
                },
                PaymentCard = new CardInfo
                {
                    CardNumber           = "5528790000000008",
                    CardHolderName       = "iyzico",
                    ExpireMonth          = "12",
                    ExpireYear           = "2029",
                    Cvc                  = "123",
                    RegisterConsumerCard = true
                },
                ConversationId           = "123456789",
                PricingPlanReferenceCode = planResource.ReferenceCode
            };

            ResponseData <SubscriptionCreatedResource> response = Subscription.Initialize(request, _options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
            Assert.NotNull(response.Data.ReferenceCode);
            Assert.NotNull(response.Data.ParentReferenceCode);
            Assert.AreEqual(planResource.ReferenceCode, response.Data.PricingPlanReferenceCode);
            Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.SubscriptionStatus);
            Assert.AreEqual(3, response.Data.TrialDays);
            Assert.NotNull(response.Data.TrialStartDate);
            Assert.NotNull(response.Data.TrialEndDate);
            Assert.NotNull(response.Data.StartDate);
        }
예제 #4
0
        public static ResponseData <SubscriptionCreatedResource> Initialize(SubscriptionInitializeRequest request, Options options)
        {
            string uri = $"{options.BaseUrl}/v2/subscription/initialize";

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