Integration in practice

Detailed digital delivery platform integration: from product setup to payment callbacks and automatic delivery acceptance

You have products, a domain and a digital delivery application. How do you make sure customers reliably receive their license codes after payment? This article follows a complete integration through preparation, development, testing and launch. Examples concern digital products you own or are authorized to sell. Field names and pseudocode illustrate mapping concepts and are not the actual 稳付pay API documentation.

Preparing to integrate 稳付pay: see the collection developer documentation and use the actual fields for MD5 signing, order creation, queries and callbacks. Technical staff provide merchant gateways and keys separately; payout APIs are not currently available.
Contents

Step 1: define product, payment and fulfillment responsibilities

Start with three boundaries: the digital delivery platform manages products, orders and fulfillment; the payment service identifies transactions and sends notifications; the settlement process delivers the amount payable to the merchant as agreed. Payment success, product delivery and settlement receipt are three distinct facts and must not share one completed switch.

  1. Prepare productsDefine SKUs, inventory and after-sales rules
  2. Create paymentFix the order amount and payment attempt on the backend
  3. Verify paymentCombine trusted callbacks with server-side queries
  4. Deliver automaticallyAllocate transactionally and retry durable tasks
Fulfillment depends on a trusted payment result; record and reconcile merchant settlement progress separately.

For example, an order for a software activation code you developed may be paid and awaiting delivery before it enters the current settlement batch. If a paying customer cannot receive the product because the settlement queue has not completed, the system has usually coupled these separate workflows incorrectly.

Step 2: prepare products, inventory and the runtime environment

Give each product variant a stable ID and define the license duration, supported versions, purchase quantity limits, delivery method and after-sales contact. Displayed prices and backend order prices should use the same trusted data source; never let the browser decide the payable amount.

Distinguish sellable, reserved, allocated and delivered inventory. Reservations need expiration times and atomic release conditions, coordinated with the payment waiting period. An expiry job must not change a confirmed paid order back to unpaid and release its stock unconditionally.

At minimum, prepare valid HTTPS, independent test configuration, a reliable database, durable workers and a backup and recovery method. Show codes only to users authorized for the associated order. Access logs and error stacks must not contain full codes, private keys or payment keys.

Step 3: confirm integration capabilities before mapping fields

Confirm each part of the actual protocol: authentication, signature coverage, raw body requirements, query capability, payment states, notification acknowledgements, retry behavior, time zones and amount precision. If an existing plugin does not match, change the adapter; editing a page template does not replace payment integration.

Local business informationConfirm during integrationWhy it is stored
Merchant order numberLength, allowed characters and uniqueness scopeConnect products, payment and fulfillment
Payment attempt numberHow retries for the same order are identifiedAvoid duplicate order creation after timeouts
Payable amount and currencyUnits, precision and allowed statesPrevent underpayment or currency mismatches
Channel transaction and event IDsAvailability, scope and lookup methodMatch payments and deduplicate notifications
Callback URL and return URLThe distinction between server notifications and browser redirectsSeparate business confirmation from progress display
Network, asset and receiving addressThe network and asset identifier for USDTPrevent cross-chain or same-name token confusion

The names in the table are business concepts only. Final fields and signing methods must follow the actual documentation agreed by both parties; do not copy this article as a request format.

Step 4: create orders on the backend and save every payment attempt

Once the customer selects a product, the backend reads the price again, checks stock and purchase restrictions, generates a merchant order number and saves an amount snapshot, currency and expiration time. Save the payment attempt before calling the payment service so that this specific request can still be located after a network failure.

A creation timeout means only that no definitive response was received, not that the payment service failed to create the order. First verify using the original merchant order number or agreed query criteria. Retry safely with identical business content and the agreed idempotency identifier only if the provider's protocol supports idempotent requests. See Stripe's idempotent request documentation to understand the mechanism; do not assume every channel supports the same request header.

When a customer chooses another payment method, retain the association of the previous attempt so that an old notification cannot be mapped to a new channel order. If two real payments occur, record each and handle the duplicate payment; do not hide the issue by delivering two products.

Step 5: display payment instructions and use the return page only for progress

Pass the payment link or required parameters obtained by the server to the frontend, and display the order number, payable amount, expiration time and support entry. For USDT, also display the exact network and receiving address instead of asking the customer to infer the network from the label USDT.

Returning to the site after payment, closing the page or switching devices must not alter backend verification. The return page only queries your own backend for order progress; it does not deliver based on a success parameter in the URL. Order details and code lookup must require authentication or a sufficiently strong order access credential.

OWASP's third-party payment integration guidance emphasizes server-side verification and amount matching. Distinguish submitted and confirming from paid in payment messages, so that an unconfirmed transfer is not mistakenly shown as successful.

Step 6: verify signatures, query orders and check business fields on the backend

Verify incoming notifications according to the actual protocol and check the merchant, order, amount, currency and successful state. If the protocol requires the raw body, preserve the original bytes before parsing or rewriting them. A valid signature does not replace business field checks.

Use authenticated server-side queries under the integration plan to verify payment status, particularly when callbacks are missing, order creation times out or states conflict. If queries are temporarily unavailable, keep the result awaiting confirmation and schedule retries; do not interpret a network error as failure or automatically deliver from a payment screenshot.

