PackagesPayment providers

@prood/payment-ifthenpay

Ifthenpay payment provider for Portugal — Multibanco, MB WAY, and credit card.

@prood/payment-ifthenpay implements the PaymentProvider interface for Ifthenpay — a Portuguese payment provider supporting Multibanco, MB WAY, and credit card payments.

Installation

Workspace package. Available from the source repo for now.

Usage

ts
import { IfthenpayPaymentProvider } from '@prood/payment-ifthenpay'

const provider = new IfthenpayPaymentProvider({
  antiPhishingKey: config.antiPhishingKey,
  mbKey: config.mbKey,
  mbWayKey: config.mbWayKey,
  ccKey: config.ccKey,
})

Configuration

FieldDescription
antiPhishingKeyAnti-phishing verification key
mbKeyMultibanco gateway key
mbWayKeyMB WAY gateway key. Optional
ccKeyCredit card gateway key. Optional

Each store enters these under Integrations in the dashboard. There is no environment fallback.

mbKey is required, since Multibanco is the default method. The other keys are optional, and each one unlocks its method at checkout.

Ifthenpay has no read-only call to test keys with, so they aren't tested on save. It has no refund API either: refunds happen in the Ifthenpay backoffice, then the merchant records them in the dashboard.

Selecting a method

Pass method on createSession() (defaults to multibanco):

methodKey usedResult
multibancombKeyEntity + reference in providerData
mbwaymbWayKeyMB WAY push; providerData.requestId
cardccKeyRedirect to Ifthenpay hosted card page
ts
const session = await provider.createSession({
  amount: 49.9,
  currency: 'EUR',
  orderId: 'ord_123',
  method: 'mbway',
  customer: { phone: '912345678' },
})

Reference-based methods (Multibanco) confirm asynchronously — the webhook callback is the source of truth, not a synchronous capture.

Factory usage

ts
import { getTenantPaymentProvider } from '@prood/commerce'

const { provider } = await getTenantPaymentProvider(orgId, 'ifthenpay')

Payment methods

MethodKeyFlow
MultibancombKeyEntity + reference; async ATM/homebanking payment
MB WAYmbWayKeyPhone push notification
Credit cardccKeyRedirect to Ifthenpay hosted page

Anti-phishing verification

Ifthenpay uses an anti-phishing key to verify webhook authenticity. The provider validates incoming webhooks against this key before processing.

Webhook setup

The integration form shows the callback URL for your store. Send it to Ifthenpay with your anti-phishing key:

https://checkout.example.com/api/webhooks/ifthenpay/{orgId}?key=[ANTI_PHISHING_KEY]&orderId=[ORDER_ID]&amount=[AMOUNT]&requestId=[REQUEST_ID]

Order ids are encoded to fit Ifthenpay's 25-character limit and decoded when the callback arrives.