AlyaPay Documentation
API Integration

Create Transaction

Create a new BNPL transaction via partner API

Create Transaction

Create a new Buy Now, Pay Later transaction. The transaction starts in PENDING status and the customer receives an SMS to confirm.

Endpoint

POST /api/v1/public/partner/transactions

Authentication

X-Service-Key: <your-api-key>

Request body

FieldTypeRequiredDescription
customerPhonestringYesCustomer phone — digits only, no + (e.g. 212612345678)
totaldecimalYesTotal amount in MAD
currencystringYesMust be MAD
itemsarrayYesAt least 1 item required
items[].namestringYesProduct name (max 200 chars)
items[].referencestringNoProduct SKU (max 100 chars)
items[].quantityintegerYesMin: 1
items[].unitPricedecimalYesUnit price in MAD (min: 0.01)
items[].categoryIdlongNoProduct category ID
vendorReferencestringNoYour unique order ID — returned in webhooks for matching

Example

curl -X POST https://api.alyapay.com/api/v1/public/partner/transactions \
  -H "X-Service-Key: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "customerPhone": "212612345678",
    "total": 1500.00,
    "currency": "MAD",
    "vendorReference": "ORDER-001",
    "items": [
      {
        "name": "iPhone 15",
        "reference": "SKU-001",
        "quantity": 1,
        "unitPrice": 1500.00,
        "categoryId": 1
      }
    ]
  }'

Response 201

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "orderReference": "ALY-20260626-001",
  "vendorReference": "ORDER-001",
  "status": "PENDING",
  "totalAmount": 1500.00,
  "currency": "MAD",
  "customerPhone": "212612345678",
  "merchantName": "Acme",
  "storeName": "Main Store",
  "items": [
    {
      "id": "uuid",
      "name": "iPhone 15",
      "reference": "SKU-001",
      "quantity": 1,
      "unitPrice": 1500.00,
      "categoryId": 1
    }
  ],
  "createdAt": "2026-06-26T09:00:00Z",
  "updatedAt": null
}

Transaction statuses

StatusDescription
PENDINGCreated, waiting for customer confirmation
APPROVEDCustomer confirmed — webhook sent
CANCELEDCanceled by merchant or system
EXPIREDCustomer did not confirm within the agreed expiry period

Common errors

StatusDescription
400Validation error (missing field, invalid phone format)
401Invalid or missing API key
409vendorReference already exists for this merchant
422Business rule violation (amount limits, inactive merchant, credit limit)