---
title: "Authorize transaction"
description: "You can use this call to authorize an existing Google Pay transaction using the CM.com Online Payments API."
canonical: "https://docs.cm.com/payments/online-payments/guides/google-pay/authorize-transaction"
---

# Authorize transaction

> You can use this call to authorize an existing Google Pay transaction using the CM.com Online Payments API.

Source: https://docs.cm.com/payments/online-payments/guides/google-pay/authorize-transaction

You can use this call to authorize an existing Google Pay transaction using the CM.com Online Payments API.

## Prerequisite

Get an `access_token` and use it as 'Bearer' token in your request. Find more details [here](https://docs.cm.com/payments/online-payments/guides/authorization).

## Request

```text
POST https://api.pay.cm.com/api/v1/paymentmethods/google-pay/v1/transactions/{transactionId}/authorize
```

When the customer has selected a card in the payment sheet, the details are returned as `paymentData`  by the Google payments client. The retrieved `paymentData.paymentMethodData` must be sent as-is in the request body to this endpoint.

## Response

```json
{
  "id": "8db1e7fa-ba8a-4189-92fd-67a20217443d",
  "orderId": "8db1e7fa-ba8a-4189-92fd-67a20217443d",
  "reference": "20210623130413",
  "amount": 1200,
  "currency": "EUR",
  "description": "Order at yourdomain.tld",
  "expiresAt": "2006-01-02T15:04:05Z",
  "language": "nl",
  "country": "NL",
  "webhooks": [
    {
      "url": "https://yourdomain.tld/order-webhooks?purchaseId=order123",
      "events": [
        "FINALSTATUS"
      ]
    },
    {
      "url": "https://yourdomain.tld/payment-webhooks?purchaseId=order123",
      "events": [
        "REFUND_STATUS"
      ]
    },
    {
      "url": "https://yourdomain.tld/payment-webhooks?purchaseId=order123",
      "events": [
        "STATUS_CHANGE"
      ]
    }
  ],
  "status": "OPEN",
  "details": {
    "merchantCountry": "DE",
    "gatewayId": "example-gateway",
    "environment": "TEST",
    "merchantId": "exampleMerchantId",
    "merchantName": "www.example.com",
    "merchantKey": "8db1e7fa-ba8a-4189-92fd-67a20217443d",
    "allowedCardNetworks": [
      "AMEX"
    ],
    "serverUrl": "https://www.example.com/api/"
  },
  "action": {
    "redirect": {
      "url": "https://checkout.tld/3ds/v2/creditcard/123"
    }
  },
  "createdAt": "2006-01-02T15:04:05Z",
  "refunds": {
    "refundedAmount": 300,
    "refundedPendingAmount": 100
  },
  "returnUrls": {
    "success": "https://yourdomain.tld/order/payment-success.html",
    "cancelled": "https://yourdomain.tld/order/payment-cancelled.html",
    "expired": "https://yourdomain.tld/order/payment-expired.html",
    "failed": "https://yourdomain.tld/order/payment-failed.html"
  }
}
```

## Parameters

| Parameter | Type | Description | Constraints |
| - | - | - | - |
| id | String(36) | Transaction unique identifier. | |
| orderId | String(36) | Unique identifier. | |
| reference | String(1...255) | An identifier specified by you. If webhooks were specified in the request this identifier is added to the webhook request payload. | Specified in the `initialize transaction` request. |
| amount | Int(1...99999999) | Integer representing the amount of the checkout. Denomination in the smallest currency subunit (e.g. eurocents). | Specified in the `initialize transaction` request. |
| currency | String (ISO 4217) | Currency code. | Specified in the `initialize transaction` request. |
| description | String(1...255) | Description of the transaction. | Specified in the `initialize transaction` request. |
| expiresAt | String(RFC3339) | Expiration time. | ISO 8601 date and time. |
| language | String(ISO 639-1) | Preferred language of the user interface. | Specified in the `initialize transaction` request. |
| country | String | Country of the Customer. | Specified in the `initialize transaction` request. |
| status | String | `OPEN` - Transaction has been created. This is the initial status.  <br />`SUCCESS` - Transaction successfully paid.  <br />`CANCELLED` - Transaction has been cancelled by your customers.  <br />`EXPIRED` - Transaction has not succeeded; expired.  <br />`FAILURE` - Transaction has not succeeded; unknown reason.  <br />`AUTHORIZED` - Transaction is authorized. | |
| createdAt | String(RFC3339) | Creation time. | ISO 8601 date and time. |
| returnUrl | String(2000) | Specifies the URL where your customers will be redirected to. | Specified in the `initialize transaction` request. |
| returnUrls | [returnUrls](https://docs.cm.com/payments/online-payments/guides/google-pay/schemas#returnurls)   Object | Specifies a URL where your customers will be redirected to per transaction status. For example, your customers will be redirected to `returnUrls.success` when the status of the transaction changes to `SUCCESS`. | Specified in the `initialize transaction` request. |

## Optional parameters

| Parameter | Type | Description | Constraints |
| :- | :- | :- | :- |
| webhooks | Array of objects | Webhooks enable receiving a web request once a given event occurs. | Specified in the `initialize transaction` request. |
| details | [details](https://docs.cm.com/payments/online-payments/guides/google-pay/schemas#details)       Object | These are the details used  to render the Google Pay button in your own page. | This is nullable. |
| action | [action](https://docs.cm.com/payments/online-payments/guides/google-pay/schemas#action)      Object | The next action to be performed by you for this transaction. This includes a URL where you should `redirect` your customer to. | This is nullable. |
| refunds | [refund](https://docs.cm.com/payments/online-payments/guides/google-pay/schemas#refund)   Object | Indicates refundedAmount and refundedPendingAmount. | |

## Response codes

| HTTP status | Description |
| :- | :- |
| 201 | Transaction authorized. |
| 4XX | Client error response (See message for details). This response is given when the user input was incorrect or something illegal was attempted (eg. using a service without having that service configured for the user, or not being authorized). |
| 5XX | Server error response (See message for details). |
