cancel
Showing results for 
Search instead for 
Did you mean: 

PHP - Setting invoicenumber and description with Capture a Previously Authorized Amount api call

 Hi,

 

I'm using the Capture Previously Authorized Amount api call and I'm able to capture and set the amount. Though, when I set the description and invoicenumber on the <order> tag, the description and invoicenumber do not get changed when I check the transaction in the sandbox.

 

Is it even possible to set the description and invoice number or just the amount?

Below is the code I'm using to send the request.

 

		$orderRequestType = new AnetAPI\OrderType();	    
		$orderRequestType->setInvoiceNumber($invoiceNumber);
		$orderRequestType->setDescription("Reprocessing transaction");

		$transactionRequestType = new AnetAPI\TransactionRequestType();
		$transactionRequestType->setTransactionType("priorAuthCaptureTransaction");		
		$transactionRequestType->setAmount($dueAmount);		
		$transactionRequestType->setOrder($orderRequestType);		
		$transactionRequestType->setRefTransId($externalTransactionID);		

		$request = new AnetAPI\CreateTransactionRequest();
		$request->setMerchantAuthentication($this->merchantAuthentication);
		$request->setRefId( $this->refId);
		$request->setTransactionRequest($transactionRequestType);
		
		echo $request->getTransactionRequest()->getOrder()->getInvoiceNumber(); //debug, this prints the correct string

		$controller = new AnetController\CreateTransactionController($request);
		$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
RogDev2016
Member
1 ACCEPTED SOLUTION

Accepted Solutions

Hello @RogDev2016

 

Currently you must include an Invoice Number or Description in the transaction request.  It's not possible at this time to add those values during the capture.

 

You are welcome to post this as a new feature using our Ideas forum. This will allow others to vote on and make suggestions to improve the request.

Richard

View solution in original post

RichardH
Administrator Administrator
Administrator
3 REPLIES 3

Hello @RogDev2016

 

Currently you must include an Invoice Number or Description in the transaction request.  It's not possible at this time to add those values during the capture.

 

You are welcome to post this as a new feature using our Ideas forum. This will allow others to vote on and make suggestions to improve the request.

Richard

RichardH
Administrator Administrator
Administrator

I wonder if this is still the case? I have the EXACT same issue here.

 

SCENARIO:
Customer is placing a order through the storefront. When finalizing their order, we have an order of operations that first do an authorization of the card, then the order gets generated in the internal system, after which, after going through an order approval process, the initial authorization (funds) gets captured.

 

The order is key here, and the reason for the request. We "authorize" before we have the Invoice Number and Description, so those are NULL on said authorization, but when it comes time to "capture" the funds, we do have the Invoice Number and Description, and it would be really really really helpful if we could apply them to the transaction at that time.

 

jima
Regular Contributor

I'm getting an error when I included the InvoiceNumber in the TransactionRequest.

settingType[] settings = new settingType[9];

settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Submit Payment\"}";

settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
settings[1].settingValue = "{\"show\": false}";

settings[2] = new settingType();
settings[2].settingName = settingNameEnum.hostedPaymentPaymentOptions.ToString();
settings[2].settingValue = "{\"cardCodeRequired\": true, \"showCreditCard\": true, \"showBankAccount\": false}";

settings[3] = new settingType();
settings[3].settingName = settingNameEnum.hostedPaymentShippingAddressOptions.ToString();
settings[3].settingValue = "{\"show\": false}";

settings[4] = new settingType();
settings[4].settingName = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();
settings[4].settingValue = "{\"show\": true}";

settings[5] = new settingType();
settings[5].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();
settings[5].settingValue = "{\"showEmail\": false, \"requiredEmail\": false}";

// TO DO: hostedPaymentIFrameCommunicatorUrl
settings[6] = new settingType();
settings[6].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();
settings[6].settingValue = $"{{\"url\": \"{this.Settings.APEURL}/ape/authorizenet/IFrameCommunicator.html\"}}";

settings[7] = new settingType();
settings[7].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();
settings[7].settingValue = "{\"showReceipt\": false}";

settings[8] = new settingType();
settings[8].settingName = settingNameEnum.hostedPaymentStyleOptions.ToString();
settings[8].settingValue = "{\"bgColor\": \"#99c93c\"}";

settings[8] = new settingType();
settings[8].settingName = settingNameEnum.hostedPaymentStyleOptions.ToString();
settings[8].settingValue = "{\"bgColor\": \"#99c93c\"}";

var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize capture only
currencyCode = this.Settings.Currency,
amount = amount,
customer = new customerDataType { id = $"BID-{this.Registration.BID}" },
order = new orderType { invoiceNumber = "ORD-123456" }
};

var request = new getHostedPaymentPageRequest()
{
transactionRequest = transactionRequest,
hostedPaymentSettings = settings
};