Ejemplo n.º 1
0
        /*
         *  POST {{ServerURL}}/WebCheckout/CreateSession/
         *  H Content-Type: application/json
         *  {
         *      "Key": "{{Token}}",
         *      "Local": "He",
         *      "UniqueId": "#100",
         *      "SuccessUrl": "{{SuccessUrl}}",
         *      "CallbackUrl": "{{CallbackUrl}}",
         *      "PaymentType": "regular",
         *      "CreateInvoice": false,
         *      "AdditionalText": "some extra details",
         *      "ShowCart": true,
         *      "Installments": {
         *          "Type": "regular",
         *          "MinQuantity": 1,
         *          "MaxQuantity": 5
         *      },
         *      "Customer": {
         *          "Email": "*****@*****.**",
         *          "Name": "RcBuilder",
         *          "PhoneNumber": ""
         *      },
         *      "CartItems": [
         *          {
         *              "Amount": 10,
         *              "Currency": "ILS",
         *              "Name": "Item 1",
         *              "Description": "bla bla bla",
         *              "Quantity": 1,
         *              "IsTaxFree": false
         *          }
         *      ]
         *  }
         */
        public ZCreditCreateSessionResponse CreateSession(ZCreditCreateSessionRequest Request)
        {
            try
            {
                var session = ZCreditSession.Clone(Request);
                session.Key         = this.Token;
                session.CallbackUrl = this.NotifyURL;
                session.SuccessUrl  = this.SuccessURL;
                session.CancelUrl   = this.CancelURL;

                using (var client = new WebClient())
                {
                    client.Proxy    = null;
                    client.Encoding = Encoding.UTF8;

                    client.Headers.Clear();
                    client.Headers.Add("Accept", "*/*");
                    client.Headers.Add("Content-Type", "application/json");

                    var response = client.UploadString(CREATE_SESSION_ENDPOINT, JsonConvert.SerializeObject(session));
                    return(JsonConvert.DeserializeObject <ZCreditCreateSessionResponse>(response));
                }
            }
            catch (Exception Ex) {
                return(new ZCreditCreateSessionResponse
                {
                });
            }
        }
Ejemplo n.º 2
0
        public static ZCreditSession Clone(ZCreditCreateSessionRequest Source)
        {
            var serialized = JsonConvert.SerializeObject(Source);
            var clone      = JsonConvert.DeserializeObject <ZCreditSession>(serialized);

            return(clone);
        }