diff --git a/uc_stripe.module b/uc_stripe.module index ba489e0..de0f247 100644 --- a/uc_stripe.module +++ b/uc_stripe.module @@ -323,6 +323,20 @@ function uc_stripe_settings_form() { '#default_value' => variable_get('uc_stripe_poweredby', FALSE), ); + $form['uc_stripe_settings']['uc_stripe_metadata_titles'] = array( + '#type' => 'checkbox', + '#title' => t('Metadata: Title'), + '#description' => t('Include order item title(s) in Stripe metadata.'), + '#default_value' => variable_get('uc_stripe_metadata_titles', FALSE), + ); + + $form['uc_stripe_settings']['uc_stripe_metadata_models'] = array( + '#type' => 'checkbox', + '#title' => t('Metadata: Model'), + '#description' => t('Include item model(s) (SKU(s)) in Stripe metadata.'), + '#default_value' => variable_get('uc_stripe_metadata_models', FALSE), + ); + return $form; } @@ -539,7 +553,6 @@ function uc_stripe_charge($order_id, $amount, $data) { return $result; } - // Charge the customer try { @@ -548,11 +561,24 @@ function uc_stripe_charge($order_id, $amount, $data) { throw new Exception('No customer ID found'); } + foreach($order->products as $item){ + $titles[] = $item->title; + $models[] = $item->model; + } + $metadata = array(); + + if (!empty($models)) { + $metadata['models'] = implode(";", $models); + } + if (!empty($titles)) { + $metadata['titles'] = implode(";", $titles); + } $params = array( "amount" => $amount, "currency" => strtolower($order->currency), "customer" => $stripe_customer_id, "description" => t("Order #@order_id", array("@order_id" => $order_id)), + "metadata" => $metadata, ); if (!empty($shipping_info)) { $params['shipping'] = $shipping_info;