Exemplo n.º 1
0
        public void NewPreAuthorizationUrl_ExcOptionalParams_GeneratesCorrectUrl()
        {
            var request = new PreAuthorizationRequest("0190G74E3J", 15m, 1, "month");
            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.NewPreAuthorizationUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/pre_authorizations/new?client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&pre_authorization%5Binterval_length%5D=1&pre_authorization%5Binterval_unit%5D=month&pre_authorization%5Bmax_amount%5D=15.00&pre_authorization%5Bmerchant_id%5D=0190G74E3J&signature=40792b67ff99a474c2db08b870842bd5b3b82003206e4ab003a69860bbb0a30e&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Generate the URL for creating a new pre authorization. The parameters
 /// passed in define various attributes of the pre authorization. Redirecting
 /// a user to the resulting URL will show them a page where they can approve
 /// or reject the pre authorization 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 NewPreAuthorizationUrl(PreAuthorizationRequest requestResource,
     string redirectUri = null, string cancelUri = null, string state = null)
 {
     return GenerateNewLimitUrl("pre_authorization", requestResource, redirectUri, cancelUri, state);
 }
Exemplo n.º 3
0
        public void NewPreAuthorizationUrl_IncOptionalParams_GeneratesCorrectUrl()
        {
            var request = new PreAuthorizationRequest("0190G74E3J", 15m, 1, "month")
                              {
                                  ExpiresAt = new DateTimeOffset(new DateTime(2013, 03, 24, 19, 32, 22)),
                                  Name = "Premium Account",
                                  Description = "Test preauthorization",
                                  IntervalCount = 12,
                                  CalendarIntervals = true,
                                  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.NewPreAuthorizationUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/pre_authorizations/new?client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&pre_authorization%5Bcalendar_intervals%5D=True&pre_authorization%5Bdescription%5D=Test%20preauthorization&pre_authorization%5Bexpires_at%5D=2013-03-24T19%3A32%3A22Z&pre_authorization%5Binterval_count%5D=12&pre_authorization%5Binterval_length%5D=1&pre_authorization%5Binterval_unit%5D=month&pre_authorization%5Bmax_amount%5D=15.00&pre_authorization%5Bmerchant_id%5D=0190G74E3J&pre_authorization%5Bname%5D=Premium%20Account&pre_authorization%5Buser%5D%5Bbilling_address1%5D=Flat%201&pre_authorization%5Buser%5D%5Bbilling_address2%5D=100%20Main%20Street&pre_authorization%5Buser%5D%5Bbilling_county%5D=Countyshire&pre_authorization%5Buser%5D%5Bbilling_postcode%5D=N1%201AB&pre_authorization%5Buser%5D%5Bbilling_town%5D=Townville&pre_authorization%5Buser%5D%5Bemail%5D=john.smith%40example.com&pre_authorization%5Buser%5D%5Bfirst_name%5D=John&pre_authorization%5Buser%5D%5Blast_name%5D=Smith&pre_authorization%5Buser%5D%5Bname%5D=John%20Smith&signature=d28979ca9f0a515b06636777edfaec8c3b80bca6c783517a35ac4ed499a456ff&timestamp=2012-03-21T08%3A55%3A56Z";
            Assert.AreEqual(expected, url);
        }
 /// <summary>
 /// Generate the URL for creating a new pre authorization. The parameters
 /// passed in define various attributes of the pre authorization. Redirecting
 /// a user to the resulting URL will show them a page where they can approve
 /// or reject the pre authorization 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 NewPreAuthorizationUrl(PreAuthorizationRequest requestResource, string redirectUri = null, string cancelUri = null, string state = null)
 {
     return(GenerateNewLimitUrl("pre_authorization", requestResource, redirectUri, cancelUri, state));
 }