cancel
Showing results for 
Search instead for 
Did you mean: 

Apple Pay - Customer Profile Creation - E00141 - Profile Creation With OpaqueData descriptor...

When attempting to create a customer profile with an Apple Pay token, I get the following error:

 

E00141 - Payment Profile Creation with this OpaqueData descriptor requires transactionMode to be set to liveMode

 

I found this but there are no other details provided aobut the error:
https://developer.authorize.net/api/reference/responseCodes.html?code=E00141

 

I have tried this in both Sandbox and the Production side and in both places I get the same error.  What am I missing?

qw
Contributor
14 REPLIES 14

This is the code I'm using which is essentially the sample account creation code, but supplying an opaqueDataType as the paymentType.

 

public static CreateApplePayCustomerProfileResult Run(string ApiLoginID, string ApiTransactionKey, ApplePayPayment token, bool isLive)
{
    var result = new CreateApplePayCustomerProfileResult();
    result.DebugText += ("Create Apple Pay Profile Sample   ");
    result.DebugText += ("isLive == " + isLive + "  ");

    //comvert the "payment data token" back into JSON
    var tokenjson = Newtonsoft.Json.JsonConvert.SerializeObject(token.paymentData);

    //the base-64 encode it
    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(tokenjson);
    var token64 = System.Convert.ToBase64String(plainTextBytes);

    // set whether to use the sandbox environment, or production enviornmentif (isLive)
    if(isLive)
    {
        ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
    }
    else
    {
        ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
    }

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

    var applePay = new opaqueDataType {
        dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT",
        dataValue = token64
    };

    paymentType ap = new paymentType { Item = applePay };
    List<customerPaymentProfileType> paymentProfileList = new List<customerPaymentProfileType>();
            
    customerPaymentProfileType apPaymentProfile = new customerPaymentProfileType();
    apPaymentProfile.payment = ap;
    paymentProfileList.Add(apPaymentProfile);

    List<customerAddressType> addressInfoList = new List<customerAddressType>();
    customerAddressType homeAddress = new customerAddressType();
    homeAddress.firstName = "Tester";
    homeAddress.lastName = "McTester";
    homeAddress.address = "10900 NE 8th St";
    homeAddress.city = "Seattle";
    homeAddress.zip = "98006";
            
    addressInfoList.Add(homeAddress);
            
    customerProfileType customerProfile = new customerProfileType();
    customerProfile.merchantCustomerId = "Test CustomerID";
    customerProfile.email = "Tester@McTester.nowhere.test.com";
    customerProfile.paymentProfiles = paymentProfileList.ToArray();
    customerProfile.shipToList = addressInfoList.ToArray();

    var request = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.none };

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

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

    // validate response 
    if (response != null)
    {
        if (response.messages.resultCode == messageTypeEnum.Ok)
        {
            if (response.messages.message != null)
            {
                result.DebugText += ("Success!");
                result.DebugText += ("Customer Profile ID: " + response.customerProfileId);
                result.DebugText += ("Payment Profile ID: " + response.customerPaymentProfileIdList[0]);
                result.DebugText += ("Shipping Profile ID: " + response.customerShippingAddressIdList[0]);
            }
        }
        else
        {
            result.DebugText += ("Customer Profile Creation Failed.");
            result.DebugText += ("Error Code: " + response.messages.message[0].code);
            result.DebugText += ("Error message: " + response.messages.message[0].text);
        }
    }
    else
    {
        if (controller.GetErrorResponse().messages.message.Length > 0)
        {
            result.DebugText += ("Customer Profile Creation Failed.");
            result.DebugText += ("Error Code: " + response.messages.message[0].code);
            result.DebugText += ("Error message: " + response.messages.message[0].text);
        }
        else
        {
            result.DebugText += ("Null Response.");
        }
    }

    return result;
}
qw
Contributor

Try changing the validationMode to validationModeEnum.liveMode in the following line of your code. 

 

var request = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.none };

 

 

rahulr
Authorize.Net Developer Authorize.Net Developer
Authorize.Net Developer

Ok, that helped get me past the previous error!  But now the error is:

E00027 Credit card number is required.

 

 

Error code E00027 means the transaction was unsuccessful.

See more details here- https://developer.authorize.net/api/reference/responseCodes.html?code=E00027

 

When the validationMode is set to liveMode a transaction will be performed to validate the card and reversed immediately. The details of this validation are sent in the "validationDirectResponseList" field in the api response. 

rahulr
Authorize.Net Developer Authorize.Net Developer
Authorize.Net Developer

