Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commerce_stripe-2433257
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
commerce_stripe-2433257
Commits
96c840bb
Commit
96c840bb
authored
9 years ago
by
Erik Peterson
Committed by
aviindub
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2545400
by Artusamak, torgosPizza: Let modules alter the charge data
parent
4e8f7511
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commerce_stripe.api.php
+4
-2
4 additions, 2 deletions
commerce_stripe.api.php
commerce_stripe.module
+11
-2
11 additions, 2 deletions
commerce_stripe.module
with
15 additions
and
4 deletions
commerce_stripe.api.php
+
4
−
2
View file @
96c840bb
...
...
@@ -17,10 +17,12 @@ function hook_commerce_stripe_metadata($order) {
/**
* Alter the description of the order sent to Stripe in the payment details.
*/
function
hook_commerce_stripe_order_
description_alter
(
&
$description
,
$order
)
{
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
);
$description
=
t
(
'Token card id: %token_card_id'
,
array
(
'%token_card_id'
=>
$card_id
));
$
charge
[
'
description
'
]
=
t
(
'Token card id: %token_card_id'
,
array
(
'%token_card_id'
=>
$card_id
));
}
// Add application fees.
$charge
[
'application_fee'
]
=
rand
(
1
,
1000
);
}
This diff is collapsed.
Click to expand it.
commerce_stripe.module
+
11
−
2
View file @
96c840bb
...
...
@@ -488,7 +488,6 @@ function commerce_stripe_submit_form_submit($payment_method, $pane_form, $pane_v
// Build a default description and offer modules the possibility to alter it.
$description
=
t
(
'Order Number: @order_number'
,
array
(
'@order_number'
=>
$order
->
order_number
));
drupal_alter
(
'commerce_stripe_order_description'
,
$description
,
$order
);
$currency_code
=
$payment_method
[
'settings'
][
'stripe_currency'
];
if
(
isset
(
$charge
[
'currency_code'
])){
...
...
@@ -500,7 +499,14 @@ function commerce_stripe_submit_form_submit($payment_method, $pane_form, $pane_v
'card'
=>
$pane_values
[
'stripe_token'
],
'description'
=>
$description
,
);
// The metadata could be added via the alter below but for compatibility
// reasons it may stay.
commerce_stripe_add_metadata
(
$c
,
$order
);
// Let modules alter the charge object to add attributes.
drupal_alter
(
'commerce_stripe_order_charge'
,
$c
,
$order
);
// To later store the card with all required fields, carry out necessary steps before making the charge request.
if
(
module_exists
(
'commerce_cardonfile'
)
&&
!
empty
(
$payment_method
[
'settings'
][
'cardonfile'
])
&&
!
empty
(
$pane_values
[
'credit_card'
][
'cardonfile_store'
])
&&
$pane_values
[
'credit_card'
][
'cardonfile_store'
])
{
...
...
@@ -744,7 +750,6 @@ function commerce_stripe_cardonfile_charge($payment_method, $card_data, $order,
// Build a default description and offer modules the possibility to alter it.
$description
=
t
(
'Order Number: @order_number'
,
array
(
'@order_number'
=>
$order
->
order_number
));
drupal_alter
(
'commerce_stripe_order_description'
,
$description
,
$order
);
$c
=
array
(
'amount'
=>
$charge
[
'amount'
],
...
...
@@ -753,8 +758,12 @@ function commerce_stripe_cardonfile_charge($payment_method, $card_data, $order,
'card'
=>
$card_id
,
'description'
=>
$description
,
);
commerce_stripe_add_metadata
(
$c
,
$order
);
// Let modules alter the charge object to add attributes.
drupal_alter
(
'commerce_stripe_order_charge'
,
$c
,
$order
);
$transaction
=
commerce_payment_transaction_new
(
'commerce_stripe'
,
$order
->
order_id
);
$transaction
->
instance_id
=
$payment_method
[
'instance_id'
];
$transaction
->
amount
=
$charge
[
'amount'
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment