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


C# Payment.createNewTransactionRedirectUrl方法代码示例

本文整理汇总了C#中Payment.createNewTransactionRedirectUrl方法的典型用法代码示例。如果您正苦于以下问题:C# Payment.createNewTransactionRedirectUrl方法的具体用法?C# Payment.createNewTransactionRedirectUrl怎么用?C# Payment.createNewTransactionRedirectUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Payment的用法示例。


在下文中一共展示了Payment.createNewTransactionRedirectUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        // Enter the value from the 'App Key' field obtained at developer.att.com in your
        // app account.
        string clientId = "";

        // Enter the value from the 'App Secret' field obtained at developer.att.com
        // in your app account.
        string secretKey = "";

        // Set the fully-qualified domain name to: https://api.att.com
        string fqdn = "https://api.att.com";

        //Set the scope to AAB
        string scope = "Payment";

        // Create the service for requesting an OAuth access token.
        var oauth = new OAuth(fqdn, clientId, secretKey, scope);

        // Get the OAuth access token using the Client Credentials.
        if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials))
        {
            // Get access token
            OAuthToken at = new OAuthToken();
            string accessToken = at.getAccessToken(oauth.accessTokenJson);

            // Create the service for making the method request.
            var payment = new Payment(fqdn, accessToken);

            if (string.IsNullOrEmpty((string)Session["NewTransaction"]))
            {
                /// <summary>
                /// Create new transaction
                /// </summary>
                /// <param name="apiKey">apiKey</param>
                /// <param name="secretKey">secretKey</param>
                /// <param name="description">description</param>
                /// <param name="amount">amount</param>
                /// <param name="category">category</param>
                /// <param name="channel">channel</param>
                /// <param name="merchantRedirectURI">merchantRedirectURI</param>
                /// <param name="merchantProductId">merchantProductId</param>
                /// <param name="merchantTransactionId">merchantTransactionId</param>

                var redirectUrl = payment.createNewTransactionRedirectUrl(
                    clientId,
                    secretKey,
                    "Sample Product",
                    0.01,
                    2,
                    "MOBILE_WEB",
                    "http://localhost/PaymentNewTransaction.aspx",
                    "whateverprod",
                    merchantTransactionId);

                Session["NewTransaction"] = "created";
                Response.Redirect(redirectUrl);
            }

            if (Request.QueryString["success"] != null && Request.QueryString["success"].ToString() == "false")
            {
                errorCreateNew = new Dictionary<string, string>();

                foreach (String key in Request.QueryString.AllKeys)
                {
                    errorCreateNew.Add(key, Request.QueryString[key]);
                }
                throw new Exception(Request.QueryString["faultDescription"]);
            }

            if ((Request["TransactionAuthCode"] != null))
            {
                TransactionAuthCode = Request.QueryString["TransactionAuthCode"].ToString();
            }

            /// <summary>
            /// Call getTransactionStatus operation return getTransactionStatus object
            /// </summary>
            /// <param name="idType">idType</param>
            /// <param name="id">id</param>
            TransactionStatusResponseObj.RootObject getTransactionStatus
                = payment.getTransactionStatus("TransactionAuthCode", TransactionAuthCode);

            //Get Payment notification
            //Stream inputstream = Request.InputStream;
            //int streamLength = Convert.ToInt32(inputstream.Length);
            //byte[] stringArray = new byte[streamLength];
            //inputstream.Read(stringArray, 0, streamLength);

            //string xmlString = System.Text.Encoding.UTF8.GetString(stringArray);

            string xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ownershipEvent type=\"revoke\" timestamp=\"2014-05-02T06:12:33+00:00\" effective=\"2014-05-02T06:12:18+00:00\"><networkOperatorId>cingular</networkOperatorId><ownerIdentifier>N_NBI_PNW_1369816836000116729061</ownerIdentifier><purchaseDate>2014-05-02T06:12:05+00:00</purchaseDate><productIdentifier>Onetime_Cat1</productIdentifier><purchaseActivityIdentifier>Z89EZXmzjy2yu6s7wFY88cZM9lgztD6PRyo8</purchaseActivityIdentifier><instanceIdentifier>ada820f1-ce48-499b-8b46-eac60ef28a2a-CTASTransactionP1</instanceIdentifier><minIdentifier>4256586023</minIdentifier><sequenceNumber>178</sequenceNumber><reasonCode>1760</reasonCode><reasonMessage>CP Requested Refund</reasonMessage><vendorPurchaseIdentifier>M789819033</vendorPurchaseIdentifier></ownershipEvent>";

            XmlSerializer deserializer = new XmlSerializer(typeof(ownershipEvent));
            TextReader textReader = new StringReader(xmlString);
            ownershipEvent notificationObj;
            notificationObj = (ownershipEvent)deserializer.Deserialize(textReader);
            textReader.Close();

            //create refund transaction object
//.........这里部分代码省略.........
开发者ID:venugec,项目名称:codekit-csharp,代码行数:101,代码来源:PaymentNewTransaction.aspx.cs


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