根据Authorize.NET CIM中的先前事务执行事务 [英] Performing Transaction based on previous Transactions in Authorize.NET CIM

查看:198
本文介绍了根据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-dotnet This 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付款配置文件的地址信息.这是我构建的一个简单方法,用于构建Address对象:

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

现在,使用cg.AddCreditCard()创建新的CIM付款资料.为此有3个重载,#2添加CVV编号,并且#3能够放入AVS的Address对象.如果您执行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中的先前事务执行事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