You are here

function hook_commerce_stripe_order_charge_alter in Commerce Stripe 7.3

Same name and namespace in other branches
  1. 7 commerce_stripe.api.php \hook_commerce_stripe_order_charge_alter()

Alter the description of the order sent to Stripe in the payment details.

The settings array for the payment method instance used to process charges for the order may be accessed via a temporary property added to the order object for this hook: $order->payment_method_settings

1 function implements hook_commerce_stripe_order_charge_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

commerce_stripe_connect_commerce_stripe_order_charge_alter in modules/commerce_stripe_connect/commerce_stripe_connect.module
Implements hook_commerce_stripe_order_charge_alter().
2 invocations of hook_commerce_stripe_order_charge_alter()
commerce_stripe_cardonfile_charge in ./commerce_stripe.module
Card on file callback: background charge payment TODO: implement proper return codes per commerce payment
commerce_stripe_submit_form_submit in ./commerce_stripe.module
Payment method callback: checkout form submission.

File

./commerce_stripe.api.php, line 27
This code is never called, it's just information about to use the hooks.

Code

function hook_commerce_stripe_order_charge_alter(&$charge, $order) {

  // Example of alteration of the description.
  if ($order->data['item_purchased'] == 'token_card') {
    $card_id = rand(1, 10000);
    $charge['description'] = t('Token card id: %token_card_id', array(
      '%token_card_id' => $card_id,
    ));
  }

  // Check to see if the site-wide Stripe Connect account is being used.
  if (!empty($order->payment_method_settings['use_connected_account']) && $order->payment_method_settings['use_connected_account'] == 'site account') {

    // Then add application fees.
    $charge['application_fee'] = rand(1, 1000);
  }
}