Braintree.TestUtil.TestHelper.GetNonceForNewCreditCard C# (CSharp) 메소드

GetNonceForNewCreditCard() 공개 정적인 메소드

public static GetNonceForNewCreditCard ( BraintreeGateway gateway, object>.System.Collections.Generic.Dictionary creditCardDetails, string customerId = null ) : string
gateway Braintree.BraintreeGateway
creditCardDetails object>.System.Collections.Generic.Dictionary
customerId string
리턴 string
        public static string GetNonceForNewCreditCard(BraintreeGateway gateway, Params creditCardDetails, string customerId = null)
        {
            var clientToken = GenerateDecodedClientToken(
                gateway,
                customerId == null ? null : new ClientTokenRequest { CustomerId = customerId });

            var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken);

            var builder = new RequestBuilder();
            builder.
                AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
                AddTopLevelElement("shared_customer_identifier", "test-identifier").
                AddTopLevelElement("shared_customer_identifier_type", "testing");

            foreach (var param in creditCardDetails) {
                var nested = param.Value as Params;
                if (null != nested) {
                    foreach (var nestedParam in nested) {
                        builder.AddTopLevelElement(string.Format("credit_card[{0}][{1}]", param.Key, nestedParam.Key), nestedParam.Value.ToString());
                    }
                } else
                    builder.AddTopLevelElement(string.Format("credit_card[{0}]", param.Key), param.Value.ToString());
            }

            var response = new BraintreeTestHttpService().Post(
                gateway.MerchantId,
                "v1/payment_methods/credit_cards",
                builder.ToQueryString());

            return extractParamFromJson("nonce", response);
        }