SDK reference · Rails

@provenanceauth/rails/acp

@provenanceauth/rails/acp in the Rails: 16 methods. ACP (Agentic Commerce Protocol) mapping + merchant verification.

Methods

currencyExponent

currencyExponent(currency: string): number

The ISO 4217 minor-unit exponent for a currency (2 unless listed as 0- or 3-decimal).

toMinorUnits

toMinorUnits(amount: number, currency: string): number

Major units (Provenance) → integer minor units (ACP).

fromMinorUnits

fromMinorUnits(minor: number, currency: string): number

Integer minor units (ACP) → major units (Provenance).

provenanceToAcpAllowance

provenanceToAcpAllowance(source: AcpMandateSource | AcpIntentSource, opts: AcpAllowanceOptions): AcpAllowance

A Provenance mandate or intent → an ACP delegate-payment allowance.

acpRiskSignals

acpRiskSignals(token: string): AcpRiskSignal[]

The token's free risk claim ({ score, action }) → ACP risk_signals, so the merchant's PSP sees the same coarse score: { type: "provenance_intent", score, action }, with review → manual_review (ACP's word).

acpAllowanceToProvenance

acpAllowanceToProvenance(allowance: AcpAllowance): { constraints: { max_amount: number; allowed_counterparties: string[]; expires_at: string }; checkout_session_id: string; currency: string; }

The inverse mapping: an ACP allowance → mandate-shaped constraints plus its session facts.

acpTotalOf

acpTotalOf(session: Pick<AcpCheckoutSessionLike, "totals">): number

totals[type=total].amount of an ACP checkout session.

acpBindingFromSession

acpBindingFromSession(session: AcpCheckoutSessionLike, merchantId: string, origin: string): AcpBinding

The binding for a checkout session the merchant (or agent) holds, bound to the store's origin.

acpBindingPayload

acpBindingPayload(b: AcpBinding): AcpBinding

The exact object to pass as action_payload to POST /v1/mandate/intents, so the token's payload_hash binds this checkout.

acpBindingHash

acpBindingHash(b: AcpBinding): Promise<string>

Sha256(canonical JSON) of the binding, the value a bound token carries as payload_hash.

acpExtension

acpExtension(intentToken: string, opts: AcpExtensionOptions): { declaration: AcpExtensionDeclaration; identifier: string; field: { [ACP_EXTENSION_FIELD]: AcpProvenanceIntent } }

The extension for one completion: its capabilities.extensions declaration, the request-side identifier, and the field to spread into the complete request.

acpExtensionDeclaration

acpExtensionDeclaration(opts?: { schemaUrl?: string; specUrl?: string; profile?: DiscoveryBlock }): AcpExtensionDeclaration

The extension's capabilities.extensions[] declaration: both fields it adds, the complete request's provenance_intent and the session response's provenance_approval_request.

acpApprovalRequired

acpApprovalRequired(session: AcpCheckoutSessionLike, opts: AcpApprovalRequiredOptions): { message: AcpMessageError; field: { [ACP_APPROVAL_FIELD]: ApprovalRequest } }

Merchant side: ask for the shopper's approval inside an ACP session response.

acpApprovalRequestOf

acpApprovalRequestOf(session: unknown): ApprovalRequest | null

Agent side: the provenance_approval_request of a session response, or null.

withProvenanceIntent

withProvenanceIntent<T extends { payment_data: unknown }>(request: T, intentToken: string, opts: AcpExtensionOptions): T & { [ACP_EXTENSION_FIELD]: AcpProvenanceIntent }

Attach the extension field to a complete request (returns a new object).

verifyAcpCompletion

verifyAcpCompletion(request: AcpCompleteRequest | null | undefined, opts: AcpVerifyOptions): Promise<AcpVerifyResult>

Merchant side: verify a CheckoutSessionCompleteRequest carrying the extension.

Was this page helpful? Send us feedback

LLM? Read llms.txt.