Reply
Member
Posts: 1
Registered: ‎03-11-2019

Created customer profile and payment profile but cant charge profile with credit card

Team - Have been able to verify that the customer profile and payment profile are visible in sandbox.authorize.net..  The test credit card is visible in the profile but when I try to charge it I receive error E00040: Customer Profile ID or Customer Payment Profile ID not found.  Below is code:

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 = APITRANSATIONKEY
};

//create a customer payment profile
//create a customer payment profile
customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
profileToCharge.customerProfileId = customerProfileId;
profileToCharge.paymentProfile = new paymentProfile { paymentProfileId = paymentProfileId };

var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // refund type
amount = Amount,
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();

Highlighted
Posts: 2,765
Topics: 57
Kudos: 245
Blog Posts: 67
Registered: ‎12-05-2011

Re: Created customer profile and payment profile but cant charge profile with credit card

Hello @Codemonkeys2019 

 

If you are creating customer profile and then immediately running a charge, there can be a short delay before the customer profile is available.  Creating a customer profile is done realtime, but follow-on transactions like charging a customer profile use replicated data for performance reasons.

 

If you need to create a transaction AND create a customer profile, you might consider creating transaction request and set createProfile=true.  If the transaction is successful, a customer profile is returned in the transaction response which you can store in your system.

 

Richard