Commit 09eba9f7 authored by Birin Sanchez's avatar Birin Sanchez

* Return None subscriptions for users without WC account

* Save error message in ExternalCredit.error_message
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 8cd1e17a
Pipeline #10162 passed with stage
in 40 seconds
......@@ -76,6 +76,9 @@ def parse_subscription(json_entry):
def get_user_subscriptions(user):
user_wc_id = user.get_woocommerce_id()
if user_wc_id is None:
# The user does not have WC account
return None
woo = get_woo_connection()
subscriptions = woo.get(
'subscriptions?customer={}'.format(user_wc_id)).json()
......@@ -160,11 +163,12 @@ def process_pending_registrations_user(user):
if hasattr(user, 'chosenreward'):
user.chosenreward.is_pending = is_pending
user.chosenreward.save()
ext_cred.error_message = error
ext_cred.save()
if is_pending:
logger.info('Subscription {} for user {} found error: '
'{}'.format(parsed_sub['label'], user.username,
error))
error))
else:
logger.info('Subscription {} for user {} was processed '
'successfully'.format(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment