C#Authorize.net创建个人资料问题

时间:2017-11-06 01:55:18

标签: c# authorize.net

以下代码正在为卡充电,但它没有创建配置文件....任何提示?我假设我错过了某些东西,或者使用了错误的Type ...

ld: library not found for -lomp
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/y_/0bm1vdx95dn4m8x_xtctp2gh0000gn/T/RtmpfslTnc/downloaded_packages’

更新 由于显然不允许使用OpaqueData,我将其更改为手动创建配置文件。我收到以下错误:"错误:I00001成功。"

            var opaqueData = new opaqueDataType { dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT", dataValue = paymentNonce };

            //standard api call to retrieve response
            var paymentType = new paymentType { Item = opaqueData };

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize and capture transaction
                amount = paymentAmount,
                payment = paymentType,
                customer = new customerDataType()
                {
                    type = customerTypeEnum.individual,
                    id = userID.ToString()
                },
                profile = new customerProfilePaymentType()
                {
                    createProfile = true
                }
            };

            var request = new createTransactionRequest { transactionRequest = transactionRequest };

            // instantiate the contoller that will call the service
            var controller = new createTransactionController(request);
            const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
            const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
            ServicePointManager.SecurityProtocol = Tls12;
            controller.Execute();

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

更新#2 非常困惑,因为auth.net文档说这段代码意味着成功...所以为什么我没有看到CIM支付方法创建??? RESPONSE CODE DOCS

更新#3 所以我打印出主响应消息而不是CIM请求消息,呃。实际错误是:" E00114无效的OTS令牌。" 基于文档,该错误通常来自使用过的密钥,因此我现在生成2个密钥(一个用于处理,一个用于通过CIM存储)但现在出现此错误:" E00040无法找到记录。" ....任何想法?

1 个答案:

答案 0 :(得分:1)

