> ## Documentation Index
> Fetch the complete documentation index at: https://developer.novacpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apple Pay and Google Pay

> Learn how to accept Apple Pay and Google Pay on a secure Novac page without handling card details.

## Overview

Apple Pay and Google Pay let your customers pay on a secure Novac page, so your system never handles their card details. You choose the experience by adding the optional `paymentMethod` field to your payment request.

If you leave out `paymentMethod`, Novac uses `card`, the standard flow you get when you accept a hosted checkout payment. The field accepts three values:

* `card`: The standard card flow.
* `apple_pay`: A Novac page with Apple Pay only.
* `hosted_card`: A Novac page with card, plus Apple Pay or Google Pay where available.

> [!NOTE]
>
> To offer Google Pay, set `paymentMethod` to `hosted_card`. This option shows Apple Pay and Google Pay where they're available.

## Prerequisites

> [accordion] See details
>
> Before you accept Apple Pay or Google Pay, make sure you have:
>
> * [Obtained your API keys](https://developer.novacpayment.com/docs/getting-started/obtain-api-keys.md).
> * Asked [support@novacpayment.com](mailto:support@novacpayment.com) to turn on `apple_pay`, `hosted_card` or both.
> * Turned on international payments for your account.
> * Set up a [webhook](https://developer.novacpayment.com/docs/api-basics/webhooks.md) to receive the final result.

***

> [!NOTE]
>
> * Use one of these currencies: `USD`, `GBP`, `EUR`, `CAD` or `AUD`. Always send `currency`.
> * Apple Pay and Google Pay don't support `NGN` payments.
> * Only one-time `sale` payments are supported. Authorize-and-capture and recurring payments aren't supported.
> * These payment methods don't return card details or reusable card tokens.
> * Contact support before you refund a hosted payment. See [Refund a Transaction](https://developer.novacpayment.com/docs/accept-payment/manage-payment/refund-transaction.md).

***

## How it works

```mermaid theme={null}
sequenceDiagram
    autonumber
    actor Customer as Customer (Browser)
    participant Server as Your Server
    participant Novac as Novac

    Server->>Novac: Card payment request (paymentMethod: apple_pay or hosted_card)
    Novac-->>Server: redirectUrl (the Novac payment page)
    Server->>Customer: Open the payment page in the browser
    Customer->>Novac: Pay on the Novac payment page
    Note over Customer,Novac: Extra checks such as 3D Secure happen here
    Novac->>Server: Webhook with the final result
    opt Customer comes back
        Novac-->>Customer: Redirect to your return URL with ?reference=ORDER-7F3K9Q2M8X4T
        Customer->>Server: Browser opens /payment/complete?reference=...
    end
    Server->>Novac: Verify the payment using the reference
    Novac-->>Server: Verified payment status
    Note over Server: Deliver only after verification
```

Your server starts the payment and sends the customer to Novac's payment page. The customer pays and completes any extra checks, such as 3D Secure. When the payment is completed, Novac sends your server a webhook. That webhook is how you reliably receive every payment status, because the customer may close the page and never return.

If the customer does return, Novac sends them to your return URL.

```text theme={null}
https://example.com/payment/complete?reference=ORDER-7F3K9Q2M8X4T
```

This happens after both successful and failed payments. The URL carries no status, and anyone can edit a URL, so use the reference only to find the order. Then verify the payment with Novac before you deliver anything.

> [!NOTE]
>
> The `redirectUrl` you send in your request is where Novac sends customers after they pay. It can be a page on your website or app. If you don't send one, Novac uses the callback URL set on your dashboard and adds the reference to it. If neither is set, the customer sees a Novac receipt instead.

***

## Choose an endpoint

You can set up these payment methods in three ways: a direct card charge with card encryption, a direct card charge without card encryption, or a custom checkout.

| Your integration | Endpoint | Key to use |
| - | - | - |
| Direct card charge | **POST** `/api/v1/direct-card-charge` | Secret key |
| Direct card charge (no card encryption) | **POST** `/api/v1/card-charge` | Secret key |
| Custom checkout | **POST** `/api/v1/card-payment` | Public key |

***

## Start a direct payment

Send a [POST request](https://developer.novacpayment.com/api-reference/collections/direct-card-charge.md) to `/api/v1/direct-card-charge`. Leave out the card details, because the customer enters them on the Novac page.

```bash Apple Pay request theme={null}
# start-apple-pay-payment.sh
curl --request POST \
  --url https://api.novacpayment.com/api/v1/direct-card-charge \
  --header 'Authorization: <your-secret-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "amount": 10.50,
    "currency": "USD",
    "reference": "ORDER-7F3K9Q2M8X4T",
    "email": "customer@example.com",
    "redirectUrl": "https://example.com/payment/complete",
    "paymentMethod": "apple_pay"
  }'
```

To offer card payment and the supported wallets (Apple Pay or Google Pay) on the same page, use `"paymentMethod": "hosted_card"`.

```json expandable Response theme={null}
{
  "status": true,
  "message": "Proceed to complete the payment",
  "data": {
    "authMode": "3ds",
    "authAction": "redirect",
    "authEndpoint": "v1/transaction/ORDER-7F3K9Q2M8X4T/verify",
    "authMessage": "Redirect the customer to the redirect url",
    "friendlyMessage": "Proceed to complete the payment",
    "redirectUrl": "https://api.novacpayment.com/payer/auth/hosted/ORDER-7F3K9Q2M8X4T"
  }
}
```

This response shows that the payment has started. `authMode` is `3ds`, `authAction` is `redirect`, and `authEndpoint` is `v1/transaction/ORDER-7F3K9Q2M8X4T/verify`. To use `authEndpoint`, add the Novac base URL `https://api.novacpayment.com/api/` before it.

***

## Start a custom checkout payment

**1. Step 1 - Create the transaction**

Create the transaction with a [POST request](https://developer.novacpayment.com/api-reference/checkout/initiate-checkout.md) to `/api/v1/initiate`. Include the customer's email and your return URL in this request.

**2. Step 2 - Complete the payment**

Send a [POST request](https://developer.novacpayment.com/api-reference/custom-checkout/complete-card-payment.md) to `/api/v1/card-payment` with the same transaction reference and your `paymentMethod`.

```bash Request theme={null}
# start-hosted-card-payment.sh
curl --request POST \
  --url https://api.novacpayment.com/api/v1/card-payment \
  --header 'Authorization: <your-public-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "transactionReference": "ORDER-7F3K9Q2M8X4T",
    "paymentMethod": "hosted_card"
  }'
```

```json expandable Response theme={null}
{
  "status": true,
  "message": "Proceed to complete the payment",
  "data": {
    "authMode": "3ds",
    "authAction": "redirect",
    "authEndpoint": "v1/checkout/{transactionReference}/verify",
    "authMessage": "Redirect the customer to the redirect url",
    "friendlyMessage": "Proceed to complete the payment",
    "redirectUrl": "https://api.novacpayment.com/payer/auth/hosted/ORDER-7F3K9Q2M8X4T"
  }
}
```

Direct card charge and custom checkout return similar responses, but `authEndpoint` for custom checkout is `v1/checkout/{transactionReference}/verify`.

While the transaction is still `pending`, you can call this endpoint again to switch between `apple_pay` and `hosted_card`. After the customer submits a payment, you can't switch while Novac processes it.

> [!NOTE]
>
> Don't send `APPLEPAY` or `HOSTEDCARD` in `allowedPaymentOptions` when you initiate the checkout payment, because Novac rejects the request. Choose the method later with `paymentMethod`. The payment options returned by `/api/v1/initiate` don't show whether these methods are turned on for you.

***

## Redirect the customer to the payment page

Open `data.redirectUrl` in the customer's browser.

```javascript Redirect the customer theme={null}
// redirect-customer.js
window.location.assign(response.data.redirectUrl);
```

* Use the URL exactly as Novac returns it. Don't build it yourself or depend on its format, because it may change.
* Open it in the full browser window if you can. If you use an iframe, add `allow="payment"`, then test each wallet and 3D Secure, because some browsers may still block them.
* Keep the whole page visible, including its legal notice. The notice tells customers who the seller is and which terms apply, so don't cover, crop or hide it.

Customers enter an email address on the `hosted_card` page, because Novac doesn't fill in the email you sent. With `apple_pay`, the Apple Pay sheet asks for an email address. The name on the customer's card statement may be different from your business name.

### Wallet availability

Wallets only appear on supported devices and browsers, when they're available for your account. If Apple Pay isn't available on the `apple_pay` page, the customer sees a message asking them to choose another payment method. Always offer another way to pay.

If you draw your own Apple Pay button, follow [Apple's button guidelines](https://developer.apple.com/design/human-interface-guidelines/apple-pay).

***

## Retry safely

* **Request timed out:** Novac may still have created your payment. Check it with the verify endpoint and the same reference before you try again.
* **Duplicate reference on a direct payment:** this can happen even if the customer hasn't paid. Use the `redirectUrl` you saved, or check the payment status. Direct endpoints don't return the URL again, so save it when you first receive it.
* **Customer reloads the page:** they can use the same `redirectUrl`. While Novac processes a payment, the page doesn't let the customer pay again.
* **Payment not accepted:** if the page says it couldn't process the payment and offers another try, the customer can try again on the same page.
* **Payment failed:** use a new reference to start another payment.

***

## What's next?

* [Verify a transaction](https://developer.novacpayment.com/docs/accept-payment/manage-payment/verify-transaction.md)
* [Set up webhooks](https://developer.novacpayment.com/docs/api-basics/webhooks.md)
* [See common errors for Apple Pay and hosted card payments](https://developer.novacpayment.com/docs/api-basics/errors.md#apple-pay-and-hosted-card-errors)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.