/// <summary> /// The generate client request token. /// </summary> /// <param name="customer"> /// The customer. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> /// <exception cref="BraintreeException"> /// Throws an exception if the braintree customer returns null /// </exception> public string GenerateClientRequestToken(ICustomer customer) { var braintreeCustomer = GetBraintreeCustomer(customer); if (braintreeCustomer == null) { throw new BraintreeException("Failed to retrieve and/or create a Braintree Customer"); } var attempt = TryGetApiResult(() => BraintreeGateway.ClientToken.generate(RequestFactory.CreateClientTokenRequest(customer.Key))); return(attempt.Success ? attempt.Result : string.Empty); }
/// <summary> /// The generate client request token. /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> public string GenerateClientRequestToken() { var attempt = TryGetApiResult(() => BraintreeGateway.ClientToken.generate(RequestFactory.CreateClientTokenRequest(Guid.Empty))); return(attempt.Success ? attempt.Result : string.Empty); }