# Card Verification Authorization

The second two-phase commit flow is a card verification authorization, and it actually involves three requests:

1. An initial authorization request for a small amount that only serves to save the card details. This is normally done upon customer registration, and there's no follow-up capture request after this.
2. A second authorization request that is performed when the customer is ready to make an actual purchase. This step must be performed on a terminal that does not require CVV entry.
3. A capture request that is a follow-up to (2) that charges the customer.

This flow is best explained with an example. Imagine that you are an Airbnb-like service. When a new user signs up for your service, you ask them to enter their credit card details. You do this to ensure that their credit card is valid and, more importantly, to save their credit card details that you can use to charge them later when they're ready to make a booking.

## Card verification request

During registration, you request a Hyp payment page configured for authorization and a small total — let's say, ₪1.

To do this, you need to send a [payment page request](/creditguard/payment-page-integration/integrating-hyps-payment-page-and-accepting-payment.md#create-a-payment-page-request) where inside the `doDeal` command, `mpiValidation` is set to `Verify`:

```xml
<ashrait>
      <request>
          <version>2000</version>
          <language>ENG</language>
          <command>doDeal</command>
          <doDeal>
              <terminalNumber>{terminalNumber}</terminalNumber>
              <cardNo>CGMPI</cardNo>
              <total>100</total>
              <transactionType>Debit</transactionType>
              <creditType>RegularCredit</creditType>
              <currency>ILS</currency>
              <transactionCode>Internet</transactionCode>
              <validation>TxnSetup</validation>
              <mid>{mid}</mid>
              <uniqueid>{uniqueId}</uniqueid>
              <mpiValidation>Verify</mpiValidation>
              <successUrl>{successUrl}</successUrl>
              <errorUrl>{errorUrl}</errorUrl>
          </doDeal>
      </request>
  </ashrait>
```

Extract and handle the returned payment page URL as usual.

When Hyp performs a [payment completion redirect](/creditguard/payment-page-integration/integrating-hyps-payment-page-and-accepting-payment.md#handle-payment-completion-redirect), save the values of the following URL parameters:

1. `cardToken`: the credit card token that Hyp generates and that you can use in further requests.
2. `cardExp`: the credit card expiration date.

{% hint style="info" %}
Some terminals also require the cardholder's Israeli ID number (תעודת זהות). In this case, you must save the ID number along with the token and expiration date. You receive the ID from the payment completion redirect as the `personalId` URL parameter and then use it in payment requests as the `id` parameter. Note that the Israeli ID number is considered sensitive personal data under privacy regulations such as the GDPR and the Israeli Privacy Law. As a merchant, you are responsible for ensuring the secure storage and handling of this information.
{% endhint %}

These are all the values you need to perform authorization requests at a later time. You don't need to perform a capture request for this authorization.

## Authorization request for a purchase amount

At some point later, which can be days or months after the customer registers, they are ready to make their first booking. They've selected an apartment and booking dates, and they click **Book**.

At this point, you need to send an authorization request for the cost of the booking for the selected dates. Although you know the customer has a valid credit card, you need to make sure it currently has sufficient funds to cover the booking.

The authorization request is a [standard Hyp API request](/creditguard/introduction/request-and-response-general-structure.md) where the `int_in` parameter contains the `doDeal` command payload with `validation` set to `Verify`:

```xml
<ashrait>
    <request>
        <version>2000</version>
        <language>ENG</language>
        <command>doDeal</command>
        <doDeal>
            <terminalNumber>{terminalNumber}</terminalNumber>
            <cardId>{cardToken}</cardId>
            <cardExpiration>{cardExp}</cardExpiration>
            <total>{totalAmount}</total>
            <transactionType>Debit</transactionType>
            <creditType>RegularCredit</creditType>
            <currency>ILS</currency>
            <transactionCode>Phone</transactionCode>
            <validation>Verify</validation>
            </doDeal>
    </request>
</ashrait>
```

Variable parameters of the `doDeal` command in an authorization request are:

* `terminalNumber`: a unique number assigned to you as a merchant during [registration](/creditguard/introduction/prerequisites-and-requirements.md).
* `cardId`: the card token you saved from the `cardToken` URL parameter in the payment completion redirect following card verification.
* `cardExpiration`: the card expiration date you saved from the `cardExp` URL parameter in the payment completion redirect following card verification.
* `total`: the total amount to charge, which should be equal to or greater than the cost of the customer's booking.
* `id`: the customer's Israeli ID, if required by the terminal, saved in the previous step from the `personalId` parameter.

Here's a sample response for a successful authorization request:

<details>

<summary>Show response</summary>

```xml
<?xml version='1.0'?>
<ashrait>
    <response>
        <command>doDeal</command>
        <dateTime>2025-08-19 21:24</dateTime>
        <requestId/>
        <tranId>119566148</tranId>
        <result>000</result>
        <message>Permitted transaction</message>
        <userMessage>Permitted transaction</userMessage>
        <additionalInfo>Host Result Remote 00-SUCCESS</additionalInfo>
        <version>2000</version>
        <language>Eng</language>
        <doDeal>
            <status>000</status>
            <statusText>Permitted transaction</statusText>
            <extendedStatus/>
            <extendedStatusText/>
            <extendedUserMessage/>
            <terminalNumber>0882819014</terminalNumber>
            <cardId>1092880571131111</cardId>
            <cardBin>411111</cardBin>
            <cardMask>411111******1111</cardMask>
            <cardLength>16</cardLength>
            <cardNo>xxxxxxxxxxxx1111</cardNo>
            <cardName/>
            <cardExpiration>0328</cardExpiration>
            <cardType code="99">Foreign</cardType>
            <extendedCardType code="0">Credit</extendedCardType>
            <blockedCard/>
            <lifeStyle/>
            <customCardType/>
            <creditCompany code="0">Foreign</creditCompany>
            <cardBrand code="2">Visa</cardBrand>
            <cardAcquirer code="6">Alphacard</cardAcquirer>
            <serviceCode/>
            <transactionType code="01">RegularDebit</transactionType>
            <creditType code="1">RegularCredit</creditType>
            <currency code="1">ILS</currency>
            <baseCurrency/>
            <baseAmount/>
            <transactionCode code="50">Phone</transactionCode>
            <total>100000</total>
            <firstPayment/>
            <periodicalPayment/>
            <numberOfPayments/>
            <clubId/>
            <validation code="5">Verify</validation>
            <idStatus code="0">Absent</idStatus>
            <cvvStatus code="3">NotValidated</cvvStatus>
            <authSource code="2">CreditCompany</authSource>
            <authNumber>1493217</authNumber>
            <fileNumber/>
            <slaveTerminalNumber/>
            <slaveTerminalSequence/>
            <eci/>
            <clientIp/>
            <email/>
            <cavv code=""/>
            <user/>
            <addonData/>
            <supplierNumber>300012</supplierNumber>
            <id/>
            <shiftId1/>
            <shiftId2/>
            <shiftId3/>
            <shiftTxnDate/>
            <cgUid>119566148</cgUid>
            <cardHash/>
            <acquirerData>
                <gateway>AshraitEmv</gateway>
                <acquirerTranType>01</acquirerTranType>
                <mcc>4121</mcc>
                <acquirerResponseId>618285345996</acquirerResponseId>
                <avsResponse code="0">Absent</avsResponse>
                <acquirerTranCode>50</acquirerTranCode>
            </acquirerData>
            <ashraitEmvData>
                <uid>25081921240108828191487</uid>
                <authCodeCreditCompany code="1">CreditCompanyAuthorized</authCodeCreditCompany>
                <idFlag>0</idFlag>
                <manufId>CGD</manufId>
                <catLevel>0</catLevel>
                <manufUse>001101</manufUse>
                <ashVersion>x</ashVersion>
                <ashTermType>0</ashTermType>
                <emvResponseCode>00</emvResponseCode>
                <deviceStatus>1111000000</deviceStatus>
                <ashReasonText>TIKRA, BAKASHA_LEISHUR_LELO_ISKA</ashReasonText>
                <authCodeAcquirer code="0">NoAuthNumber</authCodeAcquirer>
                <isDoReverseDeal>0</isDoReverseDeal>
                <mti>100</mti>
            </ashraitEmvData>
            <extendedTranCode/>
            <sendNotification/>
        </doDeal>
    </response>
</ashrait>
```

</details>

Save the `cgUid` value from the response, as you'll need it later for the capture request.

## Capture request

If the apartment owner confirms each booking manually, your service gives them a 24-hour window to approve or decline the booking.

If the owner rejects the booking, you simply don't perform a follow-up capture request. If the owner confirms the booking, that's when you're ready to perform the capture request to charge the customer.

A capture request is a [standard Hyp API request](/creditguard/introduction/request-and-response-general-structure.md) with the `doDeal` command payload in the `int_in` parameter:

```xml
<ashrait>
  <request>
      <version>2000</version>
      <language>ENG</language>
      <command>doDeal</command>
      <doDeal>
          <terminalNumber>{terminalNumber}</terminalNumber>
          <cardId>{cardToken}</cardId>
          <cardExpiration>{cardExp}</cardExpiration>
          <total>{total}</total>
          <transactionType>Debit</transactionType>
          <creditType>RegularCredit</creditType>
          <currency>ILS</currency>
          <transactionCode>Phone</transactionCode>
          <validation>AutoComm</validation>
          <cgUid>{cgUid}</cgUid>
      </doDeal>
</request>
</ashrait>
```

Variable parameters of the `doDeal` command in a capture request are:

* `terminalNumber`: a unique number assigned to you as a merchant during [registration](/creditguard/introduction/prerequisites-and-requirements.md).
* `cardId`: the card token saved from the `cardToken` URL parameter in the payment completion redirect following card verification. Alternatively, you can use the `cardId` from the authorization response.
* `cardExpiration`: the card expiration date saved from the `cardExp` URL parameter in the payment completion redirect following card verification. Alternatively, you can use the `cardExpiration` from the authorization response.
* `total`: the total amount to charge, which can be equal to or less than the authorized amount.
* `cgUid`: the ID that Hyp returned in the authorization response.

Here's a sample response for a successful capture request:

<details>

<summary>Show response</summary>

```xml
<?xml version='1.0'?>
<ashrait>
    <response>
        <command>doDeal</command>
        <dateTime>2025-08-19 21:34</dateTime>
        <requestId/>
        <tranId>119566257</tranId>
        <result>000</result>
        <message>Permitted transaction</message>
        <userMessage>Permitted transaction</userMessage>
        <additionalInfo>Host Result Local 00-SUCCESS</additionalInfo>
        <version>2000</version>
        <language>Eng</language>
        <doDeal>
            <status>000</status>
            <statusText>Permitted transaction</statusText>
            <extendedStatus/>
            <extendedStatusText/>
            <extendedUserMessage/>
            <terminalNumber>0882819014</terminalNumber>
            <cardId>1092880571131111</cardId>
            <cardBin>411111</cardBin>
            <cardMask>411111******1111</cardMask>
            <cardLength>16</cardLength>
            <cardNo>xxxxxxxxxxxx1111</cardNo>
            <cardName/>
            <cardExpiration>0328</cardExpiration>
            <cardType code="99">Foreign</cardType>
            <extendedCardType code="0">Credit</extendedCardType>
            <blockedCard/>
            <lifeStyle/>
            <customCardType/>
            <creditCompany code="0">Foreign</creditCompany>
            <cardBrand code="2">Visa</cardBrand>
            <cardAcquirer code="6">Alphacard</cardAcquirer>
            <serviceCode/>
            <transactionType code="01">RegularDebit</transactionType>
            <creditType code="1">RegularCredit</creditType>
            <currency code="1">ILS</currency>
            <baseCurrency/>
            <baseAmount/>
            <transactionCode code="50">Phone</transactionCode>
            <total>100000</total>
            <firstPayment/>
            <periodicalPayment/>
            <numberOfPayments/>
            <clubId/>
            <validation code="4">AutoComm</validation>
            <idStatus code=""/>
            <cvvStatus code=""/>
            <authSource code="3">VoiceMail</authSource>
            <authNumber>1493217</authNumber>
            <fileNumber>63</fileNumber>
            <slaveTerminalNumber>086</slaveTerminalNumber>
            <slaveTerminalSequence>452</slaveTerminalSequence>
            <eci/>
            <clientIp/>
            <email/>
            <cavv code=""/>
            <user/>
            <addonData/>
            <supplierNumber>300012</supplierNumber>
            <id/>
            <shiftId1/>
            <shiftId2/>
            <shiftId3/>
            <shiftTxnDate/>
            <cgUid>119566148</cgUid>
            <cardHash/>
            <acquirerData>
                <gateway>AshraitEmv</gateway>
                <acquirerResponseId>618285345996</acquirerResponseId>
                <mcc>4121</mcc>
                <acquirerTranType>01</acquirerTranType>
                <acquirerTranCode>50</acquirerTranCode>
            </acquirerData>
            <ashraitEmvData>
                <orgUid>25081921240108828191487</orgUid>
                <orgAuthCodeCreditCompany>1</orgAuthCodeCreditCompany>
                <orgAuthCodeAcquirer>0</orgAuthCodeAcquirer>
                <orgAuthNo>1493217</orgAuthNo>
                <orgAmount>100000</orgAmount>
                <orgTranDate>0819</orgTranDate>
                <orgCvvFlag>0</orgCvvFlag>
                <orgTranTime>212401</orgTranTime>
                <authCodeCreditCompany code="7">CreditCompanyPreAuthorized</authCodeCreditCompany>
                <uid>25081921240108828191487</uid>
                <idFlag>0</idFlag>
                <manufId>CGD</manufId>
                <catLevel>0</catLevel>
                <cvvFlag>0</cvvFlag>
                <manufUse>001101</manufUse>
                <ashVersion>x</ashVersion>
                <ashTermType>0</ashTermType>
                <deviceStatus>1111000000</deviceStatus>
                <authCodeAcquirer code="0">NoAuthNumber</authCodeAcquirer>
                <isDoReverseDeal>0</isDoReverseDeal>
                <mti>100</mti>
            </ashraitEmvData>
            <extendedTranCode/>
            <sendNotification/>
        </doDeal>
    </response>
</ashrait>
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.hyp.co.il/creditguard/two-phase-commits/card-verification-auth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
