【问题标题】:Payflow Refunds支付流退款
【发布时间】:2012-07-07 17:45:30
【问题描述】:

是否有人知道如何根据 pnref 或通过调用 paypal 返回的其他参数进行退款(使用 payflow api 时)。 谢谢 马切克

【问题讨论】:

    标签: paypal payflowpro


    【解决方案1】:

    如果交易尚未结算,您可以使用 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();
        }
    }
    }
    

    【讨论】:

    • 非常感谢约瑟夫。但是我还有一个问题,因为我不确定解决方案。在付款过程中,我是否必须使用信用或作废?我首先拨打授权电话“&TRXTYPE=A&AMT=199.00&”,然后我再次拨打电话“TRXTYPE=D&AMT=199.00&” - 因为稍后我想拨打电话基于ORIGID。此外,哪个 pnref 选择退款 - 授权呼叫或延迟捕获的 pnref。最好的问候,Maciek
    • 不客气。您可以使用 auth and capture 或 auth with delay capture。您一开始使用哪种付款方式并不重要。如果仅授权付款,请使用 void。我认为您可以使用任何 pnref,因为我相信它们是相同的。自定义解决方案将 pnref 保存到数据库中,并且可以通过 order id 引用。如果您仍有问题,请在您的帖子中添加一些代码。
    • 未来读者请注意:您不需要指定信用卡号(至少根据我的经验),只要您指定了 PNREF 值即可。
    猜你喜欢
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 2015-12-07
    • 2012-07-01
    • 2015-12-23
    • 2013-04-17
    • 1970-01-01
    • 2020-03-09
    相关资源
    最近更新 更多