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)

1 Answer 1


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:

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->getBasePath());
        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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.