add support to milti transaction
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import requests
|
||||
from aws_lambda_powertools.utilities.typing.lambda_context import LambdaContext
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
|
||||
import events.payments.charge_credit_card as app
|
||||
|
||||
from ...test_iugu import MockResponse
|
||||
|
||||
event = {
|
||||
'detail': {
|
||||
'new_image': {
|
||||
'credit_card': {
|
||||
'number': '4242424242424242',
|
||||
'cvv': '123',
|
||||
'created_at': '2026-01-13T02:33:57.088176-03:00',
|
||||
'exp_month': '03',
|
||||
'exp_year': '2027',
|
||||
'ttl': 1768282737,
|
||||
'holder_name': 'Sergio R Siqueira',
|
||||
},
|
||||
'created_at': '2026-01-13T02:34:00.065619-03:00',
|
||||
'invoice_id': '493dd32a-b646-40b2-a307-0fcb3d42d954-2097',
|
||||
'installments': 12,
|
||||
'ttl': 1768282740,
|
||||
'id': '121c1140-779d-4664-8d99-4a006a22f547',
|
||||
'sk': 'TRANSACTION',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def test_charge_credit_card(
|
||||
monkeypatch,
|
||||
dynamodb_seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
'post',
|
||||
lambda url, *args, **kwargs: MockResponse(
|
||||
'tests/samples/iugu_payment_token.json'
|
||||
if 'payment_token' in url
|
||||
else 'tests/samples/iugu_charge_paid.json'
|
||||
),
|
||||
)
|
||||
|
||||
assert app.lambda_handler(event, lambda_context) # type: ignore
|
||||
@@ -2,7 +2,7 @@ from decimal import Decimal
|
||||
|
||||
import requests
|
||||
from aws_lambda_powertools.utilities.typing.lambda_context import LambdaContext
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, SortKey, TransactKey
|
||||
|
||||
import events.payments.create_invoice as app
|
||||
|
||||
@@ -89,3 +89,37 @@ def test_create_bank_slip_pix(
|
||||
invoice['pix']['qrcode_text']
|
||||
== 'http://faturas.iugu.com/iugu_pix/970cb579-c396-4e59-a323-ce61ae04f7bc-196c/test/pay'
|
||||
)
|
||||
|
||||
|
||||
def test_create_credit_card(
|
||||
monkeypatch,
|
||||
dynamodb_seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
'post',
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
'tests/samples/iugu_invoice_credit_card.json'
|
||||
),
|
||||
)
|
||||
|
||||
assert app.lambda_handler(_event('CREDIT_CARD'), lambda_context) # type: ignore
|
||||
|
||||
invoice = dynamodb_persistence_layer.collection.get_items(
|
||||
TransactKey(order_id)
|
||||
+ SortKey('0')
|
||||
+ SortKey('INVOICE')
|
||||
+ SortKey('TRANSACTION')
|
||||
)
|
||||
print(invoice)
|
||||
|
||||
# assert (
|
||||
# invoice['pix']['qrcode_text']
|
||||
# == 'http://faturas.iugu.com/iugu_pix/970cb579-c396-4e59-a323-ce61ae04f7bc-196c/test/pay'
|
||||
# )
|
||||
# assert (
|
||||
# invoice['pix']['qrcode_text']
|
||||
# == 'http://faturas.iugu.com/iugu_pix/970cb579-c396-4e59-a323-ce61ae04f7bc-196c/test/pay'
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user