# Metadata not passing through

**URL:** https://community.rapyd.net/t/metadata-not-passing-through/59045
**Category:** 🙋🏽‍♀️🙋🏽‍♂️ Ask Questions
**Created:** [November 21, 2023, 12:40pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045 "2023-11-21T12:40:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![whitelotus](https://avatars.discourse-cdn.com/v4/letter/w/94ad74/32.png) [@whitelotus](https://community.rapyd.net/u/whitelotus)
#### Post date: [November 21, 2023, 12:40pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/1 "2023-11-21T12:40:24Z")

</div>

I have a flutter app in the making and i have succesfully made the payment work using InAppWebView where user can pay… But i try to pass a metadata for the info that i need about the user and product, but it doesnt seem to be coming into the webhook.

i recieve the webhook with firebase functions, and when i log the response the metadata list is empty.

what am i missing?

i will share the code im using here

---------------------this is my rapyd.dart

```auto
Map<String, dynamic> _getBody(String type, String eventId, String userId) {
    return {
      "amount": amount.toString(),
      "currency": "ISK",
      "country": "IS",
      "complete_checkout_url": "https://www.thewhitelotus.is/",
      "cancel_checkout_url": "https://www.mamareykjavik.is/",
      "metadata": {
        "purchase_type": type,
        "event_id": eventId,
        "user_id": userId,
      }
    };
  }

```

```auto
Future<http.Response> createCheckoutPage(String type, String eventId, String userId) async {
    final responseURL = Uri.parse("$baseUrl/v1/checkout");
    final String body = jsonEncode(_getBody(type, eventId, userId));
    print(body); // This will show you the exact structure being sent

    var response = await http.post(
      responseURL,
      headers: _getHeaders("/v1/checkout", body: body),
      body: body,
    );
    return response;  
}

```

---------------------Here is the Index.js

```auto
const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();

exports.rapydWebhook = functions.region('europe-west1').https.onRequest(async (request, response) => {
        console.log("Full webhook payload:", JSON.stringify(request.body));

    if (request.method === "POST") {
        console.log("Webhook event received:", request.body);

        // Extract payment status and metadata
        const paymentStatus = request.body.data.status;
        let metadata = request.body.data.metadata;

        if (typeof metadata === 'string') {
            metadata = JSON.parse(metadata);
        }

        const purchaseType = metadata.purchase_type;
        const eventId = metadata.event_id;
        const userId = metadata.user_id;

        // Check if the payment was successful
        const isSuccess = paymentStatus === 'CLO';

        if (isSuccess) {
            if (purchaseType === 'event') {
                // Logic for handling event ticket purchase
            } else if (purchaseType === 'store') {
                // Logic for handling store purchase
            }

            response.status(200).send("Received");
        } else {
            // Handle failed payment
            response.status(200).send("Payment failed");
        }
    } else {
        response.status(405).send("Only POST requests are accepted");
    }
});

```

---

<div class="post-metadata">

### Author: ![drew.harris](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/drew.harris/32/1259_2.png) [@drew.harris](https://community.rapyd.net/u/drew.harris)
#### Post date: [November 21, 2023, 5:23pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/2 "2023-11-21T17:23:15Z")

</div>

Welcome to the developer community @whitelotus - happy to have you here. Are you still getting the error? Are you in the production or sandbox environment?

---

<div class="post-metadata">

### Author: ![whitelotus](https://avatars.discourse-cdn.com/v4/letter/w/94ad74/32.png) [@whitelotus](https://community.rapyd.net/u/whitelotus)
#### Post date: [November 21, 2023, 5:46pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/3 "2023-11-21T17:46:52Z")

</div>

Thank you

yes im still getting this error, i am currently in sandbox

---

<div class="post-metadata">

### Author: ![whitelotus](https://avatars.discourse-cdn.com/v4/letter/w/94ad74/32.png) [@whitelotus](https://community.rapyd.net/u/whitelotus)
#### Post date: [November 23, 2023, 11:02pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/4 "2023-11-23T23:02:20Z")

</div>

Now this is not a problem anymore, by some sudden miracle this is fixed. if you did something i deeply thank you, if note im suprisingly happy that its working.

---

<div class="post-metadata">

### Author: ![drew.harris](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/drew.harris/32/1259_2.png) [@drew.harris](https://community.rapyd.net/u/drew.harris)
#### Post date: [November 27, 2023, 3:01pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/5 "2023-11-27T15:01:15Z")

</div>

Thanks @whitelotus for letting us know it is now working for you.

---

<div class="post-metadata">

### Author: ![drew.harris](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/drew.harris/32/1259_2.png) [@drew.harris](https://community.rapyd.net/u/drew.harris)
#### Post date: [November 27, 2023, 3:01pm UTC](https://community.rapyd.net/t/metadata-not-passing-through/59045/6 "2023-11-27T15:01:20Z")

</div>


