public static string GenerateFuturePaymentPayPalNonce(BraintreeGateway gateway) { var clientToken = TestHelper.GenerateDecodedClientToken(gateway); var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken); RequestBuilder builder = new RequestBuilder(""); builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint). AddTopLevelElement("shared_customer_identifier_type", "testing"). AddTopLevelElement("shared_customer_identifier", "test-identifier"). AddTopLevelElement("paypal_account[consent_code]", "consent"). AddTopLevelElement("paypal_account[correlation_id]", System.Guid.NewGuid().ToString()). AddTopLevelElement("paypal_account[options][validate]", "false"); HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/paypal_accounts", builder.ToQueryString()); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string responseBody = reader.ReadToEnd(); Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\""); Match match = regex.Match(responseBody); return(match.Groups["nonce"].Value); }
public static string GenerateUnlockedNonce(BraintreeGateway gateway, string creditCardNumber, string customerId) { var clientToken = ""; if (customerId == null) { clientToken = TestHelper.GenerateDecodedClientToken(gateway); } else { clientToken = TestHelper.GenerateDecodedClientToken(gateway, new ClientTokenRequest { CustomerId = customerId } ); } var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken); RequestBuilder builder = new RequestBuilder(""); builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint). AddTopLevelElement("shared_customer_identifier_type", "testing"). AddTopLevelElement("shared_customer_identifier", "test-identifier"). AddTopLevelElement("credit_card[number]", creditCardNumber). AddTopLevelElement("share", "true"). AddTopLevelElement("credit_card[expiration_month]", "11"). AddTopLevelElement("credit_card[expiration_year]", "2099"); HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString()); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string responseBody = reader.ReadToEnd(); Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\""); Match match = regex.Match(responseBody); return(match.Groups["nonce"].Value); }
public static string GenerateFuturePaymentPayPalNonce(BraintreeGateway gateway) { var clientToken = TestHelper.GenerateDecodedClientToken(gateway); var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken); RequestBuilder builder = new RequestBuilder(""); builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint). AddTopLevelElement("shared_customer_identifier_type", "testing"). AddTopLevelElement("shared_customer_identifier", "test-identifier"). AddTopLevelElement("paypal_account[consent_code]", "consent"). AddTopLevelElement("paypal_account[correlation_id]", System.Guid.NewGuid().ToString()). AddTopLevelElement("paypal_account[options][validate]", "false"); HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/paypal_accounts", builder.ToQueryString()); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string responseBody = reader.ReadToEnd(); Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\""); Match match = regex.Match(responseBody); return match.Groups["nonce"].Value; }
public static string GenerateUnlockedNonce(BraintreeGateway gateway, string creditCardNumber, string customerId) { var clientToken = ""; if (customerId == null) { clientToken = TestHelper.GenerateDecodedClientToken(gateway); } else { clientToken = TestHelper.GenerateDecodedClientToken(gateway, new ClientTokenRequest { CustomerId = customerId } ); } var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken); RequestBuilder builder = new RequestBuilder(""); builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint). AddTopLevelElement("shared_customer_identifier_type", "testing"). AddTopLevelElement("shared_customer_identifier", "test-identifier"). AddTopLevelElement("credit_card[number]", creditCardNumber). AddTopLevelElement("share", "true"). AddTopLevelElement("credit_card[expiration_month]", "11"). AddTopLevelElement("credit_card[expiration_year]", "2099"); HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString()); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string responseBody = reader.ReadToEnd(); Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\""); Match match = regex.Match(responseBody); return match.Groups["nonce"].Value; }