> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://mmg-sdk.wetechnologygroup.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mmg-sdk.wetechnologygroup.com/_mcp/server.

# Result Codes Reference

> A complete list of result codes returned by the MMG Hosted Checkout.

# Checkout Result Codes

When handling the webhook response from MMG, the decrypted payload will contain a `ResultCode` and a `ResultMessage`. You must evaluate the `ResultCode` to determine whether to fulfill the customer's order or mark it as failed.

> **Warning**
>
> Only fulfill orders when you receive a `ResultCode` of `"0"`. Any other code indicates that the transaction did not complete successfully.

## Status Codes Table

Use the following table to map the outcome of the checkout session:

| Result Code | Message                 | Description                                                         | Action to Take                                                 |
| :---------- | :---------------------- | :------------------------------------------------------------------ | :------------------------------------------------------------- |
| `0`         | Transaction Successful  | Payment was successful; Merchant can release product/service/goods. | **Fulfill Order.**                                             |
| `1`         | Agent Not Registered    | User is not registered with MMG.                                    | Mark as failed. Prompt user to register or use another method. |
| `2`         | Payment Failed          | Payment has failed.                                                 | Mark as failed. Prompt user to try again.                      |
| `3`         | Invalid Secret Key      | Secret Key is invalid (possible phishing or configuration issue).   | Check your environment variables and SDK configuration.        |
| `4`         | Merchant ID Mismatch    | Merchant ID did not match Merchant ID in the encrypted token.       | Verify the `merchantId` passed during token generation.        |
| `5`         | Token Decryption Failed | Incoming token is invalid or cannot be decrypted.                   | Check your PEM keys and ensure formatting is correct.          |
| `6`         | Transaction Cancelled   | User clicked Cancel during Checkout.                                | Mark order as cancelled. Return user to cart.                  |
| `7`         | Request Timed Out       | The request timed out.                                              | Mark order as abandoned/failed.                                |

## Handling Edge Cases

* **Missing Webhooks:** If a user closes their browser before MMG can send the webhook, or if your server experiences downtime, you may miss the callback. It is highly recommended to implement a cron job or scheduled task that uses the **Transaction Lookup API** to check the status of any pending orders after a certain time period (e.g., 15 minutes).
* **Duplicate Webhooks:** Ensure your webhook handler is idempotent. If MMG sends the same `transactionId` twice, your system should recognize that the order is already paid and gracefully ignore the duplicate request while still returning a `200 OK`.