You are here

function hook_commerce_stripe_order_charge_alter in Commerce Stripe 7

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

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

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 20
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,
    ));
  }

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