当前位置: 首页>>代码示例>>C#>>正文


C# Braintree.BraintreeService类代码示例

本文整理汇总了C#中Braintree.BraintreeService的典型用法代码示例。如果您正苦于以下问题:C# BraintreeService类的具体用法?C# BraintreeService怎么用?C# BraintreeService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BraintreeService类属于Braintree命名空间,在下文中一共展示了BraintreeService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AndroidPayCard

        protected internal AndroidPayCard(NodeWrapper node, BraintreeService service)
        {
            CardType = node.GetString("virtual-card-type");
            VirtualCardType = node.GetString("virtual-card-type");
            SourceCardType = node.GetString("source-card-type");
            Last4 = node.GetString("virtual-card-last-4");
            SourceCardLast4 = node.GetString("source-card-last-4");
            VirtualCardLast4 = node.GetString("virtual-card-last-4");
            Bin = node.GetString("bin");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            GoogleTransactionId = node.GetString("google-transaction-id");
            Token = node.GetString("token");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], service);
            }
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:26,代码来源:AndroidPayCard.cs

示例2: BuildTrData

        public static string BuildTrData(Request request, string redirectURL, BraintreeService service)
        {
            var dateString = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmss");

            var trContent = new QueryString().
                Append("api_version", service.ApiVersion).
                Append("public_key", service.PublicKey).
                Append("redirect_url", redirectURL).
                Append("time", dateString).
                Append("kind", request.Kind()).
                ToString();

            string requestQueryString = request.ToQueryString();

            if (requestQueryString.Length > 0)
            {
                trContent += "&" + requestQueryString;
            }

            var signatureService = new SignatureService {
              Key = service.PrivateKey,
              Hasher = new Sha1Hasher()
            };
            return signatureService.Sign(trContent);
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:25,代码来源:TrUtil.cs

示例3: Customer

        internal Customer(NodeWrapper node, BraintreeService service)
        {
            if (node == null) return;

            Id = node.GetString("id");
            FirstName = node.GetString("first-name");
            LastName = node.GetString("last-name");
            Company = node.GetString("company");
            Email = node.GetString("email");
            Phone = node.GetString("phone");
            Fax = node.GetString("fax");
            Website = node.GetString("website");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var creditCardXmlNodes = node.GetList("credit-cards/credit-card");
            CreditCards = new CreditCard[creditCardXmlNodes.Count];
            for (int i = 0; i < creditCardXmlNodes.Count; i++)
            {
                CreditCards[i] = new CreditCard(creditCardXmlNodes[i], service);
            }

            var addressXmlNodes = node.GetList("addresses/address");
            Addresses = new Address[addressXmlNodes.Count];
            for (int i = 0; i < addressXmlNodes.Count; i++)
            {
                Addresses[i] = new Address(addressXmlNodes[i]);
            }

            CustomFields = node.GetDictionary("custom-fields");
        }
开发者ID:toantran,项目名称:braintree_dotnet,代码行数:31,代码来源:Customer.cs

示例4: IsValidTrQueryString

 public static bool IsValidTrQueryString(string queryString, BraintreeService service)
 {
     var delimiters = new string[1];
     delimiters[0] = "&hash=";
     string[] dataSections = queryString.TrimStart('?').Split(delimiters, StringSplitOptions.None);
     return dataSections[1] == new Sha1Hasher().HmacHash(service.PrivateKey, dataSections[0]).ToLower();
 }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:7,代码来源:TrUtil.cs

示例5: IsValidTrQueryString

 public static Boolean IsValidTrQueryString(String queryString, BraintreeService service)
 {
     string[] delimeters = new string[1];
     delimeters[0] = "&hash=";
     String[] dataSections = queryString.TrimStart('?').Split(delimeters, StringSplitOptions.None);
     return dataSections[1] == new Crypto().HmacHash(service.PrivateKey, dataSections[0]).ToLower();
 }
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:7,代码来源:TrUtil.cs

示例6: TransparentRedirectRequest

        public TransparentRedirectRequest(string queryString, BraintreeService service)
        {
            queryString = queryString.TrimStart('?');

            var paramMap = new Dictionary<string, string>();
            string[] queryParams = queryString.Split('&');

            foreach (var queryParam in queryParams)
            {
                var items = queryParam.Split('=');
                paramMap[items[0]] = items[1];
            }

            string message = null;
            if (paramMap.ContainsKey("bt_message"))
            {
                message = HttpUtility.UrlDecode(paramMap["bt_message"]);
            }

            BraintreeService.ThrowExceptionIfErrorStatusCode((HttpStatusCode)int.Parse(paramMap["http_status"]), message);

            if (!TrUtil.IsValidTrQueryString(queryString, service))
            {
                throw new ForgedQueryStringException();
            }

            Id = paramMap["id"];
        }
开发者ID:Jammyhammy,项目名称:braintree_dotnet,代码行数:28,代码来源:TransparentRedirectRequest.cs

示例7: QueryStringForTR

    public static string QueryStringForTR(Request trParams, Request req, string postURL, BraintreeService service)
    {
      string trData = TrUtil.BuildTrData(trParams, "http://example.com", service);
      string postData = "tr_data=" + HttpUtility.UrlEncode(trData, Encoding.UTF8) + "&";
      postData += req.ToQueryString();

      var request = WebRequest.Create(postURL) as HttpWebRequest;

      request.Method = "POST";
      request.KeepAlive = false;
      request.AllowAutoRedirect = false;

      byte[] buffer = Encoding.UTF8.GetBytes(postData);
      request.ContentType = "application/x-www-form-urlencoded";
      request.ContentLength = buffer.Length;
      Stream requestStream = request.GetRequestStream();
      requestStream.Write(buffer, 0, buffer.Length);
      requestStream.Close();

      var response = request.GetResponse() as HttpWebResponse;
      string query = new Uri(response.GetResponseHeader("Location")).Query;

      response.Close();

      return query;
    }
开发者ID:Jammyhammy,项目名称:braintree_dotnet,代码行数:26,代码来源:TestHelper.cs

示例8: IsTrDataValid

        public static bool IsTrDataValid(string trData, BraintreeService service)
        {
            string[] dataSections = trData.Split('|');
            var trHash = dataSections[0];
            var trContent = dataSections[1];

            return trHash  == new Sha1Hasher().HmacHash(service.PrivateKey, trContent);
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:8,代码来源:TrUtil.cs

示例9: IsTrDataValid

        public static Boolean IsTrDataValid(String trData, BraintreeService service)
        {
            String[] dataSections = trData.Split('|');
            String trHash = dataSections[0];
            String trContent = dataSections[1];

            return trHash  == new Crypto().HmacHash(service.PrivateKey, trContent);
        }
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:8,代码来源:TrUtil.cs

示例10: Setup

 public void Setup()
 {
     service = new BraintreeService(new Configuration(
         Environment.DEVELOPMENT,
         "integration_merchant_id",
         "integration_public_key",
         "integration_private_key"
     ));
 }
开发者ID:kevlut,项目名称:braintree_dotnet,代码行数:9,代码来源:TrUtilTest.cs

示例11: PaymentMethodNonce

        protected internal PaymentMethodNonce(NodeWrapper node, BraintreeService service)
        {
            Nonce = node.GetString("nonce");
            Type = node.GetString("type");

            var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
            if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty()){
                ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
            }
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:10,代码来源:PaymentMethodNonce.cs

示例12: Setup

 public void Setup()
 {
     gateway = new BraintreeGateway
     {
         Environment = Environment.DEVELOPMENT,
         MerchantId = "integration_merchant_id",
         PublicKey = "integration_public_key",
         PrivateKey = "integration_private_key"
     };
     service = new BraintreeService(gateway.Configuration); }
开发者ID:Jammyhammy,项目名称:braintree_dotnet,代码行数:10,代码来源:PlanTest.cs

示例13: BaseMerchantURL_ReturnsSandboxURL

        public void BaseMerchantURL_ReturnsSandboxURL()
        {
            BraintreeService service = new BraintreeService(new Configuration(
                Environment.SANDBOX,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            ));

            Assert.AreEqual("https://sandbox.braintreegateway.com:443/merchants/integration_merchant_id", service.BaseMerchantURL());
        }
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:11,代码来源:ConfigurationTest.cs

示例14: BaseMerchantURL_ReturnsProductionURL

        public void BaseMerchantURL_ReturnsProductionURL()
        {
            BraintreeService service = new BraintreeService(new Configuration(
                Environment.PRODUCTION,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            ));

            Assert.AreEqual("https://www.braintreegateway.com:443/merchants/integration_merchant_id", service.BaseMerchantURL());
        }
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:11,代码来源:ConfigurationTest.cs

示例15: GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys

        public void GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys()
        {
            BraintreeService service = new BraintreeService(new Configuration(
                Environment.DEVELOPMENT,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            ));
            Assert.AreEqual("Basic aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", service.GetAuthorizationHeader());

        }
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:11,代码来源:ConfigurationTest.cs


注:本文中的Braintree.BraintreeService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。