【问题标题】:Auth.net Create Customer Payment Profile - E00040 - The record cannot be foundAuth.net 创建客户付款配置文件 - E00040 - 找不到记录
【发布时间】:2016-06-24 16:12:09
【问题描述】:

我是使用Java SDKAuthorize.net 的新手。我正在尝试使用CreateCustomerPaymentProfile API 创建客户资料。

下面的错误来了:

06/24/16 21:24:36,362:  INFO [pool-1-thread-1] (net.authorize.util.LogHelper:24) - Use Proxy: 'false'
Failed to create customer payment profile:  ERROR
~~~~ Details Are ~~~~
Message Code  : E00040
Message Text  : The record cannot be found.

以下 API:

import java.util.List;

import net.authorize.Environment;
import net.authorize.api.contract.v1.CreateCustomerPaymentProfileRequest;
import net.authorize.api.contract.v1.CreateCustomerPaymentProfileResponse;
import net.authorize.api.contract.v1.CreditCardType;
import net.authorize.api.contract.v1.CustomerAddressType;
import net.authorize.api.contract.v1.CustomerPaymentProfileType;
import net.authorize.api.contract.v1.MerchantAuthenticationType;
import net.authorize.api.contract.v1.MessageTypeEnum;
import net.authorize.api.contract.v1.MessagesType.Message;
import net.authorize.api.contract.v1.PaymentType;
import net.authorize.api.controller.CreateCustomerPaymentProfileController;
import net.authorize.api.controller.base.ApiOperationBase;

public class CreateCustomerPaymentProfile {
    public static final String apiLoginID= "72mNC7gyq";
    public static final String transactionKey= "**";

    private static final String customerProfileId = "36731856";

    public static void main(String[] args) {
        ApiOperationBase.setEnvironment(Environment.SANDBOX);

        MerchantAuthenticationType merchantAuthenticationType  = new MerchantAuthenticationType() ;
        merchantAuthenticationType.setName(apiLoginID);
        merchantAuthenticationType.setTransactionKey(transactionKey);
        ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

        //private String getPaymentDetails(MerchantAuthenticationType merchantAuthentication, String customerprofileId, ValidationModeEnum validationMode) {
        CreateCustomerPaymentProfileRequest apiRequest = new CreateCustomerPaymentProfileRequest();
        apiRequest.setMerchantAuthentication(merchantAuthenticationType);
        apiRequest.setCustomerProfileId(customerProfileId); 

        //customer address
        CustomerAddressType customerAddress = new CustomerAddressType();
        customerAddress.setFirstName("test");
        customerAddress.setLastName("scenario");
        customerAddress.setAddress("123 Main Street");
        customerAddress.setCity("Bellevue");
        customerAddress.setState("WA");
        customerAddress.setZip("98004");
        customerAddress.setCountry("USA");
        customerAddress.setPhoneNumber("000-000-0000");

        //credit card details
        CreditCardType creditCard = new CreditCardType();
        creditCard.setCardNumber("4111111111111111");
        creditCard.setExpirationDate("2023-12");
        creditCard.setCardCode("122");

        CustomerPaymentProfileType profile = new CustomerPaymentProfileType();
        profile.setBillTo(customerAddress);

        PaymentType payment = new PaymentType();
        payment.setCreditCard(creditCard);
        profile.setPayment(payment);

        apiRequest.setPaymentProfile(profile);

        CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest);
        controller.execute();

        CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse();
        response = controller.getApiResponse();
        if (response != null) {
            if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {

                System.out.println(response.getCustomerPaymentProfileId());
                System.out.println(response.getMessages().getMessage().get(0).getCode());
                System.out.println(response.getMessages().getMessage().get(0).getText());
                if(response.getValidationDirectResponse() != null)
                    System.out.println(response.getValidationDirectResponse());
            }
            else {
                System.out.println("Failed to create customer payment profile:  " + response.getMessages().getResultCode());
                System.out.println("~~~~ Details Are ~~~~");
                List<Message> messages = response.getMessages().getMessage();
                for (Message message : messages) {
                    System.out.println("Message Code  : "+message.getCode());
                    System.out.println("Message Text  : "+message.getText());
                }
            }
        }
    }
}

【问题讨论】:

    标签: java authorize.net


    【解决方案1】:

    您无法在没有客户资料的情况下创建客户付款资料。

    在您提供String customerProfileId = "36731856"; 的代码中,您收到错误E00040,因为ID 为36731856 的客户资料不存在。

    你不清楚你想要什么。 如果您想创建客户资料,请使用CreateCustomerProfile API

    这里是它的 GitHub 示例代码:https://github.com/AuthorizeNet/sample-code-java/blob/master/src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-17
      • 2011-07-24
      • 1970-01-01
      • 2015-01-25
      • 1970-01-01
      • 2014-10-06
      • 2014-12-28
      • 1970-01-01
      相关资源
      最近更新 更多