Example #1
0
        /*
         * PAYMENT
         */
        public ChargeModel ChargeCreate(
            string token_card,
            string customer_id,
            string doc_type,
            string doc_number,
            string name,
            string last_name,
            string email,
            string bill,
            string description,
            string value,
            string tax,
            string tax_base,
            string ico,
            string currency,
            string dues,
            string address,
            string phone,
            string cell_phone,
            string url_response,
            string url_confirmation,
            string method_confirmation,
            string ip,
            string extra1            = "N/A",
            string extra2            = "N/A",
            string extra3            = "N/A",
            string extra4            = "N/A",
            string extra5            = "N/A",
            string extra6            = "N/A",
            string extra7            = "N/A",
            string extra8            = "N/A",
            string extra9            = "N/A",
            string extra10           = "N/A",
            SplitModel split_details = null)
        {
            ENDPOINT  = Constants.url_charge;
            PARAMETER = body.getBodyChargeCreate(token_card, customer_id, doc_type, doc_number, name, last_name,
                                                 email, bill, description, value, tax, tax_base, ico, currency, dues, address, phone, cell_phone,
                                                 url_response,
                                                 url_confirmation, method_confirmation, ip, extra1, extra2, extra3, extra4, extra5, extra6, extra7, extra8, extra9, extra10);

            if (split_details != null)
            {
                string split_req_body = body.getBodySplitPayments(split_details, false);
                PARAMETER = Auxiliars.ConcatBodyStrings(PARAMETER, split_req_body);
            }

            string content = _request.Execute(
                ENDPOINT,
                "POST",
                _auxiliars.ConvertToBase64(_PUBLIC_KEY),
                PARAMETER);

            ChargeModel payment = new ChargeModel();

            if (content.Contains("errorMessage"))
            {
                ChargeDataListError response = JsonConvert.DeserializeObject <ChargeDataListError>(content);
                ChargeData          data     = new ChargeData
                {
                    status      = response.data.status,
                    description = response.data.description,
                    errors      = response.data.errors
                };
                payment.status  = response.status;
                payment.message = response.message;
                payment.data    = data;
            }
            else
            {
                payment = JsonConvert.DeserializeObject <ChargeModel>(content);
            }

            return(payment);
        }
Example #2
0
        /*
         * CASH
         */
        public CashModel CashCreate(string type, string invoice,
                                    string description,
                                    string value,
                                    string tax,
                                    string tax_base,
                                    string ico,
                                    string currency,
                                    string type_person,
                                    string doc_type,
                                    string doc_number,
                                    string name,
                                    string last_name,
                                    string email,
                                    string cell_phone,
                                    string end_date,
                                    string url_response,
                                    string url_confirmation,
                                    string method_confirmation,
                                    string extra1            = "N/A",
                                    string extra2            = "N/A",
                                    string extra3            = "N/A",
                                    string extra4            = "N/A",
                                    string extra5            = "N/A",
                                    string extra6            = "N/A",
                                    string extra7            = "N/A",
                                    string extra8            = "N/A",
                                    string extra9            = "N/A",
                                    string extra10           = "N/A",
                                    SplitModel split_details = null)
        {
            CashModel cash;
            string    content;
            CashModel invalid = new CashModel
            {
                success        = false,
                title_response = "Error",
                text_response  = "Método de pago en efectivo no válido, unicamnete soportados: efecty, gana, redservi, puntored, sured",
                last_action    = "validation transaction",
                data           = new DataCash
                {
                    totalerrores = 1,
                    errores      = new List <errors>
                    {
                        new errors
                        {
                            codError     = "109",
                            errorMessage = "Método de pago en efectivo no válido, unicamnete soportados: efecty, gana, redservi, puntored, sured"
                        }
                    }
                }
            };
            string medio = type.ToLower();

            if (medio == "baloto")
            {
                return(invalid);
            }
            bool isCorrect = this.GetEntitiesCash(type);

            if (!isCorrect)
            {
                return(invalid);
            }
            ENDPOINT = Constants.url_cash + type;

            PARAMETER = body.getBodyCashCreate(_auxiliars.ConvertToBase64(IV), _TEST, _PUBLIC_KEY, _PRIVATE_KEY,
                                               invoice, description, value, tax, tax_base, ico, currency, type_person, doc_type, doc_number, name,
                                               last_name, email, cell_phone, end_date, url_response, url_confirmation, method_confirmation, extra1, extra2, extra3, extra4, extra5, extra6, extra7, extra8, extra9, extra10);

            if (split_details != null)
            {
                string split_req_body = body.getBodySplitPayments(split_details, true);
                PARAMETER = Auxiliars.ConcatBodyStrings(PARAMETER, split_req_body);
            }
            content = _restRequest.Execute(
                ENDPOINT,
                "POST",
                _auxiliars.ConvertToBase64(_PUBLIC_KEY),
                PARAMETER);
            cash = JsonConvert.DeserializeObject <CashModel>(content);
            return(cash);
        }