Right, but in this case I'm trying to use an Apple Pay opaqueDataType instead of a card, so there is no credit card to validate.

 

I've tried both creating just a customer profile, and creating a new subscription this way, and both return the same error.

 

This post seems to indicate that what I am doing should be possible?:

https://community.developer.authorize.net/t5/Integration-and-Testing/Can-I-create-a-recurring-subscr...

Hi @qw,

 

It is possible to create profiles and subscriptions with opaqueDataType.

Since the card number is not in the opaqueData, we need to perform a transaction to validate the card that is linked to the opaqueData. The liveMode is required for this.

 

Here it looks like your validation transaction is failing with the error code E00027. 

rahulr
Authorize.Net Developer Authorize.Net Developer
Authorize.Net Developer

Is there sample code anywhere that shows how to do this?  The "Create Customer Profile" example in the authorize.net documentation does not show how to use an Apple Pay token.

 

This is my code that returns the E00027 Credit Card Required error:

 

using System;
using System.Collections.Generic;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers.Bases;
using Test_ApplePay.ApplePay;

namespace Test_ApplePay
{

    public class CreateApplePayCustomerProfileResult
    {
        public bool DidComplete { get; set; }
        public string DebugText { get; set; }
    }

    public class CreateApplePayCustomerProfile
    {
        public static CreateApplePayCustomerProfileResult Run(string ApiLoginID, string ApiTransactionKey, ApplePayPayment token, bool isLive)
        {
            var result = new CreateApplePayCustomerProfileResult();
            result.DebugText += ("Create Apple Pay Profile Sample   ");
            result.DebugText += ("isLive == " + isLive + "  ");

            //comvert the "payment data token" back into JSON
            var tokenjson = "";

            if (token != null) Newtonsoft.Json.JsonConvert.SerializeObject(token.paymentData);

            //the base-64 encode it
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(tokenjson);
            var token64 = System.Convert.ToBase64String(plainTextBytes);

            // set whether to use the sandbox environment, or production enviornmentif (isLive)
            if(isLive)
            {
                ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
            }
            else
            {
                ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
            }

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

            List<customerPaymentProfileType> paymentProfileList = new List<customerPaymentProfileType>();

            var applePay = new opaqueDataType {
                dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT",
                dataValue = token64
            };

            paymentType ap = new paymentType { Item = applePay };
            customerPaymentProfileType apPaymentProfile = new customerPaymentProfileType();
            apPaymentProfile.payment = ap;
            paymentProfileList.Add(apPaymentProfile);


            customerProfileType customerProfile = new customerProfileType();
            customerProfile.merchantCustomerId = "Test CustomerID";
            customerProfile.email = "Tester@McTester.nowhere.test.com";
            customerProfile.paymentProfiles = paymentProfileList.ToArray();

            var request = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.liveMode };

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

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

            // validate response 
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.messages.message != null)
                    {
                        result.DebugText += ("Success!");
                        result.DebugText += ("Customer Profile ID: " + response.customerProfileId);
                        result.DebugText += ("Payment Profile ID: " + response.customerPaymentProfileIdList[0]);
                        result.DebugText += ("Shipping Profile ID: " + response.customerShippingAddressIdList[0]);
                    }
                }
                else
                {
                    result.DebugText += ("Customer Profile Creation Failed.");
                    result.DebugText += ("Error Code: " + response.messages.message[0].code);
                    result.DebugText += ("Error message: " + response.messages.message[0].text);
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    result.DebugText += ("Customer Profile Creation Failed.");
                    result.DebugText += ("Error Code: " + response.messages.message[0].code);
                    result.DebugText += ("Error message: " + response.messages.message[0].text);
                }
                else
                {
                    result.DebugText += ("Null Response.");
                }
            }

            return result;
        }
    }
}

Along with that code above, we also tried supplying the credit card number with the apple pay token in the same transaction like so:

 

            var creditCard = new creditCardType
            {
                cardNumber = "[real card number]",
                expirationDate = "[real expiration]"
            };

            paymentType cc = new paymentType { Item = creditCard };
            customerPaymentProfileType ccPaymentProfile = new customerPaymentProfileType();
            ccPaymentProfile.payment = cc;
            paymentProfileList.Add(ccPaymentProfile);
qw
Contributor

Hi @qw,

 

What is your GatewayId? We can check the issue with the transaction.

You can use this request to get the gatewayId - https://developer.authorize.net/api/reference/#transaction-reporting-get-merchant-details

rahulr
Authorize.Net Developer Authorize.Net Developer
Authorize.Net Developer

Type a product name