Skip to content

Payments

Protokol Payments enables online payment processing through supported payment gateways. It supports the full transaction lifecycle — authorization, purchase, capture, void, refund — and card tokenization for recurring payments.

Note

This integration is currently geolocked to Serbia (RS).


Overview

Key characteristics:

  • Transaction lifecycle — authorization, purchase, capture, void, and refund operations
  • Payment links — generate hosted payment pages for checkout flows
  • Card tokenization — securely store card tokens for recurring payments
  • Direct token payments — charge stored tokens without redirect
  • Transaction reporting — workflow events on transaction status changes
  • Provider support — monri, stripe and braintree (the unified routes also accept wspay; do not use it for new work)

Generate a hosted payment page that redirects the customer to complete payment.

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()
const { data: link } = await payments.getPaymentLink("monri", {
  totalAmount: "1500,00",
  currency: "RSD",
  description: "Order #456",
  redirectUrl: "https://myapp.com/payment/complete",
  lang: "en",
})

console.log(link) // { paymentLink: "https://...", transactionId: "...", ... }
curl -X POST https://lemon.protokol.io/luma/integrations/v1/payments/monri/getPaymentLink \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "totalAmount": "1500,00",
    "currency": "RSD",
    "description": "Order #456",
    "redirectUrl": "https://myapp.com/payment/complete",
    "lang": "en"
  }'

Payment with Line Items

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()
const { data: link } = await payments.getPaymentLink("monri", {
  currency: "RSD",
  items: [
    { name: "Widget A", pricePerUnit: 500, quantity: 2, price: 1000 },
    { name: "Shipping", price: 350 },
  ],
  description: "Order #456",
  redirectUrl: "https://myapp.com/payment/complete",
})

Listing Transactions

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()
const { data: result } = await payments.getTransactions({
  status: "completed",
  sortBy: "createdAt",
  sortDirection: "desc",
  limit: 20,
  page: 1,
})

console.log(result.items)  // Transaction[]
console.log(result.total)  // total matching count
curl -X GET "https://lemon.protokol.io/luma/integrations/v1/payments/list?status=completed&limit=20&page=0" \
  -H "Authorization: Bearer $TOKEN"

Getting a Single Transaction

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()
const { data: tx } = await payments.getTransaction("tx-id-789")

console.log(tx.status)  // "completed"
console.log(tx.amount)  // 1500
curl -X GET https://lemon.protokol.io/luma/integrations/v1/payments/tx-id-789 \
  -H "Authorization: Bearer $TOKEN"

Transaction Fields

Field Type Description
provider string Payment provider (e.g. "monri")
transactionId string Transaction ID (use it for getTransaction, refund, voidTransaction, ...)
amount number Transaction amount (minor units)
precision number Decimal precision
currency string Currency code
status string pending, completed, failed, refunded, voided, deactivated, expired
description string Transaction description
paymentLink string Payment page URL (if applicable)
autoRefund boolean Whether auto-refund is enabled
metadata object Additional metadata (lang, items)
logs array Status change log entries
expiresAt string Expiration timestamp
createdAt string Creation timestamp

Void, Refund, and Deactivate

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()

// Void a pending transaction
await payments.voidTransaction("tx-id-789")

// Refund a completed transaction
await payments.refund("tx-id-789")

// Deactivate a payment link
await payments.deactivatePaymentLink("tx-id-789")
# Void
curl -X POST https://lemon.protokol.io/luma/integrations/v1/payments/tx-id-789/void \
  -H "Authorization: Bearer $TOKEN"

# Refund
curl -X POST https://lemon.protokol.io/luma/integrations/v1/payments/tx-id-789/refund \
  -H "Authorization: Bearer $TOKEN"

Card Tokenization

Request a token for storing card details for future payments.

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()

// Get a tokenization link (redirects user to enter card)
const { data: tokenLink } = await payments.getTokenRequestLink("monri", {
  description: "Save card for recurring billing",
  redirectUrl: "https://myapp.com/card-saved",
})

// Charge a stored token directly
const { data: tx } = await payments.directPayUsingToken("monri", {
  totalAmount: "2000,00",
  currency: "RSD",
  description: "Monthly subscription",
  token: "stored-card-token",
})

Provider Settings

import { Payments } from "@ptkl/sdk/beta"

const payments = new Payments()
const { data } = await payments.settings("monri")

console.log(data.provider)
console.log(data.settings)

Workflow Integration

Transaction Events

Event When
integration.payment.transaction.report Transaction status changed (created, completed, failed, refunded, etc.)

Permissions

Permission Description
view_transactions View transaction list and details
create_authorization_transaction Create authorization-only transactions
create_purchase_transaction Create purchase (direct charge) transactions
void_transaction Void pending transactions
refund_transaction Refund completed transactions
capture_transaction Capture authorized transactions
tokenize_card Request card tokenization
use_tokenized_card Charge stored card tokens

CLI

Payments is also available via the Protokol Toolkit CLI as a typed interface under ptkl integration:

ptkl integration payments link --provider monri \
  --total-amount 15,00 --currency RSD --description "Order #456" \
  --redirect-url https://myapp.com/payment/complete

ptkl integration payments list --status completed
ptkl integration payments refund --tx tx-id-789

See ptkl integration payments for the full subcommand reference.


Using in Platform Functions

const { Payments } = $sdk.version('0.10')
const payments = new Payments()

// Create payment link for an order
const { data: link } = await payments.getPaymentLink("monri", {
  totalAmount: $input.body.amount, // e.g. "1500,00"
  currency: "RSD",
  description: "Order #" + $input.body.order_id,
  redirectUrl: $input.body.redirect_url,
})

response.json({
  payment_url: link.paymentLink,
  transaction_id: link.transactionId,
})

SDK Reference

Every method returns the HTTP response; the result is in .data.

The Payments class is available via the SDK:

import { Payments } from "@ptkl/sdk/beta"

// Or via the Integrations facade
import { Integrations } from "@ptkl/sdk/beta"
const integrations = new Integrations()
const payments = integrations.getPayments()
Method Description
payments.getPaymentLink(provider, options) Generate a hosted payment link
payments.getTransactions(params?) List transactions with filtering
payments.getTransaction(txId) Get a single transaction
payments.voidTransaction(txId) Void a pending transaction
payments.refund(txId) Refund a completed transaction
payments.deactivatePaymentLink(txId) Deactivate a payment link
payments.cancel(txId) Cancel a transaction
payments.settings(provider) Get provider configuration
payments.getTokenRequestLink(provider, options) Request card tokenization link
payments.directPayUsingToken(provider, options) Charge a stored card token