public void Should_Activate_Subscription()
        {
            ActivateSubscriptionRequest request = new ActivateSubscriptionRequest
            {
                Locale                    = Locale.TR.ToString(),
                ConversationId            = "123456789",
                SubscriptionReferenceCode = "subscriptionReferenceCode"
            };

            IyzipayResourceV2 response = Subscription.Activate(request, options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
        }
Esempio n. 2
0
        public void Should_Activate_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 subscriptionInitializeRequest = 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,
                SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString()
            };

            ResponseData <SubscriptionCreatedResource> initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options);

            ActivateSubscriptionRequest request = new ActivateSubscriptionRequest
            {
                Locale                    = Locale.TR.ToString(),
                ConversationId            = "123456789",
                SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode
            };

            IyzipayResourceV2 response = Subscription.Activate(request, _options);

            PrintResponse(response);

            Assert.AreEqual(Status.SUCCESS.ToString(), response.Status);
            Assert.IsNotNull(response.SystemTime);
            Assert.Null(response.ErrorMessage);
        }
Esempio n. 3
0
        public static IyzipayResourceV2 Activate(ActivateSubscriptionRequest request, Options options)
        {
            string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/activate";

            return(RestHttpClientV2.Create().Post <IyzipayResourceV2>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request));
        }
Esempio n. 4
0
        public static ESNStatusDoc[] ActivateSubscription(List <ESNInfo> lstESNInfo)
        {
            List <ESNStatusDoc> lstESNDoc = new List <ESNStatusDoc>();

            try
            {
                // wssService.activa
                wssService.wsMessageHeader = getHeader();
                SecurityHelper.prepareSoapContext(wssService.RequestSoapContext);
                ESNStatusDoc doc = null;
                foreach (ESNInfo info in lstESNInfo)
                {
                    try
                    {
                        ActivateSubscriptionRequest request = new ActivateSubscriptionRequest();
                        request.csa                    = info.CSA;
                        request.effectiveDate          = DateTime.Now;
                        request.effectiveDateSpecified = true;
                        ProductDeployment deployment = new ProductDeployment();
                        deployment.serviceCode = "321PLAN2";
                        deployment.serviceEffectiveDateSpecified  = false;
                        deployment.serviceExpirationDateSpecified = false;
                        request.pricePlan = deployment;
                        ElectronicSerialNumber number = new ElectronicSerialNumber();
                        number.Item            = info.ESN;
                        number.ItemElementName = ItemChoiceType.electronicSerialNumberDec;
                        SerialNumber number2 = new SerialNumber();
                        number2.Item = number;
                        request.esn  = number2;
                        List <ProductDeployment> list = new List <ProductDeployment>();

                        var dt = DataLayer_WholesaleSubscriptionDetailService.GetPpSocList(info.CSA);

                        if (info.LocalCallOnly)
                        {
                            var soc = from r in dt.AsEnumerable()
                                      where r.Field <string>("socDescription") == "LOCAL CALLING ONLY"
                                      select r.Field <string>("soc");

                            ProductDeployment item = new ProductDeployment();
                            item.serviceCode                    = soc.FirstOrDefault().ToString();
                            item.serviceEffectiveDate           = DateTime.Now;
                            item.serviceEffectiveDateSpecified  = true;
                            item.serviceExpirationDateSpecified = false;
                            list.Add(item);
                        }
                        if (info.SMSBlock)
                        {
                            var soc = from r in dt.AsEnumerable()
                                      where r.Field <string>("socDescription") == "MO/MT SMS BLOCKING"
                                      select r.Field <string>("soc");

                            ProductDeployment deployment3 = new ProductDeployment();
                            deployment3.serviceCode                    = soc.FirstOrDefault().ToString();
                            deployment3.serviceEffectiveDate           = DateTime.Now;
                            deployment3.serviceEffectiveDateSpecified  = true;
                            deployment3.serviceExpirationDateSpecified = false;
                            list.Add(deployment3);
                        }
                        if (info.VoiceMail)
                        {
                            var soc = from r in dt.AsEnumerable()
                                      where r.Field <string>("socDescription") == "VOICEMAIL"
                                      select r.Field <string>("soc");

                            ProductDeployment deployment4 = new ProductDeployment();
                            deployment4.serviceCode                    = soc.FirstOrDefault().ToString();
                            deployment4.serviceEffectiveDate           = DateTime.Now;
                            deployment4.serviceEffectiveDateSpecified  = true;
                            deployment4.serviceExpirationDateSpecified = false;
                            list.Add(deployment4);
                        }

                        if (list.Count > 0)
                        {
                            request.serviceList = list.ToArray();
                        }
                        ActivateSubscriptionReply reply = wssService.ActivateSubscription(request);

                        info.MDN  = reply.mdn;
                        info.MSID = reply.msid;

                        doc           = new ESNStatusDoc();
                        doc.ESN       = info.ESN;
                        doc.MDN       = info.MDN;
                        doc.MSID      = info.MSID;
                        doc.ESNStatus = ESNSTATUSENUM.SUCCEEDED;
                        doc.Message   = "Activated";
                        lstESNDoc.Add(doc);
                    }
                    catch (System.Web.Services.Protocols.SoapException soapEx)
                    {
                        doc           = new ESNStatusDoc();
                        doc.ESN       = info.ESN;
                        doc.ESNStatus = ESNSTATUSENUM.FAILED;
                        doc.Message   = soapEx.Detail.InnerText;
                        lstESNDoc.Add(doc);
                    }
                }
                return(lstESNDoc.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }