Authorized.net - 可以 createTransactionRequest 用于授权、捕获和取消现有支付配置文件 ID 的交易

Posted

技术标签:

【中文标题】Authorized.net - 可以 createTransactionRequest 用于授权、捕获和取消现有支付配置文件 ID 的交易【英文标题】:Authorized.net - Can createTransactionRequest be use for Authorize, capture and void a transaction for existing payment profile id 【发布时间】:2017-03-25 12:32:02 【问题描述】:

对于具有现有付款资料 ID(已保存的信用卡)的客户,我们使用“createCustomerProfileTransactionController”进行授权,如下所示。

public createCustomerProfileTransactionResponse AuthorizePaymentProfile(int customerProfileId, int customerPaymentProfileId, decimal amount)
        
            createCustomerProfileTransactionResponse response = null;

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = environment;

            // define the merchant information (authentication / transaction id)
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
            
                name = apiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item = apiTransactionKey,
            ;

            //construct request
            var request = new createCustomerProfileTransactionRequest
            
                merchantAuthentication = new merchantAuthenticationType
                
                    name = apiLoginID,
                    ItemElementName = ItemChoiceType.transactionKey,
                    Item = apiTransactionKey
                ,
                transaction = new profileTransactionType
                
                    Item = new profileTransAuthOnlyType
                    
                        customerProfileId = customerProfileId.ToString(),
                        customerPaymentProfileId = customerPaymentProfileId.ToString(),
                        amount = amount
                    
                ,
                extraOptions = "x_duplicate_window=1"
            ;

            //Prepare Request
            var controller = new createCustomerProfileTransactionController(request);
            controller.Execute();

            //Send Request to EndPoint
            response = controller.GetApiResponse();

            return response;

        

对于没有现有付款资料 ID 的客户,我们使用“createTransactionRequest”进行授权,如下所示。

public createTransactionResponse AuthorizeOneTimePayment(Card cardInfo, decimal amount)
        
            createTransactionResponse response = null;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = environment;

            //define the merchant information (authentication / transaction id)
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
            
                name = apiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item = apiTransactionKey,
            ;

            var creditCard = new creditCardType
            
                cardNumber = cardInfo.CardNumber,// "4111111111111111",
                expirationDate = cardInfo.ExpirationDate// "0718"
                //cardCode=cardInfo.VerificationCode
            ;

            //standard api call to retrieve response
            var paymentType = new paymentType  Item = creditCard ;

            string firstName = string.Empty;
            string lastName = string.Empty;

            if (!string.IsNullOrWhiteSpace(cardInfo.BillingName))
            
                string[] name = GetBillName(cardInfo.BillingName);
                firstName = name[0];
                lastName = name[1];
            

            var transactionRequest = new transactionRequestType
            
                transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
                amount = amount,
                payment = paymentType,
                billTo = new customerAddressType
                
                    firstName = firstName,
                    lastName = lastName,
                    address = cardInfo.BillingAddress,
                    city = cardInfo.BillingCity,
                    state = cardInfo.BillingState,
                    zip = cardInfo.BillingZipCode
                
            ;

            var request = new createTransactionRequest  transactionRequest = transactionRequest ;

            // instantiate the controller that will call the service
            var controller = new createTransactionController(request);
            controller.Execute();

            // get the response from the service (errors contained if any)
            response = controller.GetApiResponse();

            return response;

        

并遵循相同的技术来捕获和取消交易。

我的问题是,我们能否对所有交易使用“createTransactionRequest”,例如为具有付款资料 ID 的客户和一次性客户授权、捕获和取消交易。

我可以在 authorize.net 在线文档中找到任何线索。请指导我们如何做到这一点。

【问题讨论】:

【参考方案1】:

是的,您可以通过更改 transactionRequestType 和 paymentType 将 createTransactionRequest 用于 Auth/Capture、Auth Only、Prior Auth 和 Capture、Void 和 Refund。

【讨论】:

谢谢,它可以用于现有的付款资料 ID,如何?【参考方案2】:

对于像我这样有相同问题的人,这里是答案。 请注意,订单是可选的,而配置文件显然是可选的。

            ...
            var transactionRequest = new transactionRequestType 
                transactionType = transactionTypeEnum.authOnlyTransaction.ToString(),
                amount = amount,
                order = new orderType  invoiceNumber = OrderID, description = desc ,
                profile = getCustomerPaymentProfile(CustomerProfileId, creditProfileID)
            ;
            ...

    private customerProfilePaymentType getCustomerPaymentProfile(string CustomerProfileId, string creditProfileID) 
        return new customerProfilePaymentType 
            customerProfileId = CustomerProfileId,
            paymentProfile = new paymentProfile  paymentProfileId = creditProfileID 
        ;
    

【讨论】:

以上是关于Authorized.net - 可以 createTransactionRequest 用于授权、捕获和取消现有支付配置文件 ID 的交易的主要内容,如果未能解决你的问题,请参考以下文章

HTTP/1.1 405 Method Not Allowed 允许 authorized.net

delphi7中create(nil)与create(self)区别

像FoodPanda这样的移动应用程序是如何存储卡片信息的? [关闭]

有人可以解释 Spring Security BasePermission.Create 吗?

有人可以向我解释一下:'create(email: emailArg = ) '吗?

create table 和 create schema的区别