Skip to content

API Payments

Dory Azar edited this page Nov 15, 2026 · 2 revisions

Payments

Caligrafy Quill 2.26.0. Generated from the source by php qa/build-api-reference.php; the guides explain how to use these classes, this reference says exactly what each public method takes and returns. Back to the API reference.

Stripe and cryptocurrency payments.

Class What it is
Caligrafy\Payment The Payment handles all payment transactions
Caligrafy\CryptoPayment CryptoPayment accepts crypto payments (USDC) through the Coinbase Business Checkouts API.

class Caligrafy\Payment

namespace Caligrafy;

class Payment extends \stdClass

Source: framework/core/Payment.php:19

The Payment handles all payment transactions

Methods

->__construct()

public function __construct()

Constructs the Payment Controller to initiate the Stripe api

Source: framework/core/Payment.php:48

->createTransaction()

public function createTransaction(
    $amount,
    $currency,
    $card,
    $receipt_email = null,
    $metadata = null,
    $description = '',
    $transfer = array(),
    $save = false
)

Creates a new payment transaction

Parameters

  • $amount Integer: defines the amount of the transaction in cents
  • $currency string: defines the currecy of the transaction
  • $card Object: takes the card object submitted
  • $receipt_email string, default null: takes the customer email
  • $metadata string, default null: defines the metadata information that can be passed on to the transaction
  • $description string, default '': defines the description that can be passed on to the transaction
  • $transfer, default array()
  • $save boolean, default false: defines whether the transaction should be saved or not for a particular customer

Returns $result: to report on the result of the creation

Source: framework/core/Payment.php:78

->createPaymentIntent()

public function createPaymentIntent(
    $amount,
    $currency,
    $metadata = array(),
    $receipt_email = null,
    $description = '',
    $transfer = array()
)

Creates a new payment transaction that might require a customer authentication flow (3DSecure for example)

Parameters

  • $amount Integer: defines the amount of the transaction in cents
  • $currency string: defines the currecy of the transaction
  • $metadata string, default array(): defines the metadata information that can be passed on to the transaction
  • $receipt_email string, default null: defines the email address where the receipt should be sent
  • $description string, default '': defines a description of the product beind sold
  • $transfer array, default array(): defines the transfer data to vendors if they exist. keys possible: 'destination' for connected stripe account. 'amount' to define the amount the vendor will receive

Returns $result: to report on the result of the creation

Source: framework/core/Payment.php:124

->retrieveIntent()

public function retrieveIntent($intentId)

Retrieve Payment Intent

Parameters

  • $intentId string

Returns $result: to report on the result of the creation

Source: framework/core/Payment.php:158

->createCheckout()

public function createCheckout(
    $amount = 1000,
    $currency = 'usd',
    $quantity = 1,
    $productData = array(),
    $successUrl = '',
    $cancelUrl = '',
    $customerEmail = null,
    $locale = null,
    $paymentType = null,
    $payment_intent_data = array(),
    $vendor = array()
)

Creates a new integrated checkout session

Parameters

  • $amount Integer, default 1000: defines the amount of the transaction in cents
  • $currency string, default 'usd': defines the currency of the transaction
  • $quantity string, default 1: defines the quantity of products
  • $productData string, default array(): defines the product information that can be passed on to the transaction
  • $successUrl string, default '': defines the url that it will redirect to when successful payment
  • $cancelUrl string, default '': defines the url that it will redirect to when the payment fails
  • $customerEmail, default null
  • $locale, default null
  • $paymentType array, default null: defines the different payment methods to be supported by checkout
  • $payment_intent_data array, default array(): . Potential attributes: 'application_fee_amount' for charging vendors
  • $vendor array, default array(): . Potential array keys: 'stripe_account' for the vendor account

Returns $result: to report on the result of the creation

Source: framework/core/Payment.php:193

->retrieveCheckout()

public function retrieveCheckout($sessionId)

Retrieve Checkout Session

Parameters

  • $sessionId string

Returns $result: to report on the result of the creation

Source: framework/core/Payment.php:256

->createAccount()

public function createAccount(
    $email = null,
    $country = null,
    $type = 'express',
    $capabilities = array(),
    $accountInformation = array()
)

No doc comment.

Parameters

  • $email, default null
  • $country, default null
  • $type, default 'express'
  • $capabilities, default array()
  • $accountInformation, default array()

Source: framework/core/Payment.php:283

->createAccountLink()

public function createAccountLink($accountId, $refreshUrl, $returnUrl, $type = 'account_onboarding')

No doc comment.

Parameters

  • $accountId
  • $refreshUrl
  • $returnUrl
  • $type, default 'account_onboarding'

Source: framework/core/Payment.php:314

->createLoginLink()

public function createLoginLink($accountId)

No doc comment.

Parameters

  • $accountId

Source: framework/core/Payment.php:333

->updateAccount()

public function updateAccount($accountId, $updates)

No doc comment.

Parameters

  • $accountId
  • $updates

Source: framework/core/Payment.php:350

->retrieve()

public function retrieve($accountId)

No doc comment.

