Exemplo n.º 1
0
        public void NewBillUrl_IncOptionalParams_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 15m)
                              {
                                  Name = "Premium Account",
                                  Description = "Test payment",
                                  User = new UserRequest
                                             {
                                                 Name = "John Smith",
                                                 FirstName = "John",
                                                 LastName = "Smith",
                                                 Email = "*****@*****.**",
                                                 BillingAddress1 = "Flat 1",
                                                 BillingAddress2 = "100 Main Street",
                                                 BillingTown = "Townville",
                                                 BillingCounty = "Countyshire",
                                                 BillingPostcode = "N1 1AB",
                                             }
                              };
            GoCardless.Environment = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=15.00&bill%5Bdescription%5D=Test%20payment&bill%5Bmerchant_id%5D=0190G74E3J&bill%5Bname%5D=Premium%20Account&bill%5Buser%5D%5Bbilling_address1%5D=Flat%201&bill%5Buser%5D%5Bbilling_address2%5D=100%20Main%20Street&bill%5Buser%5D%5Bbilling_county%5D=Countyshire&bill%5Buser%5D%5Bbilling_postcode%5D=N1%201AB&bill%5Buser%5D%5Bbilling_town%5D=Townville&bill%5Buser%5D%5Bemail%5D=john.smith%40example.com&bill%5Buser%5D%5Bfirst_name%5D=John&bill%5Buser%5D%5Blast_name%5D=Smith&bill%5Buser%5D%5Bname%5D=John%20Smith&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=7534d0255bb20d8ca38255c9861431f65ffb1625be9c6d0f338624f3b2c7b9b5&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
Exemplo n.º 2
0
        public void NewBillUrl_GreaterThan1000_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 1000m);
            GoCardless.Environment = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=1000.00&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=d65039ed59c227bcfa96e3bc1b3d42562a11806db57086509fba17c0028b3f76&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
Exemplo n.º 3
0
        public void NewBillUrl_ExcOptionalParams_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 15m);
            GoCardless.Environment = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=15.00&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=bab27ff9111e292286d207e68722a00a3d8a36d1cf69fb4d094b4443998283b1&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
        public void NewBillUrl_UkrainianCulture_GeneratesCorrectUrl()
        {
            // test Ukrainian culture, where numbers are formatted 0,00
            Thread.CurrentThread.CurrentCulture = new CultureInfo("uk-UA");

            var request = new BillRequest("0190G74E3J", 10.45m);
            GoCardless.Environment = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=10.45&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=2b67e51028b69a67f0f08c67282386ec625a9b78ebc1936c786602897c52f268&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Generate the URL for creating a new bill. The parameters passed in define
 /// various attributes of the bill. Redirecting a user to the resulting URL
 /// will show them a page where they can approve or reject the bill described
 /// by the parameters. Note that this method automatically includes the
 /// nonce, timestamp and signature.
 /// </summary>
 /// <param name="requestResource">the request values</param>
 /// <param name="redirectUri">optional override URI on success</param>
 /// <param name="cancelUri">optional override URI on cancel</param>
 /// <param name="state">optional state, gets passed back with the successful payload</param>
 /// <returns>the generated URL</returns>
 public string NewBillUrl(BillRequest requestResource,
     string redirectUri = null, string cancelUri = null, string state = null)
 {
     return GenerateNewLimitUrl("bill", requestResource, redirectUri, cancelUri, state);
 }
 /// <summary>
 /// Generate the URL for creating a new bill. The parameters passed in define
 /// various attributes of the bill. Redirecting a user to the resulting URL
 /// will show them a page where they can approve or reject the bill described
 /// by the parameters. Note that this method automatically includes the
 /// nonce, timestamp and signature.
 /// </summary>
 /// <param name="requestResource">the request values</param>
 /// <param name="redirectUri">optional override URI on success</param>
 /// <param name="cancelUri">optional override URI on cancel</param>
 /// <param name="state">optional state, gets passed back with the successful payload</param>
 /// <returns>the generated URL</returns>
 public string NewBillUrl(BillRequest requestResource, string redirectUri = null, string cancelUri = null, string state = null)
 {
     return(GenerateNewLimitUrl("bill", requestResource, redirectUri, cancelUri, state));
 }