本文整理汇总了C#中Payment.RefundTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# Payment.RefundTransaction方法的具体用法?C# Payment.RefundTransaction怎么用?C# Payment.RefundTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payment
的用法示例。
在下文中一共展示了Payment.RefundTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
//.........这里部分代码省略.........
// 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
RefundTransactionRequestObj.RootObject refund
= new RefundTransactionRequestObj.RootObject()
{
TransactionOperationStatus = "Refunded",
RefundReasonCode = 1,
RefundReasonText = "Customer was not happy"
};
var serializer = new JavaScriptSerializer();
var refundJSON = serializer.Serialize(refund);
RefundTransactionResponseObj.RootObject refundResponse
= payment.RefundTransaction(refundJSON, getTransactionStatus.TransactionId);
}
}