Пример #1
0
 public BitpayRateProvider(Bitpay bitpay)
 {
     if (bitpay == null)
     {
         throw new ArgumentNullException(nameof(bitpay));
     }
     _Bitpay = bitpay;
 }
Пример #2
0
        public void BitpayCheckout()
        {
            var key     = new Key(Encoders.Hex.DecodeData("7b70a06f35562873e3dcb46005ed0fe78e1991ad906e56adaaafa40ba861e056"));
            var url     = new Uri("https://test.bitpay.com/");
            var btcpay  = new Bitpay(key, url);
            var invoice = btcpay.CreateInvoice(new Invoice()
            {
                Price    = 5.0,
                Currency = "USD",
                PosData  = "posData",
                OrderId  = "cdfd8a5f-6928-4c3b-ba9b-ddf438029e73",
                ItemDesc = "Hello from the otherside"
            }, Facade.Merchant);

            // go to invoice.Url
            Console.WriteLine(invoice.Url);
        }
Пример #3
0
        private void EnsureRegisteredKey()
        {
            if (!Directory.Exists(Network.Name))
            {
                Directory.CreateDirectory(Network.Name);
            }

            BitcoinSecret k       = null;
            var           keyFile = Path.Combine(Network.Name, "key.env");

            try
            {
                k = new BitcoinSecret(File.ReadAllText(keyFile), Network);
            }
            catch { }

            if (k != null)
            {
                try
                {
                    Bitpay = new Bitpay(k.PrivateKey, BitPayUri);
                    if (Bitpay.TestAccess(Facade.Merchant))
                    {
                        return;
                    }
                }
                catch { }
            }

            k = k ?? new BitcoinSecret(new Key(), Network);
            File.WriteAllText(keyFile, k.ToString());

            Bitpay = new Bitpay(k.PrivateKey, BitPayUri);
            var pairing = Bitpay.RequestClientAuthorization("test", Facade.Merchant);


            throw new AssertException("You need to approve the test key to access bitpay by going to this link " + pairing.CreateLink(Bitpay.BaseUrl).AbsoluteUri);
        }
Пример #4
0
 public TestAccount(ServerTester parent)
 {
     this.parent = parent;
     BitPay      = new Bitpay(new Key(), parent.PayTester.ServerUri);
 }