Payment settlement on server

Now that we know that the payment is verified, we can either settles the payment by interacting with a blockchain directly, or by sending the Payment Payload and Payment Requirements to the /settle endpoint of a facilitator server.

This is what we have to send:

{
  "x402Version": 1,
  "paymentPayload": {
    "x402Version": 1,
    "scheme": "exact",
    "network": "base-sepolia",
    "payload": {
      "signature": "0xc2c261db2f352e47049c68a9f96be3a46f0dda5138ec04fc9a0462f0d32c531d31a31b26c1b7852978b9db3ccc5ea4839de25ca4c17fee47f7344d420128ceb11b",
      "authorization": {
        "from": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
        "to": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
        "value": "1000",
        "validAfter": "1747601321",
        "validBefore": "1747601441",
        "nonce": "0xa5f2264bcb079c96f07d9fe1378f5f846e3acd5ea29024d740cec881e2e85fe6"
      }
    }
  },
  "paymentRequirements": {
    "scheme": "exact",
    "network": "base-sepolia",
    "maxAmountRequired": "1000",
    "resource": "http://localhost:4021/weather",
    "description": "",
    "mimeType": "",
    "payTo": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
    "maxTimeoutSeconds": 60,
    "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "extra": {
      "name": "USDC",
      "version": "2"
    }
  }
}

And this is the kind of result we expect:

{
  "success": false,
  "network": "base-sepolia",
  "transaction": "",
  "errorReason": "invalid_scheme",
  "payer": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73"
}

Be careful, a X-PAYMENT-RESPONSE header containing the Settlement Response as Base64 encoded JSON is added if the payment was executed successfully

You can test it with curl:

curl -X POST https://www.x402.org/facilitator/settle \
  -H "Accept: application/json, text/plain, */*" \
  -H "Content-Type: application/json" \
  -H "User-Agent: axios/1.8.4" \
  -H "Accept-Encoding: identity" \
  -d '{
  "x402Version": 1,
  "paymentPayload": {
    "x402Version": 1,
    "scheme": "exact",
    "network": "base-sepolia",
    "payload": {
      "signature": "0xc2c261db2f352e47049c68a9f96be3a46f0dda5138ec04fc9a0462f0d32c531d31a31b26c1b7852978b9db3ccc5ea4839de25ca4c17fee47f7344d420128ceb11b",
      "authorization": {
        "from": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
        "to": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
        "value": "1000",
        "validAfter": "1747601321",
        "validBefore": "1747601441",
        "nonce": "0xa5f2264bcb079c96f07d9fe1378f5f846e3acd5ea29024d740cec881e2e85fe6"
      }
    }
  },
  "paymentRequirements": {
    "scheme": "exact",
    "network": "base-sepolia",
    "maxAmountRequired": "1000",
    "resource": "http://localhost:4021/weather",
    "description": "",
    "mimeType": "",
    "payTo": "0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73",
    "maxTimeoutSeconds": 60,
    "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "extra": {
      "name": "USDC",
      "version": "2"
    }
  }
}'

Last updated