<p>This is the part of the docs you need: <a href="https://github.com/craftcms/commerce-stripe#buildgatewayrequest" rel="nofollow noreferrer">https://github.com/craftcms/commerce-stripe#buildgatewayrequest</a></p>
<p>As per that example, you'll need a custom module hooking into the <code>EVENT_BUILD_GATEWAY_REQUEST</code> event, which then allows you to send any key-value pairs to Stripe like this:</p>
<p><code>$e-&gt;request['metadata']['whateverYouLike'] = 'some value'</code>.</p>
<p>I'm using this technique to send the shipping address data into Stripe, for example:</p>
<pre class="lang-php prettyprint-override"><code>&lt;?php
namespace modules\site;;

use Craft;
use craft\commerce\stripe\events\BuildGatewayRequestEvent;
use craft\commerce\stripe\base\Gateway as StripeGateway;
use yii\base\Event;

class Site extends \yii\base\Module
{
    public static $instance;

    public function __construct($id, $parent = null, array $config = [])
    {
        Craft::setAlias('@modules/site', $this-&gt;getBasePath());
        static::setInstance($this);
        parent::__construct($id, $parent, $config);
    }

    public function init()
    {
        // --------------------------------------------
        // SEND SOME METADATA into STRIPE, specifically, shipping address
        // --------------------------------------------

        Event::on(StripeGateway::class,StripeGateway::EVENT_BUILD_GATEWAY_REQUEST, function(BuildGatewayRequestEvent $e) {
            $e-&gt;request['metadata']['shippingAddressFirstName'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['firstName'] ?? null;
            $e-&gt;request['metadata']['shippingAddressLastName'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['lastName'] ?? null;
            $e-&gt;request['metadata']['shippingAddressLine1'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['address1'] ?? null;
            $e-&gt;request['metadata']['shippingAddressLine2'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['address2'] ?? null;
            $e-&gt;request['metadata']['shippingAddressLine3'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['address3'] ?? null;
            $e-&gt;request['metadata']['shippingAddressCity'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['city'] ?? null;
            $e-&gt;request['metadata']['shippingAddressPostcode'] = $e-&gt;transaction-&gt;order-&gt;shippingAddress['zipCode'] ?? null;
        });
    }
}

</code></pre>

CC BY-SA 4.0
2023-03-08T17:42:09.370Z
2023-03-08T17:47:45.517Z
2023-03-08T17:47:45.517Z
James Smith
<p>I have Craft Commerce and the Stripe Payment gateway setup and working fine. The info that comes through to Stripe is a little generic and customer would like some info about the products sent through. From what i can see the Meta Data section or the Description field in Stripe might be the place to put some info. Is this possible to do ? (without a complicated plugin etc also)</p>

<ecommerce><plugin-commerce-stripe>
Craft Commerce Stripe Payment Plugin - send custom description or meta data?
# Craft Commerce Stripe Payment Plugin - send custom description or meta data?

(Asked by: username_0 on 2023-03-08)

I have Craft Commerce and the Stripe Payment gateway setup and working fine. The info that comes through to Stripe is a little generic and customer would like some info about the products sent through. From what i can see the Meta Data section or the Description field in Stripe might be the place to put some info. Is this possible to do ? (without a complicated plugin etc also)

**Tags:** ecommerce, plugin-commerce-stripe


---

## 1 answers

### Answer by username_1 on 2023-03-08. Score: 2

This is the part of the docs you need: https://github.com/craftcms/commerce-stripe#buildgatewayrequest
As per that example, you'll need a custom module hooking into the EVENT_BUILD_GATEWAY_REQUEST event, which then allows you to send any key-value pairs to Stripe like this:
$e->request['metadata']['whateverYouLike'] = 'some value'.
I'm using this technique to send the shipping address data into Stripe, for example:
getBasePath());
        static::setInstance($this);
        parent::__construct($id, $parent, $config);
    }

    public function init()
    {
        // --------------------------------------------
        // SEND SOME METADATA into STRIPE, specifically, shipping address
        // --------------------------------------------

        Event::on(StripeGateway::class,StripeGateway::EVENT_BUILD_GATEWAY_REQUEST, function(BuildGatewayRequestEvent $e) {
            $e->request['metadata']['shippingAddressFirstName'] = $e->transaction->order->shippingAddress['firstName'] ?? null;
            $e->request['metadata']['shippingAddressLastName'] = $e->transaction->order->shippingAddress['lastName'] ?? null;
            $e->request['metadata']['shippingAddressLine1'] = $e->transaction->order->shippingAddress['address1'] ?? null;
            $e->request['metadata']['shippingAddressLine2'] = $e->transaction->order->shippingAddress['address2'] ?? null;
            $e->request['metadata']['shippingAddressLine3'] = $e->transaction->order->shippingAddress['address3'] ?? null;
            $e->request['metadata']['shippingAddressCity'] = $e->transaction->order->shippingAddress['city'] ?? null;
            $e->request['metadata']['shippingAddressPostcode'] = $e->transaction->order->shippingAddress['zipCode'] ?? null;
        });
    }
}


---

