Skip to main content
Authorization decision lets you approve or decline card transactions in real time. UQPAY sends a PGP-encrypted transaction payload to your endpoint. You decrypt it, make a decision, and return an encrypted response. The SDK handles all PGP encryption and decryption. You only write the business logic.

Generate a PGP key pair

Generate a key pair and send the public key to UQPAY. Store the private key securely.
import { generateAuthDecisionKeyPair } from '@uqpay/sdk'

const { publicKey, privateKey } = await generateAuthDecisionKeyPair({
  name: 'Acme Corp',
  email: 'issuing.tech@acme.com',
})

Configure PGP keys

After creating the client, configure the PGP keys once. You can pass file paths (.asc, .pgp, .gpg) or armored key strings:
await client.issuing.authDecision.configure({
  privateKey: './keys/my-private.asc',
  uqpayPublicKey: './keys/uqpay-public.asc',
  passphrase: process.env.PGP_PASSPHRASE, // optional
})

Create the handler

Use createHandler to build an Express-compatible request handler. You only need to implement the decide callback:
const handler = client.issuing.authDecision.createHandler({
  decide: async (transaction) => {
    // transaction contains: billing_amount, merchant_name, card_id, etc.
    if (transaction.billing_amount > 10000) {
      return { response_code: '51' } // Insufficient Funds
    }
    return { response_code: '00', partner_reference_id: 'ref-001' }
  },
  onError: (err) => console.error('Auth decision error:', err),
})

app.post('/auth-decision', handler)
The SDK automatically injects transaction_id into the response and handles all PGP encryption and decryption.

How it works