Skip to content

Commit 58a4093

Browse files
RamiroAlvarorenzon
authored andcommitted
bug fixed - User's phone number is not been collect
close #3089
1 parent e090a26 commit 58a4093

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

pythonpro/domain/checkout_domain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def user_factory(pagarme_transaction):
3939
customer = pagarme_transaction['customer']
4040
customer_email = customer['email'].lower()
4141
customer_first_name = customer['name'].split()[0]
42-
return user_domain.force_register_lead(customer_first_name, customer_email)
42+
customer_phone = customer['phone_numbers'][0]
43+
return user_domain.force_register_lead(customer_first_name, customer_email, customer_phone)
4344

4445

4546
django_pagarme_facade.set_user_factory(user_factory)

pythonpro/domain/tests/test_checkout/test_boleto_generation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest import mock
2+
13
import pytest
24
import responses
35
from django.urls import reverse
@@ -101,6 +103,15 @@ def test_created_user_tagged_with_boleto(resp, django_user_model, tag_as_mock, a
101103
tag_as_mock.assert_called_once_with(user.email, user.id, f'{active_product_item.slug}-boleto')
102104

103105

106+
def test_phone_in_the_parameters(resp, create_or_update_lead_mock):
107+
create_or_update_lead_mock.assert_called_once_with(
108+
'Foo',
109+
'foo@email.com',
110+
id=mock.ANY,
111+
phone='+5512999999999'
112+
)
113+
114+
104115
# Tests user logged
105116

106117
@pytest.fixture

pythonpro/domain/tests/test_checkout/test_credit_card_payment.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest import mock
2+
13
import pytest
24
import responses
35
from django.urls import reverse
@@ -174,6 +176,15 @@ def test_payment_linked_with_created_user(resp, django_user_model):
174176
assert user == payment.user
175177

176178

179+
def test_phone_in_the_parameters(resp, create_or_update_lead_mock):
180+
create_or_update_lead_mock.assert_called_once_with(
181+
'Agora',
182+
'captura@gmail.com',
183+
id=mock.ANY,
184+
phone='+5512997411854'
185+
)
186+
187+
177188
# Tests user logged
178189

179190
@pytest.fixture

pythonpro/domain/user_domain.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ def register_lead(first_name: str, email: str, source: str = 'unknown', tags: li
4848
return lead
4949

5050

51-
def force_register_lead(first_name: str, email: str, source: str = 'unknown') -> _User:
51+
def force_register_lead(first_name: str, email: str, phone: str, source: str = 'unknown') -> _User:
5252
"""
5353
Create a new user on the system generation a random password.
5454
An Welcome email is sent to the user informing his password with the link to change it.
5555
User is also registered on Email Marketing. But she will be registered even if api call fails
5656
:param first_name: User's first name
5757
:param email: User's email
58+
:param phone: User's phone
5859
:param source: source of User traffic
5960
:return: User
6061
"""
6162
user = _core_facade.register_lead(first_name, email, source)
62-
_email_marketing_facade.create_or_update_lead.delay(first_name, email, id=user.id)
63+
_email_marketing_facade.create_or_update_lead.delay(first_name, email, id=user.id, phone=phone)
6364
return user
6465

6566

0 commit comments

Comments
 (0)