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

# Payra for Adobe Commerce

> Accept card, Apple Pay, Google Pay, US bank account (ACH) and Canadian bank account (EFT) payments at your Adobe Commerce or Magento Open Source checkout.

Payra for Adobe Commerce is a Magento 2 extension (Composer package `payra/module-adobe-commerce`, module
`Payra_Commerce`) that adds up to four payment methods to the checkout: **card**, **US bank account (ACH)** and
**Canadian bank account (EFT)** fields inside your checkout, and **Pay with Payra**, which sends the customer to a
[hosted checkout](https://docs.payra.com/hosted-checkout.md) page and back. Card and bank details are entered in secure fields rendered by
[Payra Elements](https://docs.payra.com/elements.md); your store never sees a card or account number. From version 1.1.0 the card method can
also show **Apple Pay** and **Google Pay** buttons above its fields (see
[Apple Pay and Google Pay](#apple-pay-and-google-pay)).

Cards are charged in **USD or CAD**, US bank accounts in **USD** and Canadian bank accounts in **CAD**, following the
order currency; each option hides itself on any other currency. Signed-in customers can save a card for later
orders. Refunds are issued from credit memos, and signed [webhooks](https://docs.payra.com/webhooks.md) plus a cron job keep every order in
step with its payment. A **Test mode** switch runs the whole flow on your sandbox keys.

## Requirements

* Adobe Commerce (on-premises or on cloud infrastructure) or Magento Open Source **2.4.7, 2.4.8 or 2.4.9**.
* The default Luma-based checkout. Headless and PWA storefronts, and checkouts that replace Magento's own (such as
  Hyvä Checkout), are not supported. The Payra options are not offered on orders created in the Admin.
* **Magento's cron running** on the server (`bin/magento cron:install`). It finishes the orders whose webhook never
  arrived, and looks into charges whose answer was lost.
* A storefront served over **https** on a publicly reachable host. Payra only delivers webhooks to an `https` URL
  on a public host, and the Payra checkout page and 3-D Secure send the customer back to it.
* A Payra account with the API enabled. Sandbox and live are separate workspaces with separate keys; see
  [Environments](https://docs.payra.com/environments.md).
* For card payments in **CAD**, a workspace Payra has set up for Canadian dollars, in sandbox and in live; without
  it, card payments in CAD can fail, at checkout and on the Payra page. Ask Payra before you take CAD orders.
* For US bank accounts, an ACH processor on the workspace. For Canadian bank accounts, Canadian pre-authorized
  debits set up on the workspace; without them the option shows *Bank account payments are temporarily
  unavailable. Please try again in a moment.*
* For Apple Pay and Google Pay (from version 1.1.0), [wallets](https://docs.payra.com/wallets.md) turned on for the workspace by Payra, and
  your store's domain registered for each wallet. Without wallets on the workspace the buttons do not show; on a
  domain that is not registered they show, but the payment fails when tapped.

## Install

**1. Get the extension**

Get **Payra** on the
[Adobe Commerce Marketplace](https://commercemarketplace.adobe.com/payra-module-adobe-commerce.html) (it is
free), signed in with the Marketplace account whose access keys your store uses to install extensions.

**2. Install it**

In your store's root folder, run:

```bash theme={null}
composer require payra/module-adobe-commerce
bin/magento module:enable Payra_Commerce
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
```

On a live store, run `bin/magento maintenance:enable` first and `bin/magento maintenance:disable` at the end.

**3. On Adobe Commerce on cloud infrastructure**

Run `composer require payra/module-adobe-commerce` in your project, commit `composer.json` and
`composer.lock` (and `app/etc/config.php`, with `Payra_Commerce` enabled, if your project keeps it), and
push. The deployment runs the other commands.

## Configure

Open **Stores → Configuration → Sales → Payment Methods** and expand **Payra**, under **Other Payment Methods**.
Every setting is global: one Payra account per installation.

| Field | What it takes |
| - | - |
| **Enable Payra** | Turns the extension on. Off by default. |
| **Test mode** | *Use the sandbox keys; no real money moves.* On by default. |
| **Sandbox publishable key** / **Live publishable key** | `pk_test_…` / `pk_live_…` |
| **Sandbox secret key** / **Live secret key** | `sk_test_…` / `sk_live_…`, stored encrypted. |
| **Sandbox webhook secret** / **Live webhook secret** | `whsec_…`, from the endpoint registered on that workspace. |
| **Webhook URL** | Read only: the URL to register in Payra (see [Webhooks](#webhooks)). |
| **Validate connection** | Checks the **saved** secret key of the active mode. |

Each key field only accepts a key with its own prefix, so a live key cannot end up behind **Test mode**. With
**Test mode** on, checkouts use the sandbox keys; off, the live ones. An order keeps the environment it was paid in:
its webhooks, cron checks and refunds use that environment's keys and secret.

Each payment method has its own group, with a **Title**, a **Description** and a **Sort order**:

| Group | Switch | Default |
| - | - | - |
| **Credit or debit card** | *Accept cards in your checkout*. **Let customers save cards** offers signed-in customers to keep the card (see [Saved cards](#saved-cards)). **Show Apple Pay and Google Pay buttons above the card fields**, with **Button layout**, **Button color** and **Button text** (see [Apple Pay and Google Pay](#apple-pay-and-google-pay)). | On, saving on, wallet buttons off. |
| **Bank account (ACH)** | *Accept bank account (ACH) payments*. | Off. |
| **Canadian bank account (EFT)** | *Accept Canadian bank account (EFT) payments*. | Off. |
| **Payra checkout page** | *Offer the Payra checkout page*. Cards are always accepted on the page; **Also accept bank accounts on the Payra page** adds US bank accounts on USD orders, and **Also accept Canadian bank accounts on the Payra page** Canadian ones on CAD orders. | Off. |
| **Appearance** | How the card and bank fields look (see [Appearance](#appearance)). | Payra Elements' own look. |

A method is offered at checkout only when **Enable Payra** and its own switch are on, both keys of the active mode
are saved and the order currency is one it charges; the Payra checkout page also needs an `https` store URL.
Offering the checkout page next to the card fields gives the customer two ways to pay by card; consider offering
only one.

**1. Create the keys**

In the Payra dashboard, open **Settings → Integrations** and, under **API keys**, create a publishable key and a
secret key in the workspace you are connecting, leaving every scope selected on the secret key (saving cards needs
`customers:write`). Each key is shown in full only once: paste it in the field of the matching mode before
you close the window.

**2. Register the webhook**

In **Settings → Integrations**, under **Webhooks**, select **Add endpoint**, paste the **Webhook URL** shown in
your store's Payra settings and leave every event selected. Paste the `whsec_` secret Payra shows (also only
once) in the webhook secret field of that workspace's mode.

**3. Save and validate**

Select **Save Config**, then **Validate connection**. It answers with the workspace the key reaches, such as
*Connected to My Workspace (sandbox).*

**4. Go live**

Repeat the keys and the webhook on the live workspace, set **Test mode** to **No**, save, and select **Validate
connection**: it should name your live workspace. Place a small order with a real card and refund it.

> [!NOTE]
>
> Keep the webhook registered and its secret pasted on **both** workspaces. The store processes the events of both
> environments, each checked with its own secret, so switching **Test mode** never loses a settlement, a return or
> a refund of the other one.

## Appearance

The **Appearance** group sets how the card and bank fields look, so they match your theme without any CSS. A field
left empty, or set to its default, is not sent to Payra Elements; any other value is.

| Option | What it changes | Default |
| - | - | - |
| **Background** | The inside of every field. | `#ffffff` |
| **Border** | The border of a field at rest. | `#d5d7da` |
| **Corner radius** | How round the corners are, 0 to 24 px. | 8 px |
| **Height** | The height of every field, 36 to 64 px. | 44 px |
| **Text** | What the customer types. | `#181d27` |
| **Placeholder** | The hint inside an empty field. | `#717680` |
| **Size** | The size of the text, 12 to 20 px. | 16 px |
| **Focus** | The border and glow of the field being typed in, and the bank account's radios and checkbox. | `#2e90fa` |
| **Error** | The border of a field with an error. | `#d92d20` |

The options apply at checkout and on **Add a card** under **My Account**, not on the Payra checkout page. The font
is not an option: the fields are rendered inside secure frames that your theme's web fonts do not reach. The Apple
Pay and Google Pay buttons take the **Height** and **Corner radius**.

## Apple Pay and Google Pay

From version 1.1.0, the card method can show **Apple Pay** and **Google Pay** buttons above the card fields,
followed by *Or pay with card*. The customer taps a button, confirms on their device, and the order is placed and
charged as a card payment.

Three things decide whether a button shows:

* **The extension.** **Show Apple Pay and Google Pay buttons above the card fields** is **Yes** in the **Credit or
  debit card** group. It is **No** by default.
* **Payra.** Payra turns [wallets](https://docs.payra.com/wallets.md) on for your workspace. A workspace without them refuses the wallet
  sessions (`payment_provider_not_configured`); the extension then hides the buttons, shows no error, and asks
  again after 10 minutes, or right away once you save other keys.
* **The device.** Each customer sees only the wallets their browser and device can pay with.

| Setting | Choices | Default |
| - | - | - |
| **Button layout** | *Stacked*, one under the other, or *Side by side*, which goes back to one under the other on a narrow screen. A single wallet takes the whole width. | Stacked |
| **Button color** | *Black*, *White*, or *White with outline* (Apple's outlined button; Google draws its white one). | Black |
| **Button text** | *Logo only*, *Buy with*, *Pay with* or *Check out with*, before the wallet's logo. | Logo only |

**Domains.** Before going live, send your Payra contact every hostname of your store that shows the buttons. Apple
Pay only works on a [registered domain](https://docs.payra.com/apple-pay.md#register-your-domains), and Google reviews each domain for
[Google Pay](https://docs.payra.com/google-pay.md#register-your-domains) on live. While the buttons are on, the extension serves the domain
association file Apple reads, at
`https://your-store.example/.well-known/apple-developer-merchantid-domain-association`, so there is nothing to
upload. If that address does not answer `200` (a web server that answers `/.well-known/` itself instead of passing
it to Magento), ask your Payra contact for the file and place it there.

> [!WARNING]
>
> Magento's Payment Services serves PayPal's Apple Pay file at the same address. While Payra's buttons are on, the
> extension answers it with Payra's file instead, so do not run PayPal's Apple Pay through Payment Services on the
> same store.

**What the customer goes through.**

1. Each button has its own [session](https://docs.payra.com/wallets.md#accept-a-wallet-payment) for the grand total. When the total changes
   (a coupon, the shipping method, tax), the buttons get new sessions for the new total.
2. The customer taps a button, and the wallet's sheet shows your business name and the total.
3. Once they confirm, the order is placed with that session, through the same **Place Order** step the card fields
   use, so Magento's own checks on the payment step (the terms and conditions, for example) run first. If one fails,
   nothing is charged, the customer reads *Please complete the required fields, then pay again.*, and pays again with
   the button. The sheet does not hand over an address or a name, which is why the buttons are on the payment step
   and not on the product or cart page.
4. The store charges the session with `payment_method_session` for exactly that total.

The order follows the payment like any card order (see [How a payment flows](#how-a-payment-flows)), and its
payment block shows the wallet: **Apple Pay** or **Google Pay** as the method, and a **Wallet** row. A card paid
through a wallet is never saved, even with saving on, and a saved card selected in the vault is not charged instead.

Two refusals tell the customer what to do, and nothing is charged in either: *Your order total changed after you
confirmed the payment. Please pay again.* when the cart changed after the sheet, and *Apple Pay and Google Pay are
not available right now. Please pay with your card.* when your workspace stopped offering wallets.

**Testing.** In **Test mode**, Google Pay runs in Google's test environment: any Google account with a card can pay
and no money moves. Apple Pay needs a registered `https` domain and a device signed in with an Apple sandbox tester
account (see [Test Apple Pay](https://docs.payra.com/apple-pay.md#test-apple-pay)).

## Webhooks

The extension exposes one webhook endpoint, your store's base URL followed by `payra/webhook/index`:

```text theme={null}
https://your-store.example/payra/webhook/index
```

Register it on each workspace you use, with every event selected (the default), or at least every `payment.`,
`refund.` and `checkout_session.` type. Payra does not follow redirects: use the URL exactly as the **Webhook URL**
field shows it.

> [!WARNING]
>
> If you offer bank accounts, the webhook and Magento's cron are required: a bank debit settles after checkout, and
> `payment.succeeded`, or the cron job when the webhook is missed, is what moves the order from **Awaiting bank
> debit confirmation** to **Processing**.

Each delivery is checked against the webhook secret of its environment, a sandbox event can never move an order
paid live, and a delivery already applied is ignored. For a payment, the extension reads its current status from the
API before moving the order. The `payra_reconcile` cron job, which runs every 10 minutes, reads from the API the
orders still waiting in **Payment Review** that have not changed for a while (an order on the Payra page once its
page has expired) and finishes those a missed webhook left waiting.

## How a payment flows

1. The payment step asks your store for a [payment method session](https://docs.payra.com/payment-method-sessions.md); the secret key never
   leaves the server. With the wallet buttons on, it also asks for an `apple_pay` and a `google_pay` session for the
   grand total. Payra Elements shows the secure fields, and for a bank account the ACH authorization or the
   Canadian pre-authorized debit (PAD) agreement, which the customer must accept.
2. On **Place Order**, the session is confirmed in the browser and only its `pms_` id reaches the store, which
   charges it for the order's grand total, with the order number as `reference`. The order's lines go with the
   charge only when they add up to the grand total to the cent and fit the API's limits; otherwise it goes without
   them. On a store served over `https`, a card charge also sends a `return_url` for
   [3-D Secure](https://docs.payra.com/payments.md#3-d-secure).
3. The order then follows the payment's status, at the charge and on every webhook, return and cron check:

| Payment status | Order |
| - | - |
| `succeeded` | **Processing**, with the invoice paid. |
| `processing`, `authorized` | **Payment Review**: **Awaiting bank debit confirmation** for a bank debit, **Awaiting card confirmation** for a card (`authorized` is a card payment Payra is still capturing). On `succeeded` it moves to **Processing**, and a bank order's customer is emailed that the debit was confirmed (when Magento's **Order Comments** email is enabled). |
| `requires_action` | **Payment Review**, **Awaiting card verification**: at the charge, the customer is sent to verify the card (see [3-D Secure](#3-d-secure)); learned only after an unknown outcome, the order gets a comment that the customer must be contacted. Without an `https` verification page from Payra, it is **Awaiting card confirmation** instead. |
| `failed` | At the charge, no order is placed (see Declines). Later, an order in Payment Review is **Canceled**. |
| `returned` | A paid order gets **Payment returned, action needed** and is put **On Hold** unless it is complete or closed. An order in Payment Review is **Canceled**. |
| `canceled` | After a full refund, only a comment. Otherwise as `returned`. |

**Declines.** A declined charge leaves no order behind: the customer stays on the checkout with the cart as it was
and reads why under the fields, in the extension's own words. When Payra names a reason a card was declined that the
customer can fix (an expired card, a wrong number, expiration date or security code, an amount over the card's limit, a cardholder name
without first and last name), the sentence says it; otherwise it follows the decline code, with its own sentence
for a failed 3-D Secure check. The fields are cleared for another try.

> [!WARNING]
>
> If the outcome of a charge cannot be known (for example, Payra does not answer even after a retry), the order
> waits in **Payment Review** as **Payra charge outcome unknown**, and the customer is told they will not be charged
> twice. Do not charge the order again: the cron job looks for the payment or replays the identical request, and
> when it cannot settle the order it adds a comment asking you to look the order number up in Payra.

### 3-D Secure

When the card's bank asks to verify the customer, the order confirmation page sends the customer to Payra's
verification page or the bank's, and then back to the store. A verified payment lands on the order confirmation; a
refused one cancels the order and takes the customer back to the cart with *Your bank could not verify this
payment. Please try again or use another card.* Payra fails a verification left unfinished after 15 minutes, and
the order is then canceled.

### Payra checkout page

**Pay with Payra** shows no fields; its **Continue to payment** button sends the customer to a [checkout
session](https://docs.payra.com/hosted-checkout.md) for the order total, with the order's lines under the same rule as a charge. The order waits in
**Payment Review** as **Awaiting payment on the Payra page** until the payment is confirmed, then moves as in the
table above. A payment for anything other than the order's exact total is not applied, and the order gets a comment
to review it. If the workspace is not set up for Canadian pre-authorized debits, a CAD page opens for cards only and
an order comment says so.

A declined card on the page leaves the order pending while the customer tries again there. If the customer goes
back to the store from the page, the order is canceled and the cart is restored. A page left unpaid expires after
24 hours and its order is canceled.

## Saved cards

With **Let customers save cards** on, a signed-in customer can tick **Save this card for later orders** at
checkout. Payra keeps the card once the payment succeeds, and your store keeps only a Magento vault token pointing
at it. The next checkout lists the card, for example *Visa •••• 1111 (expires 03/30)*, and charges it without the
card fields.

A saved card can be charged only in the currency it was saved in: the order's currency for a card saved at
checkout, and US dollars for a card added under **My Account** unless the customer is set to Canadian dollars in
Payra. The extension lists saved cards on USD and CAD orders alike, so on an order in another currency the charge
fails with *Your payment could not be processed. Please try again.*

Under **My Account → Stored Payment Methods** the customer sees their cards, removes one (it is detached in Payra
too) or selects **Add a card** to save one without an order. Payra verifies that card with a small authorization the
processor voids at once, which may show on the customer's statement as pending for a short while.

Saving needs a US ZIP or Canadian postal code on the billing address and the `customers:write` scope on the secret
key. A workspace whose customers come from an ERP cannot create customers through the API; there, customers pay
without saving.

## Managing orders

The payment block of each order shows the method, the card or account (for example *Visa •••• 1111*), the Payra
payment id (`pay_…`) to look up in the dashboard, and why the order is waiting. The extension adds these order
statuses:

| Status | Meaning | What to do |
| - | - | - |
| **Awaiting bank debit confirmation** | A bank debit was submitted and has not settled yet. | Wait. A debit not confirmed after 7 days gets a comment asking you to check it in Payra. |
| **Awaiting card confirmation** | Payra is confirming or capturing the card payment. | Wait. |
| **Awaiting card verification** | The card's bank is verifying the customer (3-D Secure). | Wait, unless an order comment says the customer must be contacted. |
| **Awaiting payment on the Payra page** | The customer was sent to the Payra page. | Wait. |
| **Payra charge outcome unknown** | The charge's outcome is not known yet. | Do not charge again (see above). |
| **Payment returned, action needed** | Money went back after the order was paid: a bank return, a chargeback, or a void in Payra. | Review the order, then refund or cancel as appropriate. |
| **Payra refund failed, action needed** | A pending refund failed at the processor. | The credit memo stays; refund again from the order. |

Orders in **Payment Review** have three buttons. **Get Payment Update** applies the payment's current status.
**Accept Payment** is refused until Payra confirms the payment. **Deny Payment** cancels the order in Magento; on an
order waiting on the Payra page it first closes that page. It is refused, with a message saying why, when Payra
already reports a final status, while the customer is paying on the Payra page, and on a charge whose outcome is
unknown until the cron job hands it over to you. Otherwise it does not stop the payment in Payra: a payment
still in progress there can succeed after the order was denied, and the order then gets a comment to review it,
since the money was captured. Magento offers no credit memo, invoice or shipment while an order is in Payment Review.

## Refunds

Open the order, go to **Invoices**, open the invoice and select **Credit Memo**. Set the quantities or an
**Adjustment Refund** for a partial refund, then select **Refund**. **Refund Offline** only records the refund in
Magento and sends nothing to Payra.

The refund goes to Payra for the credit memo's amount; on success the order gets a comment. When Payra refuses it,
no credit memo is created and the Admin shows why. Partial refunds go one at a time: while one is `pending`, the next
is refused. A bank debit can be refunded once it has settled and the order is in **Processing**. A retry after a
timeout replays the refund already made instead of making a second one.

**Refund on the day of the payment.** A card refund made before the processor's nightly batch is a [same-day card
refund](https://docs.payra.com/refunds.md#same-day-card-refunds): a full one voids the payment when the processor still can; otherwise, and
for a partial one, the refund stays `pending` until after the batch, and a comment says when it goes through. If the
processor then refuses it, the order gets a comment and, when it is in **Processing**, moves to **Payra refund
failed, action needed**.

> [!NOTE]
>
> A refund made in the Payra dashboard is recorded as an order comment (*Made in the Payra dashboard: …*), without a
> credit memo. Create one with **Refund Offline** if you need the order to reflect it.

## Updates and removal

New versions arrive through Composer: run `composer update payra/module-adobe-commerce`, then the same
`bin/magento` commands as in [Install](#install). Orders, statuses and settings are kept.

To remove the extension, run `bin/magento module:uninstall Payra_Commerce --remove-data`. It removes the Payra
settings (with the encrypted keys and webhook secrets), the extension's two tables and the Payra order statuses no
order carries. Your orders, and the statuses they still carry, are kept.

## Troubleshooting

**The Payra options are not offered at checkout.** Check **Enable Payra**, the method's own switch, both keys of
the active mode, and the order currency (USD or CAD for cards and the Payra page, USD for US bank accounts, CAD for
Canadian bank accounts). The Payra page also needs your store on `https`.

**The fields never load, or show *Card payments are temporarily unavailable. Please try again in a moment.* (or
*Bank account payments are temporarily unavailable. Please try again in a moment.*).** Check that both keys of the
active mode are correct and that your server can reach Payra's API host. The extension allows Payra's hosts in its
Content Security Policy; a custom CSP rule or a proxy that strips scripts can still block them. A visitor over the
session limit sees *Too many attempts. Please wait a few minutes and try again.*

**The Apple Pay or Google Pay button does not show.** Check **Show Apple Pay and Google Pay buttons above the card
fields** and that the card method is offered, then ask your Payra contact whether wallets are on for the workspace of
the keys in use. Each device only shows the wallets it can pay with: Apple Pay needs `https` and an Apple device.
A domain that is not registered does not hide the buttons: tapping Apple Pay there shows *The payment could not be
completed. Please try again or pay with card.* under the buttons, and on live Google shows an error when the
customer taps Google Pay.
After updating the extension, run `bin/magento setup:static-content:deploy`: the checkout loads its scripts by their
integrity hashes, and a stale one keeps the card method from loading.

**Validate connection says *The secret key is not valid.*** Check that the saved key was pasted whole and is still
active: a key can be revoked or rotated, and when Payra switches a workspace between sandbox and live it revokes
every key of that workspace (see [Environments](https://docs.payra.com/environments.md)).

**Validate connection says *This key belongs to the other environment.*** The key no longer matches its workspace's
environment. Create a new key, paste it in the field of the active mode and save.

**A bank order stays in Awaiting bank debit confirmation.** That is normal until the debit settles; in the sandbox
a Canadian debit can take longer than a US one (see [Testing](https://docs.payra.com/testing.md#canadian-bank-accounts-eft)). If it never
moves, check that Magento's cron runs and that the webhook is registered with its secret pasted.

**A *Test mode* line appears above the fields.** That is expected while **Test mode** is on. Above the card fields
it reads *Test mode: use a test card such as 4111 1111 1111 1111 with expiration date 03/2030 and security code
737.* [Testing](https://docs.payra.com/testing.md) lists the values the sandbox accepts for cards and bank accounts.

**A webhook answers `400`, `409` or `503`.** `invalid_signature`: the secret of that environment is missing or does
not match the endpoint, or the signature is more than five minutes old. `lane_mismatch`: the event's environment
disagrees with its ids or with the order's. `409 in_progress`: another delivery of the same event is being handled; Payra retries it.
`503 gateway_unavailable`: **Enable Payra** is off or no webhook secret is saved.

**Anything else.** Failures are written to `var/log/payra.log` with the `request_id` Payra answered, never with card
data, request bodies or keys. When you contact [Payra support](mailto:support@payra.com), include your store's
address, the extension version, the order number, the `pay_` id from the order page and the `request_id`.


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