Authorize a Payment {#thunes-oney-auth-intro}
=============================================

The authorization service confirms a customer's account holds enough funds for the payment.  
The authorization request requires the pre-approved token returned in the session response in the apSessionReply_processorToken field.  
When a payment is authorized, it can be captured within 28 days.

Line Items
----------

The authorization service requires you to include line items in your request. Line items correspond to the item_#_ fields, starting with item_0_ and increasing in numerical order.  
For more information on how to use line items, see [Using Line Items](/docs/cybs/en-us/thunes/developer/all/so/thunes/thunes-ref-info/thunes-intro-lineitems.md "").

Tax Amounts {#thunes-oney-auth-intro_tax-info}
----------------------------------------------

Include the tax amount for every type of purchased product in the item_#_taxAmount field when you request the authorization service.

Calculating the Grand Total
---------------------------

Include the grand total in the request by using the purchaseTotals_grandTotalAmount field.  
For information about how to calculate the grand total, see [Calculating the Grand Total for Line Items](/docs/cybs/en-us/thunes/developer/all/so/thunes/thunes-ref-info/thunes-intro-total.md "").

Endpoints {#thunes-oney-auth-intro_section_chq_k24_jyb}
-------------------------------------------------------

Set the apAuthService_run field to `true`, and send the request to one of these endpoints:  
**Production:** `https://ics2ws.ic3.com/commerce/1.x/transactionProcessor`  
**Test:** `https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor`

Response Statuses
-----------------

The authorization service responds with one of these statuses as the apAuthReply_status field value:

* `AUTHORIZED`: The payment is successfully authorized.
* `FAILED`: The authorization request failed.
* `PENDING`: The authorization request is accepted but is not authorized. Either the authorization is being audited by Oney or the customer has not completed the checkout using the redirection URL. The merchant should send a check status request to retrieve status updates. Request the check status service to retrieve status updates. See [Check a Transaction Status](/docs/cybs/en-us/thunes/developer/all/so/thunes/thunes-status-intro.md "").

{#thunes-oney-auth-intro_ul_gyh_p5y_byb}  
The authorization service also responds with a reason code as the apAuthReply_reasonCode field value.  
For more information about reason codes, see the [Reason Codes for the Simple Order API](https://developer.cybersource.com/docs/cybs/en-us/reason-codes-so/reference/all/so/reason-codes-so/reason-codes-so.md "").

Required Fields for Processing an Authorization {#thunes-oney-auth-req-fields}
==============================================================================

[apAuthService_cancelURL](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-auth-service-cancel-url.md "")
:

apAuthService_failureURL
:

apAuthService_preapprovalToken
:
Set the field value to the token generated by Thunes in the session service.

apAuthService_reconciliationID
:

[apAuthService_run](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-auth-service-run.md "")
:
Set the field value to `true`.

apAuthService_successURL
:

[apPaymentType](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-payment-type.md "")
:
Set the field value to `ONY`.

[billTo_city](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-city.md "")
:

[billTo_country](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-country.md "")
:

[billTo_email](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-email.md "")
:

[billTo_firstName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-first-name.md "")
:

[billTo_lastName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-last-name.md "")
:

[billTo_phoneNumber](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-phone-number.md "")
:

[billTo_postalCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-postal-code.md "")
:

[billTo_state](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-state.md "")
:

[billTo_street1](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-street1.md "")
:

[item_#_productCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-code.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_productDescription](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-description.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_productName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-name.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_productSKU](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-sku.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_quantity](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-quantity.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_taxAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-tax-amount.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_totalAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-total-amount.md "")
:
If this field is present, the purchaseTotals_currency field is optional.
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_unitPrice](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-unit-price.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[merchantID](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/merchant-id.md "")
:

[merchantReferenceCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/merchant-reference-code.md "")
:

paymentMethod_name
:

[purchaseTotals_currency](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-currency.md "")
:
Set to `EUR`.

[purchaseTotals_grandTotalAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-grand-total-amount.md "")
:
Set the field value to the value used for the purchaseTotals_grandTotalAmount field in the session service.

[shipTo_city](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-city.md "")
:

[shipTo_country](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-country.md "")
:

[shipTo_email](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-email.md "")
:

[shipTo_firstName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-first-name.md "")
:

[shipTo_lastName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-last-name.md "")
:

[shipTo_phoneNumber](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-phone-number.md "")
:

[shipTo_postalCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-postal-code.md "")
:

[shipTo_street1](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-street1.md "")
:
{#thunes-oney-auth-req-fields_dl_t55_fnx_yxb}

Optional Fields for Processing an Authorization {#thunes-oney-auth-opt-fields}
==============================================================================

Choose from these optional fields to include additional information when authorizing a payment.

billTo_company
:

[billTo_street2](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-street2.md "")
:

billTo_gender
:

billTo_language
:

[item_#_totalAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-total-amount.md "")
:
Replace the `#` character with a sequential number starting from `0`.

[item_#_taxAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-tax-amount.md "")
:
Replace the `#` character with a sequential number starting from `0`.

merchantDefinedData_mddField_#
:
Replace the `#` character with a sequential number starting from `0`.

[purchaseTotals_taxAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-tax-amount.md "")
:

shipTo_company
:

[shipTo_street2](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ship-to-street2.md "")
:

Example: Processing an Authorization {#thunes-auth-ex-so}
=========================================================

Request

```keyword
&lt;requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.213"&gt;
	&lt;merchantID&gt;test_merchant&lt;/merchantID&gt;
	&lt;merchantReferenceCode&gt;refnum-1234&lt;/merchantReferenceCode&gt;
	&lt;billTo&gt;
		&lt;firstName&gt;capyturereq&lt;/firstName&gt;
		&lt;lastName&gt;R&lt;/lastName&gt;
		&lt;street1&gt;Montorgueil&lt;/street1&gt;
		&lt;city&gt;paris&lt;/city&gt;
		&lt;postalCode&gt;75001&lt;/postalCode&gt;
		&lt;country&gt;FR&lt;/country&gt;
		&lt;phoneNumber&gt;+33623456789&lt;/phoneNumber&gt;
		&lt;email&gt;test@cybs.com&lt;/email&gt;
	&lt;/billTo&gt;
	&lt;shipTo&gt;
		&lt;firstName&gt;John&lt;/firstName&gt;
		&lt;lastName&gt;Smith&lt;/lastName&gt;
		&lt;street1&gt;Montorgueil&lt;/street1&gt;
		&lt;city&gt;Paris&lt;/city&gt;
		&lt;postalCode&gt;75001&lt;/postalCode&gt;
		&lt;country&gt;FR&lt;/country&gt;
		&lt;phoneNumber&gt;+33623456789&lt;/phoneNumber&gt;
	&lt;/shipTo&gt;
	&lt;item id="0"&gt;
		&lt;unitPrice&gt;20&lt;/unitPrice&gt;
		&lt;quantity&gt;10&lt;/quantity&gt;
		&lt;productCode&gt;4564&lt;/productCode&gt;
		&lt;productName&gt;Mobile&lt;/productName&gt;
		&lt;productSKU&gt;testI&lt;/productSKU&gt;
		&lt;taxAmount&gt;20&lt;/taxAmount&gt;
		&lt;totalAmount&gt;220&lt;/totalAmount&gt;
		&lt;productDescription&gt;MOBILE&lt;/productDescription&gt;
	&lt;/item&gt;
	&lt;purchaseTotals&gt;
		&lt;currency&gt;EUR&lt;/currency&gt;
		&lt;grandTotalAmount&gt;220&lt;/grandTotalAmount&gt;
	&lt;/purchaseTotals&gt;
	&lt;apPaymentType&gt;ONY&lt;/apPaymentType&gt;
	&lt;apAuthService run="true"&gt;
		&lt;cancelURL&gt;https://www.test.com&lt;/cancelURL&gt;
		&lt;successURL&gt;https://www.test1.com&lt;/successURL&gt;
		&lt;failureURL&gt;https://www.test2.com&lt;/failureURL&gt;
		&lt;preapprovalToken&gt;555316958762&lt;/preapprovalToken&gt;
	&lt;/apAuthService&gt;
&lt;/requestMessage&gt;
```

Response to a Successful Request

```
&lt;replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.213"&gt;
	&lt;merchantReferenceCode&gt;ref1695322932&lt;/merchantReferenceCode&gt;
	&lt;requestID&gt;6953229325326859903007&lt;/requestID&gt;
	&lt;decision&gt;ACCEPT&lt;/decision&gt;
	&lt;reasonCode&gt;100&lt;/reasonCode&gt;
	&lt;requestToken&gt;AxjnrwSTeO9w75jQgCAfANgZYjWmjCbQhSaEywojmiG8+n0h9XwMwIZNJMvRiy0P/Sbx3uHfMaEAQD4A6xDV&lt;/requestToken&gt;
	&lt;purchaseTotals&gt;
		&lt;currency&gt;EUR&lt;/currency&gt;
	&lt;/purchaseTotals&gt;
	&lt;apAuthReply&gt;
		&lt;reasonCode&gt;100&lt;/reasonCode&gt;
		&lt;status&gt;AUTHORIZED&lt;/status&gt;
		&lt;processorResponse&gt;00003&lt;/processorResponse&gt;
		&lt;amount&gt;220.00&lt;/amount&gt;
		&lt;dateTime&gt;2023-09-21T19:02:14Z&lt;/dateTime&gt;
		&lt;paymentStatus&gt;authorized&lt;/paymentStatus&gt;
		&lt;responseCode&gt;00003&lt;/responseCode&gt;
		&lt;authorizationCode&gt;1000&lt;/authorizationCode&gt;
		&lt;reconciliationID&gt;XFZ40MPBIPLX&lt;/reconciliationID&gt;
		&lt;processorTransactionID&gt;315778574151&lt;/processorTransactionID&gt;
	&lt;/apAuthReply&gt;
&lt;/replyMessage&gt;   
```

