public void Init() { // JSON minified with the BitPay configuration as in the required configuration file // and parsed into a IConfiguration object var json = "{\"BitPayConfiguration\":{\"Environment\":\"Test\",\"EnvConfig\":{\"Test\":{\"ClientDescription\":\"" + ClientName + "\",\"ApiUrl\":\"https://test.bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"sec/bitpay_test_private.key\",\"ApiTokens\":{\"pos\":\"FrbBsxHFkoTbzJPDe6vzBghJzMvDe1nbGUJ3M6n5MHQd\",\"merchant\":\"EZYmyjSaUXh6NcF7Ej9g7dizhhsW2eRvWT29W6CG1omT\",\"payroll\":\"DjyLfN2JDeFoHgUV9Xpx3kvLpA5G2emiyFxUv1q9CREt\"}},\"Prod\":{\"ClientDescription\":\"\",\"ApiUrl\":\"https://bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"\",\"ApiTokens\":{\"pos\":\"\",\"merchant\":\"\",\"payroll\":\"\"}}}}}"; var memoryJsonFile = new MemoryFileInfo("config.json", Encoding.UTF8.GetBytes(json), DateTimeOffset.Now); var memoryFileProvider = new MockFileProvider(memoryJsonFile); var configuration = new ConfigurationBuilder() .AddJsonFile(memoryFileProvider, "config.json", false, false) .Build(); // Initialize the BitPay object to be used in the following tests _bitpay = new BitPay(configuration); // If the client doesn't have a POS token yet, fetch one. // For the Merchant and Payroll Facades, see below, in their corresponding tests if (!_bitpay.tokenExist(Facade.PointOfSale)) { _bitpay.AuthorizeClient(PairingCode); } // ledgers require the Merchant Facade if (!_bitpay.tokenExist(Facade.Merchant)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(Facade.Merchant).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } // ledgers require the Payroll Facade if (!_bitpay.tokenExist(Facade.Payroll)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(Facade.Payroll).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } }
public void Init() { // Initialize the BitPay object to be used in the following tests _bitpay = new BitPay(ClientName, BitpayTestUrl); // If the client doesn't have a POS token yet, fetch one. // For the Merchant and Payroll Facades, see below, in their corresponding tests if (!_bitpay.ClientIsAuthorized(BitPay.FacadePos)) { _bitpay.AuthorizeClient(PairingCode).Wait(); } // ledgers require the Merchant Facade if (!_bitpay.ClientIsAuthorized(BitPay.FacadeMerchant)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(BitPay.FacadeMerchant).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } // ledgers require the Payroll Facade if (!_bitpay.ClientIsAuthorized(BitPay.FacadePayroll)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(BitPay.FacadePayroll).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } }
// Will store one of the generated invoices during the test // so it can be paid manually in order to pass the ledger tests public Tests() { // JSON minified with the BitPay configuration as in the required configuration file // and parsed into a IConfiguration object var json = "{\"BitPayConfiguration\":{\"Environment\":\"Test\",\"EnvConfig\":{\"Test\":{\"ClientDescription\":\"Net_test\",\"ApiUrl\":\"https://test.bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"bitpay_private_test.key\",\"ApiTokens\":{\"pos\":\"AvJdGrEqTW9HVsJit9zabAnrJabqaQDhWHRacHYgfgxK\",\"merchant\":\"CE2WRSEEt9FgXvXboxNFA4YdQyyDJmgVAo752TGA7eUj\",\"payroll\":\"9pJ7fzW1GGeuDQfj32aNATCDnyY6YAacVMcDrs7HHUNo\"}},\"Prod\":{\"ClientDescription\":\"\",\"ApiUrl\":\"https://bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"\",\"ApiTokens\":{\"pos\":\"\",\"merchant\":\"\",\"payroll\":\"\"}}}}}"; var memoryJsonFile = new MemoryFileInfo("config.json", Encoding.UTF8.GetBytes(json), DateTimeOffset.Now); var memoryFileProvider = new MockFileProvider(memoryJsonFile); var configuration = new ConfigurationBuilder() .AddJsonFile(memoryFileProvider, "config.json", false, false) .Build(); // Initialize the BitPay object to be used in the following tests // Initialize with IConfiguration object // _bitpay = new BitPay(configuration); // Initialize with separate variables _bitpay = new BitPay( Env.Test, "bitpay_private_test.key", new Env.Tokens() { POS = "AvJdGrEqTW9HVsJit9zabAnrJabqaQDhWHRacHYgfgxK", Merchant = "CE2WRSEEt9FgXvXboxNFA4YdQyyDJmgVAo752TGA7eUj", Payout = "9pJ7fzW1GGeuDQfj32aNATCDnyY6YAacVMcDrs7HHUNo" } ); // If the client doesn't have a POS token yet, fetch one. // For the Merchant and Payroll Facades, see below, in their corresponding tests if (!_bitpay.tokenExist(Facade.PointOfSale)) { _bitpay.AuthorizeClient(PairingCode); } // ledgers require the Merchant Facade if (!_bitpay.tokenExist(Facade.Merchant)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(Facade.Merchant).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } // ledgers require the Payroll Facade if (!_bitpay.tokenExist(Facade.Payroll)) { // get a pairing code for the merchant facade for this client var pcode = _bitpay.RequestClientAuthorization(Facade.Payroll).Result; /* We can't continue. Please make sure you write down this pairing code, then goto * your BitPay account in the API Tokens section * https://test.bitpay.com/dashboard/merchant/api-tokens * and paste it into the search field. * It should get you to a page to approve it. After you approve it, run the tests * again and they should pass. */ throw new BitPayException("Please approve the pairing code " + pcode + " in your account."); } }