22
22
BaseClientSidePaymentProcessor ,
23
23
HandledProcessorResponse
24
24
)
25
+ from ecommerce .extensions .payment .utils import (
26
+ get_basket_program_uuid ,
27
+ )
28
+ from ecommerce .programs .utils import get_program
25
29
26
30
logger = logging .getLogger (__name__ )
27
31
@@ -149,15 +153,26 @@ def get_transaction_parameters(self, basket, request=None, use_client_side_check
149
153
if product .course :
150
154
regex = '\\ :(.*?)\\ +'
151
155
course_org = re .findall (regex , product .course .id )[0 ]
156
+
157
+ program_uuid = get_basket_program_uuid (basket )
158
+ program = None
159
+
160
+ if program_uuid :
161
+ program = get_program (program_uuid , basket .site .siteconfiguration )
152
162
153
- description = '{order_number} - {organization} : {title }' .format (
163
+ description_prefix = 'Order#: {order_number}, Instance : {organization }' .format (
154
164
order_number = order_number ,
155
- organization = course_org if course_org else basket .site .partner .name ,
156
- title = product .title
165
+ organization = course_org if course_org else basket .site .partner .name
157
166
)
158
167
159
168
line_items = []
169
+ product_titles = []
160
170
for line in basket .all_lines ():
171
+ description = '{prefix}: {title}' .format (
172
+ prefix = description_prefix ,
173
+ title = line .product .title
174
+ )
175
+ product_titles .append (line .product .title )
161
176
line_items .append ({
162
177
'price_data' : {
163
178
'currency' : basket .currency .lower (),
@@ -169,6 +184,16 @@ def get_transaction_parameters(self, basket, request=None, use_client_side_check
169
184
},
170
185
'quantity' : line .quantity ,
171
186
})
187
+
188
+ payment_intent_description = '{prefix}{program}, Course: {titles}' .format (
189
+ prefix = description_prefix ,
190
+ program = ', Program: ' + program .get ('title' ) if program else '' ,
191
+ titles = ', Course: ' .join (product_titles )
192
+ )
193
+
194
+ MAX_DESCRIPTION_LENGTH = 997
195
+ if len (payment_intent_description ) > MAX_DESCRIPTION_LENGTH :
196
+ payment_intent_description = payment_intent_description [:MAX_DESCRIPTION_LENGTH ] + '...'
172
197
173
198
try :
174
199
session = stripe .checkout .Session .create (
@@ -181,6 +206,9 @@ def get_transaction_parameters(self, basket, request=None, use_client_side_check
181
206
),
182
207
billing_address_collection = "required" ,
183
208
cancel_url = self .cancel_url ,
209
+ payment_intent_data = {
210
+ 'description' : payment_intent_description
211
+ },
184
212
metadata = {
185
213
'basket_id' : basket .id ,
186
214
'order_number' : order_number
0 commit comments