> For the complete documentation index, see [llms.txt](https://mogami.gitbook.io/mogami/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mogami.gitbook.io/mogami/learning/protocol-explanation-v1/get-weather-with-x-payment.md).

# Get /weather with X-PAYMENT

The user can directly call the `/weather` with a `X-PAYMENT` header containing the Payment Payload encoded with base 64 (definition here: <https://github.com/coinbase/x402?tab=readme-ov-file#type-specifications>).

To do this, the client will have to generate this kind of JSON:

```json
{
  "x402Version": 1,
  "scheme": "exact",
  "network": "base-sepolia",
  "payload": {
    "signature": "0x2d6a7588d6acca505cbf0d9a4a227e0c52c6c34008c8e8986a1283259764173608a2ce6496642e377d6da8dbbf5836e9bd15092f9ecab05ded3d6293af148b571c",
    "authorization": {
      "from": "0x857b06519E91e3A54538791bDbb0E22373e36b66",
      "to": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
      "value": "10000",
      "validAfter": "1740672089",
      "validBefore": "1740672154",
      "nonce": "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f13480"
      }
  }
}
```

In this JSON, there are two things : \
\- Payment Payload (included as the X-PAYMENT header in base64 encoded JSON).\
\- Inside this Payment payload, there is the payload field. This field is specific and depends on the scheme you set. For example, you can find read the exact payload specification here : <https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_evm.md#x-payment-header-payload>.

Once you have build this JSON, use the code below to encode it and then, add it to the `X-PAYMENT` header of your query.

```java
String encodedPaymentHeader = Base64
.getEncoder()
.withoutPadding()
.encodeToString(paymentHeader.getBytes(UTF_8));
```

If the payment is accepted and all the verification succeed, the query result will be displayed (in our case, it will be the weather).
