本文介绍了根据 Authorize.NET CIM 中先前的事务执行事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Authorize.NET 的新手.在authorize.net 中是否可以进行参考交易.例如:用户A第一次来并输入信用卡详细信息,他进行了付款.现在,当他第二次付款时,必须使用前一次交易的详细信息(即他不会再次输入详细信息,默认情况下必须使用第一个付款详细信息)并且必须完成付款.Authorize.NET CIM 服务中是否有任何此类选项可用.

I am new to Authorize.NET. Is reference transaction possible in authorize.net. For example: User A comes and enters the Credit Card details for first time, he does the payment. Now for the second time onwards when he does the payment the details of the previous transaction has to be used (i.e. he will not be entering the details again, the first payment details has to be used by default) and payment has to be done. Is there any such option available in Authorize.NET CIM service.

我正在使用 https://github.com/AuthorizeNet/sdk-dotnet这为我提供了 CIM 的功能,但不确定如何使用上述场景.使用PayFlow Pro我们可以成功做到(参考交易概念),authorize.NET的CIM是否提供使用CIM的此功能.

I am using Authorize.NET SDK from https://github.com/AuthorizeNet/sdk-dotnetThis provides me the functions for CIM, but not sure how to use above mentioned scenario. Using PayFlow Pro we can successfully do it (Reference Transaction Concept), Does CIM of authorize.NET provides this feature using CIM.

我能够授权信用卡并根据我捕获的响应(AuthorizationCode").现在,在捕获响应参数之后,我尝试执行另一项事务.但失败并收到错误信息:此交易已提交.

I am able to authorize the credit card and based on the response("AuthorizationCode") I did capture. Now after that from the capture response parameters I tried to do another transaction. But failed and got the error message : This transaction has been submitted already.

推荐答案

此答案特定于使用 C# 的 authorize.net .Net SDK.

This answer is specific to the authorize.net .Net SDK, using C#.

您应该在本地存储 CIM 配置文件 ID(客户配置文件的唯一标识符)和 CIM 付款配置文件 ID(添加到客户配置文件的每张支付卡的唯一标识符).所以你的客户/用户记录应该有办法存储这两个整数.

You should locally store the CIM profileID (unique identifier to the customer profile) and the CIM paymentprofileID(s) (unique identifier(s) for each payment card added to the customer profile). So your customer/user records should have a way to store these two integers.

来自 authorize.net 的关于如何在他们的 .Net SDK 中使用 CIM 的文档充其量是非常糟糕的.我试图从他们那里获得支持,他们不断说 SDK 不支持 CIM,这不是真的,因为使用它的所有方法都在那里.我将提供几行代码,它们应该会为您指明使用这个强大工具的正确方向.

The documentation from authorize.net for how to use CIM within their .Net SDK, is abysmal at best. I tried to get support from them and they constantly said that the SDK doesn't support CIM, which isn't true because all the methods to use it are there. I'll provide a few lines of code which should point you in the right direction for making use of this powerful tool.

一切都假设您在使用 AuthorizeNet"的类文件中编写代码,并且您拥有来自 authorize.net 的最新 DLL.

Everything is assuming you are writing code in a class file that is "using AuthorizeNet", and that you have the latest DLLs from authorize.net.

首先,AuthorizeNet 类具有地址"类型.这存储了 CIM 配置文件或 CIM 付款配置文件的地址信息.这是我构建的用于构建地址对象的简单方法:

First, the AuthorizeNet class has an "Address" type. This stores address info for either a CIM profile or CIM payment profile. Here's a simple method I built to build an Address object:

private static Address getAddressObject(string fname, string lname, string address, string city, string state, string zip, string phone)
        {
            var a = new Address();
            a.First = fname;
            a.Last = lname;
            a.Street = address;
            a.City = city;
            a.State = state;
            a.Zip = zip;
            a.Phone = phone;
            return a;
        }

使用该方法构建一个或多个地址对象(运输、账单、信用卡特定等),并在您与网关交互时准备好它们.

Use that method to build one or multiple address objects (shipping, billing, credit card specific, etc), and have them ready for when you interact with the gateway.

现在,创建一个 CustomerGateway 对象

Now, create a CustomerGateway object

CustomerGateway cg = new CustomerGateway(loginInfo[0], loginInfo[1], ServiceMode.Live);

现在创建一个空的 Customer 对象

Now create an empty Customer object

Customer cust;

此时,您有两个选择:

使用本地存储的 CIMprofileid 查看 CIM 配置文件是否存在:

Look to see if the CIM profile exists by using your locally stored CIMprofileid:

cust = cg.GetCustomer(rdr["CIMprofileID"].ToString());

-或-

创建新的 CIM 配置文件

Create a new CIMprofile

cust = cg.CreateCustomer(email, description);

一旦您设置了客户,您就可以从 cust.ProfileID

Once you have cust set, you can get the CIM profileID from cust.ProfileID

现在,使用 cg.AddCreditCard() 创建新的 CIM 付款配置文件.对此有 3 个重载,#2 添加 CVV 编号,#3 能够放入 AVS 的地址对象.如果您执行string paymentprofileid = cg.AddCreditCard(),则paymentprofileid 将成为您应该为该信用卡存储的号码,以便您将来可以再次收费.虽然您可以查找这些,但 CIM 返回的卡号格式为XXXX1234",因此以后很难匹配.

Now, to create a new CIM payment profile using cg.AddCreditCard(). There are 3 overloads for this, #2 adds CVV number, and #3 has the ability to drop in the Address object for AVS. If you do string paymentprofileid = cg.AddCreditCard(), paymentprofileid becomes the number you should store for that credit card, so that you can charge it again in the future. While you can look these up, the card number that CIM returns is formatted as 'XXXX1234', so it can become difficult to match up at a later time.

获得这些值后,您可以使用记录在案的方法对 CIM 配置文件卡收费.祝你好运!

Once you have these values You can use documented methods to charge a CIM profile card. Best of luck!

这篇关于根据 Authorize.NET CIM 中先前的事务执行事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:53