Bibliotecas SDK

Swift SDK

Install the official MakePay Swift SDK for payment links, settings, checkout URLs, and webhook verification.

MakePay Swift SDK

Overview

The MakePay Swift SDK is a Swift Package Manager library for trusted backend integrations and Swift services. It wraps API-key authentication, payment-link operations, donation pages, anonymous links, customers, subscriptions, POS terminals, products, Simple Shop, bookkeeping, branding, operational APIs, hosted checkout URL helpers, and signed webhook verification.

Public source repository:

https://github.com/makecryptoio/makepay-swift-sdk

Official Swift Package Index listing:

https://swiftpackageindex.com/makecryptoio/makepay-swift-sdk

Installation

Add the package to Package.swift:

dependencies: [
    .package(url: "https://github.com/makecryptoio/makepay-swift-sdk.git", from: "0.3.0")
]

Then add MakePay to your target dependencies:

.target(
    name: "YourApp",
    dependencies: ["MakePay"]
)

The SDK supports Swift Package Manager and uses swift-crypto for portable HMAC verification.

Authentication

Create a MakePay API key from the MakeCrypto merchant developer area and keep the key secret only on trusted backend infrastructure.

import MakePay

let makepay = MakePayClient(
    keyID: ProcessInfo.processInfo.environment["MAKEPAY_KEY_ID"]!,
    keySecret: ProcessInfo.processInfo.environment["MAKEPAY_KEY_SECRET"]!
)

Do not ship MakePay API key secrets inside iOS, macOS, tvOS, or watchOS apps. Client apps should call your backend or open public hosted checkout URLs.

The SDK sends X-MakeCrypto-Key-Id and X-MakeCrypto-Key-Secret headers to the MakePay partner API.

let response = try await makepay.createPaymentLink(
    MakePayPaymentLinkPayload(
        amount: "129.99",
        currency: "USDT",
        title: "Order #1042",
        description: "Checkout for order #1042",
        orderID: "order_1042",
        customerEmail: "buyer@example.com",
        returnURL: URL(string: "https://merchant.example/orders/1042"),
        successURL: URL(string: "https://merchant.example/orders/1042/success"),
        failureURL: URL(string: "https://merchant.example/orders/1042/pay"),
        expirationTime: "12h"
    )
)

let paymentLink = response["paymentLink"]?.objectValue
let publicURL = paymentLink?["publicUrl"]?.stringValue

Send a MakePay payment request email during creation:

try await makepay.createPaymentLink(
    payload,
    sendPaymentRequestEmail: true
)

Embedded Checkout

Use hosted checkout URLs for redirects, or the embedded URL when your frontend keeps the shopper on the merchant page.

let hostedURL = try makepay.hostedCheckoutURL(paymentUID: "PAYMENT_LINK_UID")

let embeddedURL = try makepay.embeddedCheckoutURL(
    paymentUID: "PAYMENT_LINK_UID",
    parentOrigin: URL(string: "https://merchant.example")
)

let modalScriptURL = makepay.modalScriptURL()
let buttonHTML = try makepay.embedButtonHTML(paymentUID: "PAYMENT_LINK_UID")
let iframeHTML = try makepay.iframeHTML(paymentUID: "PAYMENT_LINK_UID")

For mobile applications, generate the payment link on your backend, then open the hosted MakePay URL from app code.

try await makepay.listPaymentLinks()
try await makepay.getPaymentLink("PAYMENT_LINK_UID")
try await makepay.updatePaymentLink("PAYMENT_LINK_UID", status: .paused)
try await makepay.sendPaymentRequestEmail("PAYMENT_LINK_UID", email: "buyer@example.com")

Donations

try await makepay.createDonationLink(
    MakePayDonationLinkPayload(
        defaultAmountUSD: "25",
        minimumAmountUSD: "5",
        donationSlug: "spring-campaign",
        title: "Spring campaign"
    )
)

try makepay.hostedDonationURL(donationSlug: "spring-campaign")
try makepay.embeddedDonationURL(
    donationSlug: "spring-campaign",
    parentOrigin: URL(string: "https://merchant.example")
)

try await makepay.listDonationLinks()
try await makepay.updateDonationLink("DONATION_UID", status: .paused)

Anonymous links do not use an API key. Include the settlement route explicitly.