Parameters

  • $accountId

Source: framework/core/Payment.php:365

->getPublicKey()

public function getPublicKey()

Accessor that returns the public key

Source: framework/core/Payment.php:386

class Caligrafy\CryptoPayment

namespace Caligrafy;

class CryptoPayment extends \stdClass

Source: framework/core/CryptoPayment.php:26

CryptoPayment accepts crypto payments (USDC) through the Coinbase Business Checkouts API.

Coinbase Commerce (api.commerce.coinbase.com, CRYPTO_PAY_KEY) shut down on March 31, 2026. Its successor is the Checkouts API of Coinbase Business (https://business.coinbase.com/api/v1/checkouts), available to merchants in the supported countries. Requests are authenticated with a short-lived JWT signed with a CDP API key:

  • COINBASE_API_KEY_NAME: the key name, e.g. organizations/{org_id}/apiKeys/{key_id}
  • COINBASE_API_KEY_SECRET: the Ed25519 secret (base64) or the ECDSA private key (PEM, legacy keys)

Methods

->__construct()

public function __construct($keyName = null, $keySecret = null)

Parameters

  • $keyName string, default null: CDP API key name (defaults to COINBASE_API_KEY_NAME)
  • $keySecret string, default null: CDP API key secret (defaults to COINBASE_API_KEY_SECRET)

Source: framework/core/CryptoPayment.php:53

->createTransaction()

public function createTransaction(
    $amount,
    $currency,
    $charge = array(),
    $metadata = array(),
    $redirectUrl = '',
    $cancelUrl = '',
    $expiresAt = null
)

Creates a hosted checkout (single-use payment page)

Parameters

  • $amount string|float: the amount (2 decimals at most)
  • $currency string: USDC or a fiat currency (USD, EUR, GBP, SGD...) converted to USDC at creation
  • $charge array, default array(): 'name' and 'description' of the product
  • $metadata array, default array(): up to 20 string pairs
  • $redirectUrl string, default '': HTTPS URL to come back to after a successful payment
  • $cancelUrl string, default '': HTTPS URL to come back to after a failed payment
  • $expiresAt string, default null: RFC 3339 expiration date (default: 24 hours)

Returns array: ['action_success' => bool, 'url' => hosted payment page, 'data' => checkout (data['hosted_url'] kept for older code)]

Source: framework/core/CryptoPayment.php:72

->cancelTransaction()

public function cancelTransaction($id)

Deactivates an active checkout so that it can no longer be paid

Parameters

  • $id

Source: framework/core/CryptoPayment.php:96

->refundTransaction()

public function refundTransaction($id, $amount = null, $currency = 'USDC', $reason = '')

Refunds a completed checkout (full refund when $amount is null)

Parameters

  • $id
  • $amount, default null
  • $currency, default 'USDC'
  • $reason, default ''

Source: framework/core/CryptoPayment.php:104

->getCharges()

public function getCharges($filters = array())

Lists the checkouts. $filters: status, startTime, endTime, descriptionQuery, pageSize, pageToken

Parameters

  • $filters, default array()

Source: framework/core/CryptoPayment.php:115

->getCharge()

public function getCharge($chargeId)

Retrieves a checkout by id

Parameters

  • $chargeId

Source: framework/core/CryptoPayment.php:124

->getChargeStatus()

public function getChargeStatus($chargeId)

Returns the status of a checkout: ACTIVE, PROCESSING, COMPLETED, EXPIRED, FAILED, DEACTIVATED, REFUNDED, PARTIALLY_REFUNDED, or 'unknown'

Parameters

  • $chargeId

Source: framework/core/CryptoPayment.php:133

->coinbaseRequest()

public function coinbaseRequest($requestPath, $requestMethod, $body = null, $additionalHeaders = array())

Sends an authenticated request to the Checkouts API

Parameters

  • $requestPath
  • $requestMethod
  • $body, default null
  • $additionalHeaders, default array()

Returns array: ['action_success' => bool, 'data' => decoded response] or ['action_success' => false, 'error' => message]

Source: framework/core/CryptoPayment.php:143

->jwt()

public function jwt($method, $path)

Builds the JWT that authenticates one request (valid 120 seconds) Ed25519 keys (base64, 64 bytes) are signed with EdDSA, PEM EC keys with ES256

Parameters

  • $method
  • $path

Source: framework/core/CryptoPayment.php:169

Caligrafy: Describe it. Approve it. Ship it. Your idea turned into a complete app: every feature built once, for web pages, Vue apps, a REST API and AI agents, and online.

Start here

Why Caligrafy: the benefits, the measurements, and what it is not yet

  1. Quickstart with Claude: describe it, approve it, ship it

    or the Quickstart: the same three steps by hand, in 5 minutes

  2. How Caligrafy works: the ideas in 5 minutes
  3. Your first capability: build a feature, page included

Capabilities

Experiences

Data and people

  1. Models
  2. Relationships
  3. Queries: filters, paging, related rows
  4. Sign-in, users and tokens

Built-in features

Put it online

Build with AI

Reference

Clone this wiki locally