예제 #1
0
        /// <summary>
        /// Recharge of crypto balance
        /// It is with this resource that we carry out a recharge of balance on the buyer's card with the seller's cryptocurrencies.
        /// The checkin feature is used when we want to recharge cryptocurrency from A (seller) to B (buyer).
        /// A checkin has a monetary value in currency (amount), acronym for currency (currency),
        /// blockchain for transaction (blockchain), card number (pan),
        /// seller's administrative password (password) and vendor identifier (vendorKey)
        /// </summary>
        /// <param name="rechargeCryptoBalance"></param>
        /// <returns></returns>
        public Checkout RechargeCryptoBalance(RechargeCryptoBalance rechargeCryptoBalance)
        {
            try
            {
                //Convert to Sha256
                rechargeCryptoBalance.pan      = Converts.ComputeSha256Hash(rechargeCryptoBalance.pan);
                rechargeCryptoBalance.password = Converts.ComputeSha256Hash(rechargeCryptoBalance.password);

                string urlBase = this.SandBox ? GlobalType.URL_BASE_SANDBOX : GlobalType.URL_BASE_DEFAULT;

                string strJson = JsonConvert.SerializeObject(rechargeCryptoBalance);

                byte[] buffer = Encoding.UTF8.GetBytes(strJson);

                HttpWebRequest httpWebRequest = HttpWebRequest.CreateHttp(urlBase + GlobalType.URL_CHECKOUT);
                httpWebRequest.Method        = "POST";
                httpWebRequest.Accept        = "application/json";
                httpWebRequest.ContentType   = "application/json";
                httpWebRequest.ContentLength = buffer.Length;
                httpWebRequest.GetRequestStream().Write(buffer, 0, buffer.Length);

                using (HttpWebResponse objResponse = httpWebRequest.GetResponse() as HttpWebResponse)
                {
                    using (StreamReader strReader = new StreamReader(objResponse.GetResponseStream()))
                        return(JsonConvert.DeserializeObject <Checkout>(strReader.ReadToEnd()));
                }
            }
            catch (Exception ex)
            {
                return(new Checkout()
                {
                    status = new Status()
                    {
                        code = "-1", message = ex.Message
                    }
                });
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            ApusPaymentsAPI apusPaymentsAPI = new ApusPaymentsAPI(EnviromentType.SandBox);

            string pan      = "9999999999999999";
            string password = "******";

            string vendorKey      = "5f5bdaed-f82b-4b82-b3f5-1d562633da5b";
            string vendorPassword = "******";

            // Make a payment
            MakePayment makePayment = new MakePayment();

            makePayment.pan        = pan;
            makePayment.password   = password;
            makePayment.blockchain = BlockChainType.LTC;
            makePayment.amount     = 13.88;
            makePayment.currency   = CurrencyType.BRL;
            makePayment.vendorKey  = vendorKey;

            var makePaymentReturn = apusPaymentsAPI.MakePayment(makePayment);

            Console.WriteLine("MakePayment: " + JsonConvert.SerializeObject(makePaymentReturn));
            Console.WriteLine("");

            // Make a recurring payment
            MakeRecurringPayment makeRecurringPayment = new MakeRecurringPayment();

            makeRecurringPayment.pan        = pan;
            makeRecurringPayment.password   = password;
            makeRecurringPayment.blockchain = BlockChainType.LTC;
            makeRecurringPayment.amount     = 13.88;
            makeRecurringPayment.currency   = CurrencyType.BRL;
            makeRecurringPayment.period     = PeriodType.M;
            makeRecurringPayment.vendorKey  = vendorKey;

            var makeRecurringPaymentReturn = apusPaymentsAPI.MakeRecurringPayment(makeRecurringPayment);

            Console.WriteLine("Make a Recurring Payment: " + JsonConvert.SerializeObject(makeRecurringPaymentReturn));
            Console.WriteLine("");

            // Search payment
            SearchPayment searchPayment = new SearchPayment();

            searchPayment.vendorKey      = vendorKey;
            searchPayment.txId           = "";
            searchPayment.timestamp      = "";
            searchPayment.blockchain     = BlockChainType.LTC;
            searchPayment.currency       = CurrencyType.BRL;
            searchPayment.coinAmount     = "";
            searchPayment.currencyAmount = "";
            searchPayment.buyer          = "";

            var searchPaymentReturn = apusPaymentsAPI.SearchPayment(searchPayment);

            Console.WriteLine("Search Payment: " + JsonConvert.SerializeObject(searchPaymentReturn));
            Console.WriteLine("");

            // Cancel
            CancelPayment cancelPayment = new CancelPayment();

            cancelPayment.txId      = "2bf779e2a311c2629df977b0bb105879411fd71f5839972c4ed1d3278f80170f";
            cancelPayment.password  = vendorPassword;
            cancelPayment.vendorKey = vendorKey;

            var cancelPaymentReturn = apusPaymentsAPI.CancelPayment(cancelPayment);

            Console.WriteLine("Cancel a Payment: " + JsonConvert.SerializeObject(cancelPaymentReturn));
            Console.WriteLine("");

            RechargeCryptoBalance rechargeCryptoBalance = new RechargeCryptoBalance();

            rechargeCryptoBalance.pan        = pan;
            rechargeCryptoBalance.password   = password;
            rechargeCryptoBalance.blockchain = BlockChainType.LTC;
            rechargeCryptoBalance.amount     = 13.88;
            rechargeCryptoBalance.currency   = CurrencyType.BRL;
            rechargeCryptoBalance.vendorKey  = vendorKey;

            var rechargeCryptoBalanceReturn = apusPaymentsAPI.RechargeCryptoBalance(rechargeCryptoBalance);

            Console.WriteLine("Recharge of Crypto Balance: " + JsonConvert.SerializeObject(rechargeCryptoBalanceReturn));
            Console.WriteLine("");

            Console.ReadKey();
        }