所以这个问题的答案是:

  1. 您无法使用不透明的卡片数据自动创建付款资料,因此答案是在您成功收费后手动设置。
  2. 您不能使用相同的不透明卡数据来充电和存储,因为它们是一次性使用,所以对于我的网络方法,我最终传递了2个不透明的数据密钥。
  3. 您只需添加新卡即可为建立全新客户和现有客户进行不同的调用。我在下面粘贴了我的最终解决方案的摘录:

         ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = (System.Configuration.ConfigurationManager.AppSettings["Authorize-Live"].ToUpper() == "TRUE" ? AuthorizeNet.Environment.PRODUCTION : AuthorizeNet.Environment.SANDBOX);
        // define the merchant information (authentication / transaction id)
    
        ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
    
        {
    
            name = (System.Configuration.ConfigurationManager.AppSettings["Authorize-Live"].ToUpper() == "TRUE" ? System.Configuration.ConfigurationManager.AppSettings["Authorize-LoginID"] : System.Configuration.ConfigurationManager.AppSettings["Authorize-LoginID-SandBox"]),
    
            ItemElementName = ItemChoiceType.transactionKey,
    
            Item = (System.Configuration.ConfigurationManager.AppSettings["Authorize-Live"].ToUpper() == "TRUE" ? System.Configuration.ConfigurationManager.AppSettings["Authorize-TransactionKey"] : System.Configuration.ConfigurationManager.AppSettings["Authorize-TransactionKey-SandBox"])
    
        };
    
    
    
        if (paymentNonce.Trim() != "")
    
        {
    
            //set up data based on transaction
    
            var opaqueData = new opaqueDataType { dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT", dataValue = paymentNonce };
    
    
    
            //standard api call to retrieve response
    
            var paymentType = new paymentType { Item = opaqueData };
    
    
    
            var transactionRequest = new transactionRequestType
    
            {
    
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize and capture transaction
    
                amount = paymentAmount,
    
                payment = paymentType,
    
                customer = new customerDataType()
    
                {
    
                    type = customerTypeEnum.individual,
    
                    id = "YOUR_DB_USERID"
    
                },
    
                profile = new customerProfilePaymentType()
    
                {
    
                    createProfile = false
    
                }
    
            };
    
    
    
            var request = new createTransactionRequest { transactionRequest = transactionRequest };
    
    
    
            // instantiate the contoller that will call the service
    
            var controller = new createTransactionController(request);
    
            const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
    
            const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
    
            ServicePointManager.SecurityProtocol = Tls12;
    
            controller.Execute();
    
    
    
            // get the response from the service (errors contained if any)
    
            var response = controller.GetApiResponse();
    
    
    
            //validate
    
            if (response != null)
    
            {
    
                if (response.messages.resultCode == messageTypeEnum.Ok)
    
                {
    
                    if (response.transactionResponse.messages != null)
    
                    {
    
                        responseData.Success = true;
    
                        transactionID = response.transactionResponse.transId;
    
    
                        string merchID = "STORED AUTHORIZE.NET CUSTOMERID, return blank string if none!";
    
                        var opaqueData2 = new opaqueDataType { dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT", dataValue = paymentNonce2 };
    
    
    
                        //standard api call to retrieve response
    
                        var paymentType2 = new paymentType { Item = opaqueData2 };
    
                        customerPaymentProfileType opaquePaymentProfile = new customerPaymentProfileType();
    
                        opaquePaymentProfile.payment = paymentType2;
    
                        opaquePaymentProfile.customerType = customerTypeEnum.individual;
    
    
    
    
    
                        if (merchID == "")
    
                        {
                            // CREATE NEW AUTH.NET AIM CUSTOMER
                            List<customerPaymentProfileType> paymentProfileList = new List<customerPaymentProfileType>();
    
                            paymentProfileList.Add(opaquePaymentProfile);
    
                            customerProfileType customerProfile = new customerProfileType();
    
                            customerProfile.merchantCustomerId = "YOUR_DB_USERID";
    
    
    
                            customerProfile.paymentProfiles = paymentProfileList.ToArray();
    
    
    
                            var cimRequest = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.none };
    
    
    
                            var cimController = new createCustomerProfileController(cimRequest);          // instantiate the contoller that will call the service
    
                            cimController.Execute();
    
    
    
                            createCustomerProfileResponse cimResponse = cimController.GetApiResponse();
    
                            if (cimResponse != null && cimResponse.messages.resultCode == messageTypeEnum.Ok)
    
                            {
    
                                if (cimResponse != null && cimResponse.messages.message != null)
    
                                {
                                    // STORE cimResponse.customerProfileId IN DATABASE FOR USER
    
                                }
    
                            }
    
                            else
    
                            {
    
                                for (int i = 0; i < cimResponse.messages.message.Length; i++)
    
                                    Utility.AppendTextToFile("New Error (" + merchID + ") #" + i.ToString() + ": " + cimResponse.messages.message[i].code + "  " + cimResponse.messages.message[i].text, Server.MapPath("/pub/auth.txt"));
    
    
    
                            }
    
                        }
    
                        else
    
                        {
                            // ADD PAYMENT PROFILE TO EXISTING AUTH.NET AIM CUSTOMER
                            var cimRequest = new createCustomerPaymentProfileRequest
    
                            {
    
                                paymentProfile = opaquePaymentProfile,
    
                                validationMode = validationModeEnum.none,
    
                                customerProfileId = merchID.Trim()
    
                            };
    
                            var cimController = new createCustomerPaymentProfileController(cimRequest);
    
                            cimController.Execute();
    
    
    
                            //Send Request to EndPoint
    
                            createCustomerPaymentProfileResponse cimResponse = cimController.GetApiResponse();
    
                            if (cimResponse != null && cimResponse.messages.resultCode == messageTypeEnum.Ok)
    
                            {
    
                                if (cimResponse != null && cimResponse.messages.message != null)
    
                                {
    
                                    //Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
    
                                }
    
                            }
    
                            else
    
                            {
    
                                for (int i = 0; i < cimResponse.messages.message.Length; i++)
    
                                    Utility.AppendTextToFile("Add Error  (" + merchID + ") #" + i.ToString() + ": " + cimResponse.messages.message[i].code + "  " + cimResponse.messages.message[i].text, Server.MapPath("/pub/auth.txt"));
    
    
    
                            }
    
                        }
    
                    }
    
                    else
    
                    {
    
                        responseData.Message = "Card Declined";
    
                        responseData.Success = false;
    
                        if (response.transactionResponse.errors != null)
    
                        {
    
                            responseData.Message = response.transactionResponse.errors[0].errorText;
    
                        }
    
                    }
    
                }
    
                else
    
                {
    
                    responseData.Message = "Failed Transaction";
    
                    responseData.Success = false;
    
                    if (response.transactionResponse != null && response.transactionResponse.errors != null)
    
                    {
    
                        responseData.Message = response.transactionResponse.errors[0].errorText;
    
                    }
    
                    else
    
                    {
    
                        responseData.Message = response.messages.message[0].text;
    
                    }
    
                }
    
            }
    
            else
    
            {
    
                responseData.Message = "Failed Transaction, Try Again!";
    
                responseData.Success = false;
    
            }
    
        }
    
        else
    
        {
            // RUN PAYMENT WITH STORED PAYMENT PROFILE ID
            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
    
            profileToCharge.customerProfileId = CustomerID;
    
            profileToCharge.paymentProfile = new paymentProfile { paymentProfileId = PaymentID };
    
    
    
            var transactionRequest = new transactionRequestType
    
            {
    
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    
    
                amount = paymentAmount,
    
                profile = profileToCharge
    
            };
    
    
    
            var request = new createTransactionRequest { transactionRequest = transactionRequest };
    
    
    
            // instantiate the collector that will call the service
    
            var controller = new createTransactionController(request);
    
            controller.Execute();
    
    
    
            // get the response from the service (errors contained if any)
    
            var response = controller.GetApiResponse();
    
    
    
            //validate
    
            if (response != null)
    
            {
    
                if (response.messages.resultCode == messageTypeEnum.Ok)
    
                {
    
                    if (response.transactionResponse.messages != null)
    
                    {
    
                        responseData.Success = true;
    
                        transactionID = response.transactionResponse.transId;
    
    
    
                    }
    
                    else
    
                    {
    
                        responseData.Message = "Card Declined";
    
                        responseData.Success = false;
    
                        if (response.transactionResponse.errors != null)
    
                        {
    
                            responseData.Message = response.transactionResponse.errors[0].errorText;
    
                        }
    
                    }
    
                }
    
                else
    
                {
    
                    responseData.Message = "Failed Transaction";
    
                    responseData.Success = false;
    
                    if (response.transactionResponse != null && response.transactionResponse.errors != null)
    
                    {
    
                        responseData.Message = response.transactionResponse.errors[0].errorText;
    
                    }
    
                    else
    
                    {
    
                        responseData.Message = response.messages.message[0].text;
    
                    }
    
                }
    
            }
    
            else
    
            {
    
                responseData.Message = "Failed Transaction, Try Again!";
    
                responseData.Success = false;
    
            }
    
        }