def checkout_with_ecommerce_service(user, course_key, course_mode, processor):
 course_id = unicode(course_key)
 try:
  api = ecommerce_api_client(user)
  result = api.baskets.post({'products': [{'sku': course_mode.sku}], 'checkout': True, 'payment_processor_name': processor})
  return result.get('payment_data')
 except SlumberBaseException:
  params = {'username': user.username, 'mode': course_mode.slug, 'course_id': course_id}
  log.exception('Failed to create order for %(username)s %(mode)s mode of %(course_id)s', params)
  raise
 finally:
  audit_log('checkout_requested', course_id=course_id, mode=course_mode.slug, processor_name=processor, user_id=user.id)

def checkout_with_ecommerce_service ( user , course_key , course_mode , processor ) : course_id = unicode ( course_key ) try : api = ecommerce_api_client ( user ) result = api . baskets . post ( { 'products' : [ { 'sku' : course_mode . sku } ] , 'checkout' : True , 'payment_processor_name' : processor } ) return result . get ( 'payment_data' ) except SlumberBaseException : params = { 'username' : user . username , 'mode' : course_mode . slug , 'course_id' : course_id } log . exception ( 'Failed to create order for %(username)s %(mode)s mode of %(course_id)s' , params ) raise finally : audit_log ( 'checkout_requested' , course_id = course_id , mode = course_mode . slug , processor_name = processor , user_id = user . id )
create a new basket and trigger immediate checkout .