Stripe's Webhook documentation describes notification verification, duplicate delivery and out-of-order events. Acknowledgement must follow the protocol and occur only after the event and responsibility for subsequent processing are durably persisted. Acknowledging first while keeping the task only in memory can lose an order after a restart.

Step 7: record payment and inventory in a transaction, then fulfill asynchronously after commit

The payment fact, inventory allocation and fulfillment task must be saved together. Use a row lock or atomic state-conditional update for the same order, and apply appropriately scoped unique constraints to events, transactions and deliveries. Inventory allocation also needs unique ownership by order line and quantity. Repeated processing should return the original allocation, not take another code because the delivery task is unfinished. Checking for existence before inserting does not by itself prevent concurrency races.

# Protocol mapping example, not a runnable payment integration.
event = verify_using_confirmed_protocol(raw_request)
payment = query_and_match_payment(event)
with database_transaction():
    lock_order(payment.order_id)
    persist_verified_event_once(event)
    record_payment_once(payment)
    if not fulfillment_exists(payment.order_id):
        if allocate_or_reuse_stock_once(payment.order_id):
            create_outbox_job_once(payment.order_id, "deliver")
        else:
            mark_paid_awaiting_stock(payment.order_id)
            create_outbox_job_once(payment.order_id, "stock_review")
return acknowledgement_required_by_protocol()

PostgreSQL's transaction documentation explains committing related data together; its row locking mechanisms coordinate competing operations. Keep external queries and email sending outside short transactions. An Outbox is a task record persisted with business data and executed by a worker after commit. The illustration omits exception handling; production code still needs to handle duplicate keys, deadlocks and retries.

Step 8: handle stock shortages, late payments and refunds

If stock is unavailable after payment is confirmed, save a paid, awaiting handling state and notify the operator to restock, agree on delivery or refund. Do not revert it to unpaid. Likewise, record a valid late payment for an expired order before applying current stock and agreed handling rules; do not simply ignore it.

An email timeout does not mean the email was not sent. Keep a stable fulfillment task ID. Reuse the corresponding identifier with an idempotent external licensing service; otherwise query first or verify manually. Resending the original order's code differs from allocating a new code, and must not consume inventory again.

Refunds need separate requested, processing, successful and failed states linked to the original transaction. A displayed or redeemed license code must not simply become sellable again; verify revocation results for revocable licenses first. Record the operator, reason and associated reference for refunds or replacement delivery.

Step 9: prove exception handling with an acceptance matrix

Integration testing should include more than one normal payment. Retain the order number, payment attempt number, verification result, payment record, stock allocation and task state for every case so another maintainer can review them.

Test inputExpected order resultFulfillment acceptance
A real successful paymentPaid, with a verifiable transactionCorrect quantity, fulfilled only once
Invalid signature or amountDo not confirm success; record the reasonDo not allocate inventory
Identical notifications arrive concurrentlyRecognize the same payment only onceOnly one valid allocation
Order creation timeout and a temporarily missing callbackRecover a definite state through queriesNo duplicate payment or missed delivery
Concurrent purchases of the last stock itemPreserve each actual payment factNo overselling; out-of-stock paid orders remain actionable
Late payment after the page is closedPreserve the paid factDeliver or provide after-sales support under the rules
Process restart after commitDurable records remain intactTasks recover without extra deliveries
Refund and delivery happen concurrentlySeparate, traceable statesResolve conflicts under coordination rules

Use the provider's test environment when available. Otherwise, agree on small real payments, refunds and fee rules in advance. This workflow does not replace actual channel integration testing or prove that acceptance testing has already passed.

Step 10: launch to a limited audience and keep processing existing orders during rollback

Before release, retain recoverable backups, the previous adapter and configuration, and determine whether schema changes can be rolled back. Start with a limited audience and monitor pending confirmations, signature failures, paid but undelivered orders, task backlog and query errors.

If problems arise, pause new payment attempts while continuing to receive and reconcile notifications for existing orders. Retain compatibility with the old protocol and a key rotation plan. Deleting callback URLs or emptying queues is not a rollback and may leave old payments permanently unmatched.

稳付pay supports Alipay, WeChat and other channel integrations. USDT settlement after channel collection follows the parties' agreement; with monitoring of a merchant-owned USDT address, customers pay directly into the merchant's wallet. Monitoring currently supports Tron (TRC20) and Ethereum (ERC20), with business callbacks within seconds after the configured confirmation conditions are met. This does not mean block confirmations take only seconds. The merchant dashboard is still in development; first contact us to confirm the protocol, settlement conditions and integration testing scope, then implement the appropriate adapter.

References and technical documentation

Official references help verify general technical principles. Validate examples against the actual API documentation and runtime environment.

  1. OWASP: secure third-party payment integration
  2. Stripe: webhook verification, retries and duplicate events
  3. Stripe: idempotent requests
  4. PostgreSQL: transactions
  5. PostgreSQL: row locking and concurrency
  6. PostgreSQL: unique constraints

Confirm integration for your business scenario

Describe your products, order volume, payment methods and settlement needs to confirm the APIs, movement of funds and exception handling item by item.

Contact 稳付pay ↗