Skip to content

Commit

Permalink
Merge pull request #72 from pagopa/IDP-2475-fix-for-validate-content
Browse files Browse the repository at this point in the history
fix: [IDP-2475] fix for validate content
  • Loading branch information
Benedetta-fabbri authored May 2, 2024
2 parents 4711734 + 31a28fb commit 018bc0e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
19 changes: 14 additions & 5 deletions api/idpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,14 @@ def post_merchant_create_transaction_acquirer(initiative_id,
response = requests.post(
f'{settings.base_path.IDPAY.internal}{settings.IDPAY.endpoints.payment.internal_path}{settings.IDPAY.endpoints.payment.path}/',
headers={
'Content-Type': 'application/json',
'x-merchant-id': merchant_id,
'x-acquirer-id': acquirer_id,
'x-apim-request-id': apim_request_id
},
json={
'amountCents': amount_cents,
'idTrxAcquirer': uuid.uuid4().int,
'amountCents': int(amount_cents),
'idTrxAcquirer': str(uuid.uuid4()),
'initiativeId': initiative_id,
'mcc': mcc
},
Expand Down Expand Up @@ -315,6 +316,7 @@ def post_initiative_info(selfcare_token: str,
url=f'{settings.base_path.IO}{settings.IDPAY.domain}/initiative/info',
headers={
'Authorization': f'Bearer {selfcare_token}',
'Content-Type': 'application/json'
},
json={
'serviceIO': True,
Expand All @@ -341,6 +343,7 @@ def put_initiative_general_info(selfcare_token: str,
url=f'{settings.base_path.IO}{settings.IDPAY.domain}/initiative/{initiative_id}/general',
headers={
'Authorization': f'Bearer {selfcare_token}',
'Content-Type': 'application/json'
},
json=general_payload,
timeout=settings.default_timeout
Expand All @@ -355,6 +358,7 @@ def put_initiative_beneficiary_info(selfcare_token: str,
url=f'{settings.base_path.IO}{settings.IDPAY.domain}/initiative/{initiative_id}/beneficiary',
headers={
'Authorization': f'Bearer {selfcare_token}',
'Content-Type': 'application/json'
},
json=beneficiary_payload,
timeout=settings.default_timeout
Expand All @@ -369,6 +373,7 @@ def put_initiative_reward_info(selfcare_token: str,
url=f'{settings.base_path.IO}{settings.IDPAY.domain}/initiative/{initiative_id}/reward',
headers={
'Authorization': f'Bearer {selfcare_token}',
'Content-Type': 'application/json'
},
json=reward_payload,
timeout=settings.default_timeout
Expand All @@ -383,6 +388,7 @@ def put_initiative_refund_info(selfcare_token: str,
url=f'{settings.base_path.IO}{settings.IDPAY.domain}/initiative/{initiative_id}/refund',
headers={
'Authorization': f'Bearer {selfcare_token}',
'Content-Type': 'application/json'
},
json=refund_payload,
timeout=settings.default_timeout
Expand Down Expand Up @@ -568,14 +574,16 @@ def put_publish_ranking(selfcare_token: str, initiative_id: str):
return res


def post_idpay_code_generate(token: str, body: dict = None):
def post_idpay_code_generate(token: str, initiative_id: str = ''):
return requests.post(
f'{settings.base_path.IO}{settings.IDPAY.domain}{settings.IDPAY.endpoints.wallet.path}{settings.IDPAY.endpoints.wallet.code_generate}',
headers={
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json',
},
json=body,
json={
'initiativeId': initiative_id
},
timeout=settings.default_timeout)


Expand Down Expand Up @@ -635,12 +643,13 @@ def put_authorize_bar_code_merchant(merchant_id: str,
return requests.put(
f'{settings.base_path.IDPAY.internal}{settings.IDPAY.endpoints.payment.internal_path}{settings.IDPAY.endpoints.payment.path}{settings.IDPAY.endpoints.payment.bar_code.path}/{trx_code}/authorize',
headers={
'Content-Type': 'application/json',
'x-merchant-id': merchant_id,
'x-acquirer-id': acquirer_id
},
json={
'amountCents': amount_cents,
'idTrxAcquirer': uuid.uuid4().int
'idTrxAcquirer': str(uuid.uuid4())
}
)

Expand Down
3 changes: 2 additions & 1 deletion api/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def enroll(initiative_id, tax_code, body):
headers={
settings.API_KEY_HEADER: secrets.api_key.IDPAY_APP_ISSUER_PRODUCT,
'Accept-Language': 'it_IT',
'Fiscal-Code': tax_code
'Fiscal-Code': tax_code,
'Content-Type': 'application/json'
},
json=body,
timeout=settings.default_timeout
Expand Down
7 changes: 4 additions & 3 deletions api/mil.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ def post_merchant_create_transaction_mil(initiative_id,
headers={
settings.API_KEY_HEADER: secrets.api_key.IDPAY_MIL_PRODUCT,
'x-merchant-fiscalcode': merchant_fiscal_code,
'x-acquirer-id': acquirer_id
'x-acquirer-id': acquirer_id,
'Content-Type': 'application/json'
},
json={
'initiativeId': initiative_id,
'idTrxAcquirer': uuid.uuid4().int,
'amountCents': amount_cents,
'idTrxAcquirer': str(uuid.uuid4()),
'amountCents': int(amount_cents),
'mcc': mcc
}
)
Expand Down
2 changes: 1 addition & 1 deletion api/onboarding_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def check_prerequisites(token, initiative_id):
)


def pdnd_autocertification(token, initiative_id, pdnd_accept='true', self_declaration_accepted='true'):
def pdnd_autocertification(token, initiative_id, pdnd_accept=True, self_declaration_accepted=True):
"""API to put autocertification
:param token: token IO
:param initiative_id: initiative on which onboard the user
Expand Down
4 changes: 2 additions & 2 deletions bdd/steps/idpay_code_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def step_check_idpay_code_status(context, status, citizen_name):
def step_citizen_enroll_idpay_code(context, citizen_name):
token_io = get_io_token(context.citizens_fc[citizen_name])
res = post_idpay_code_generate(token=token_io,
body={'initiativeId': context.initiative_id})
initiative_id=context.initiative_id)

assert res.status_code == 200
context.idpay_code[citizen_name] = res.json()['idpayCode']
Expand Down Expand Up @@ -139,7 +139,7 @@ def step_check_latest_idpay_code_enabling_failed(context, cause_ko):
@when('the citizen {citizen_name} tries to enroll a new IDPay Code on the initiative')
def step_citizen_try_enroll_idpay_code(context, citizen_name):
token_io = get_io_token(context.citizens_fc[citizen_name])
res = post_idpay_code_generate(token=token_io, body={'initiativeId': context.initiative_id})
res = post_idpay_code_generate(token=token_io, initiative_id=context.initiative_id)

context.latest_idpay_code_enroll_response = res

Expand Down
8 changes: 4 additions & 4 deletions bdd/steps/onboarding_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def step_save_pdnd_consent_not_correctly(context, citizen_name):
token_io = get_io_token(context.citizens_fc[citizen_name])
context.pdnd_autocertification_response = pdnd_autocertification(token=token_io,
initiative_id=context.initiative_id,
pdnd_accept='false')
pdnd_accept=False)
step_check_saving_consent(context=context, reason_ko='THE CONSENT WAS DENIED BY THE CITIZEN')
step_check_onboarding_status(context=context, citizen_name=citizen_name, status='KO')

Expand All @@ -384,9 +384,9 @@ def step_save_pdnd_consent_not_correctly(context, citizen_name):
def step_try_to_save_pdnd_consent(context, citizen_name, correctness):
token_io = get_io_token(context.citizens_fc[citizen_name])
if correctness == 'not correctly':
pdnd_accept = 'false'
pdnd_accept = False
else:
pdnd_accept = 'true'
pdnd_accept = True

context.pdnd_autocertification_response = pdnd_autocertification(token=token_io,
initiative_id=context.initiative_id,
Expand All @@ -398,7 +398,7 @@ def step_try_to_insert_self_declared_criteria(context, citizen_name):
token_io = get_io_token(context.citizens_fc[citizen_name])
context.pdnd_autocertification_response = pdnd_autocertification(token=token_io,
initiative_id=context.initiative_id,
self_declaration_accepted='false')
self_declaration_accepted=False)


@then('the latest saving of consent failed because {reason_ko}')
Expand Down

0 comments on commit 018bc0e

Please sign in to comment.