有谁知道如何根据 pnref 或通过调用 paypal 返回的其他参数进行退款(使用 payflow api 时)。谢谢马切克
问问题
2679 次
1 回答
4
如果交易尚未结算,您可以使用 Void 退款。对于较长期的交易,例如一个月前,您需要进行贷记。这是无效代码:
using System;
using PayPal.Payments.Common;
using PayPal.Payments.Common.Utility;
using PayPal.Payments.DataObjects;
using PayPal.Payments.Transactions;
namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions
{
/// <summary>
/// This class uses the Payflow SDK Data Objects to do a simple Void transaction.
/// The request is sent as a Data Object and the response received is also a Data Object.
/// </summary>
public class DOVoid
{
public DOVoid()
{
}
public static void Main(string[] Args)
{
Console.WriteLine("------------------------------------------------------");
Console.WriteLine("Executing Sample from File: DOVoid.cs");
Console.WriteLine("------------------------------------------------------");
// Create the Data Objects.
// Create the User data object with the required user details.
//UserInfo User = new UserInfo("<user>", "<vendor>", "<partner>", "<password>");
UserInfo User = new UserInfo("xxx", Xxx", "paypal", "password");
// Create the Payflow Connection data object with the required connection details.
// The PAYFLOW_HOST property is defined in the App config file.
PayflowConnectionData Connection = new PayflowConnectionData();
///////////////////////////////////////////////////////////////////
// Create a new Void Transaction.
// The ORIGID is the PNREF no. for a previous transaction.
//VoidTransaction Trans = new VoidTransaction("<ORIGINAL_PNREF>",
// User, Connection, PayflowUtility.RequestId);
VoidTransaction Trans = new VoidTransaction("V35A0A3E6E0C",
User, Connection, PayflowUtility.RequestId);
// Submit the Transaction
Response Resp = Trans.SubmitTransaction();
// Display the transaction response parameters.
if (Resp != null)
{
// Get the Transaction Response parameters.
TransactionResponse TrxnResponse = Resp.TransactionResponse;
if (TrxnResponse != null)
{
Console.WriteLine("RESULT = " + TrxnResponse.Result);
Console.WriteLine("PNREF = " + TrxnResponse.Pnref);
Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg);
Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode);
Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr);
Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip);
Console.WriteLine("IAVS = " + TrxnResponse.IAVS);
}
// Get the Fraud Response parameters.
FraudResponse FraudResp = Resp.FraudResponse;
// Display Fraud Response parameter
if (FraudResp != null)
{
Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg);
Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg);
}
// Display the response.
Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp));
// Get the Transaction Context and check for any contained SDK specific errors (optional code).
Context TransCtx = Resp.TransactionContext;
if (TransCtx != null && TransCtx.getErrorCount() > 0)
{
Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString());
}
}
Console.WriteLine("Press Enter to Exit ...");
Console.ReadLine();
}
}
}
这是信用代码:
using System;
using PayPal.Payments.Common;
using PayPal.Payments.Common.Utility;
using PayPal.Payments.DataObjects;
using PayPal.Payments.Transactions;
namespace PayPal.Payments.Samples.CS.DataObjects.BasicTransactions
{
/// <summary>
/// This class uses the Payflow SDK Data Objects to do a simple independent Credit transaction.
/// The request is sent as a Data Object and the response received is also a Data Object.
/// </summary>
public class DOCredit
{
public DOCredit()
{
}
public static void Main(string[] Args)
{
Console.WriteLine("------------------------------------------------------");
Console.WriteLine("Executing Sample from File: DOCredit.cs");
Console.WriteLine("------------------------------------------------------");
// Create the Data Objects.
// Create the User data object with the required user details.
UserInfo User = new UserInfo("xxx", "xxx", "paypal", "a12");
// Create the Payflow Connection data object with the required connection details.
// The PAYFLOW_HOST property is defined in the App config file.
PayflowConnectionData Connection = new PayflowConnectionData();
// Create a new Invoice data object with the Amount, Billing Address etc. details.
Invoice Inv = new Invoice();
// Set Amount.
Currency Amt = new Currency(new decimal(1));
Inv.Amt = Amt;
Inv.PoNum = "PO12345";
Inv.InvNum = "INV12345";
// Set the Billing Address details.
BillTo Bill = new BillTo();
Bill.Street = "123 Main St.";
Bill.Zip = "12345";
Inv.BillTo = Bill;
// Create a new Payment Device - Credit Card data object.
// The input parameters are Credit Card Number and Expiration Date of the Credit Card.
CreditCard CC = new CreditCard("5105105105105100", "0112");
// Create a new Tender - Card Tender data object.
CardTender Card = new CardTender(CC);
///////////////////////////////////////////////////////////////////
// Create a new Credit Transaction.
// Following is an example of a independent credit type of transaction.
CreditTransaction Trans = new CreditTransaction(User, Connection, Inv, Card,
PayflowUtility.RequestId);
// Submit the Transaction
Response Resp = Trans.SubmitTransaction();
// Display the transaction response parameters.
if (Resp != null)
{
// Get the Transaction Response parameters.
TransactionResponse TrxnResponse = Resp.TransactionResponse;
if (TrxnResponse != null)
{
Console.WriteLine("RESULT = " + TrxnResponse.Result);
Console.WriteLine("PNREF = " + TrxnResponse.Pnref);
Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg);
Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode);
Console.WriteLine("AVSADDR = " + TrxnResponse.AVSAddr);
Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip);
Console.WriteLine("IAVS = " + TrxnResponse.IAVS);
Console.WriteLine("CVV2MATCH = " + TrxnResponse.CVV2Match);
// If value is true, then the Request ID has not been changed and the original response
// of the original transction is returned.
Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate);
}
// Get the Fraud Response parameters.
FraudResponse FraudResp = Resp.FraudResponse;
// Display Fraud Response parameter
if (FraudResp != null)
{
Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg);
Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg);
}
// Display the response.
Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp));
// Get the Transaction Context and check for any contained SDK specific errors (optional code).
Context TransCtx = Resp.TransactionContext;
if (TransCtx != null && TransCtx.getErrorCount() > 0)
{
Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString());
}
}
Console.WriteLine("Press Enter to Exit ...");
Console.ReadLine();
}
}
}
于 2012-07-07T15:30:54.713 回答