try await createAnonymousPaymentLink([
    "amount": "25",
    "title": "Invoice #1042",
    "webhookUrl": "https://merchant.example/webhooks/makepay",
    "settlement": [
        "currency": "USDT",
        "priorities": [
            [
                "chain": "ETH",
                "address": "0xYourSettlementWallet",
                "asset": "ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7",
            ],
        ],
    ],
])

Customers, Subscriptions, POS, And Shop

Advanced payloads use MakePayObject, an alias for [String: JSONValue].

try await makepay.upsertCustomer([
    "email": "buyer@example.com",
    "name": "Buyer Example",
    "clientId": "crm_123",
])

try await makepay.createCustomerPortal(
    customerID: "CUSTOMER_ID",
    payload: ["returnUrl": "https://merchant.example/account"]
)

try await makepay.createSubscription([
    "amountUsd": "29",
    "customerEmail": "buyer@example.com",
    "label": "Monthly plan",
    "billingIntervalUnit": "month",
    "billingIntervalCount": 1,
])

try await makepay.createPosTerminal([
    "name": "Front counter",
    "pin": "1234",
    "catalogEnabled": true,
])

try await makepay.createProduct([
    "name": "Digital guide",
    "productType": "digital",
    "basePriceUsd": "19",
])

try await makepay.updateShop([
    "slug": "merchant-shop",
    "displayCurrency": "USD",
    "checkoutMode": "hosted",
])

try await makepay.updateShopDomain("shop.merchant.example")
try await makepay.createShopCoupon([
    "code": "SPRING10",
    "discountType": "percent",
    "value": "10",
])

Bookkeeping

try await makepay.createBookkeepingInvoice([
    "title": "Invoice #1042",
    "currency": "USD",
    "issueDate": "2026-05-15",
    "dueDate": "2026-05-30",
    "lineItems": [
        [
            "description": "Implementation services",
            "quantity": "1",
            "unitAmount": "500",
        ],
    ],
])

try await makepay.createBookkeepingInvoicePaymentLink(
    invoiceID: "INVOICE_UID",
    options: ["sendPaymentRequestEmail": true]
)

try await makepay.createBookkeepingExpense([
    "title": "Hosting",
    "amount": "49",
    "currency": "USD",
    "incurredOn": "2026-05-15",
])

try await makepay.uploadBookkeepingDocument(
    MakePayBookkeepingDocumentUpload(
        file: MakePayMultipartFile(
            data: receiptData,
            fileName: "receipt.pdf",
            contentType: "application/pdf"
        ),
        documentType: "receipt",
        expenseID: "EXPENSE_UID"
    )
)

try await makepay.getBookkeepingSummary()

Branding And Operational APIs

try await makepay.updateBranding([
    "brandName": "Merchant",
    "supportEmail": "support@merchant.example",
    "paymentLinkDomain": "pay.merchant.example",
    "emailSendingDomain": "mail.merchant.example",
])

try await makepay.refreshBrandingDomains(kind: .all)
try await makepay.listDestinationAssets()
try await makepay.listWebhookRequests(query: ["limit": "25"])

Settings

try await makepay.getSettings()

try await makepay.updateSettings([
    "callbackUrl": "https://merchant.example/webhooks/makepay"
])

Webhook Verification

MakePay signs the exact raw request body. Read it before JSON decoding.

let event = try MakePayWebhook.parse(
    rawBody: rawBodyData,
    signatureHeader: request.headers["x-makepay-signature"],
    secret: ProcessInfo.processInfo.environment["MAKEPAY_WEBHOOK_SECRET"]!
)

if event["event"]?.objectValue?["type"] == "status_changed" {
    // Update the local order.
}

Use MakePayWebhook.verify when you only need a boolean result.

Error Handling

API errors throw MakePayError. It includes the HTTP status, decoded response, and a human-readable message when MakePay returns one.

do {
    try await makepay.getPaymentLink("PAYMENT_LINK_UID")
} catch let error as MakePayError {
    print(error.localizedDescription)
}

Source Layout

The canonical monorepo source lives in apps/plugins/swift-sdk. The public repository mirrors only the Swift package files so Swift Package Manager and Swift Package Index can resolve Package.swift from the repository root.

Release Notes

Swift releases are git tag based. Tag the public repository with semantic versions such as 0.3.0, then submit or refresh the package on Swift Package Index.

¿Necesitas ayuda con la configuración de partner?

Abre la vista de detalles del enlace de pago en MakeCrypto para copiar los snippets generados para un UID de pago real, o vuelve al portal para gestionar la configuración del merchant.

Abrir portal