def test_payment(mock_downloader, payment_result, snapshot): data_mock = { "referenceId": "4878711", "callbackUrl": "http://www.minhaloja.com.br/callback", "returnUrl": "http://www.minhaloja.com.br/cliente/pedido/4878711", "value": 375.25, "expiresAt": "2022-05-01T16:00:00-03:00", "buyer": { "firstName": "Bugs", "lastName": "Bunny", "document": "123.456.789-10", "email": "*****@*****.**", "phone": "+55 71 12345-6789", }, } token = "some things..." mock_downloader.return_value.post.return_value = mock.Mock( json=payment_result) # get payment... picpay = Picpay(token) response = picpay.payment(data_mock) snapshot.assert_match(response.json)
async def test_cancel_payment_async(mock_downloader, get_cancel_payment_result, snapshot): downloader = mock_downloader.return_value downloader.post_async.return_value = mock.AsyncMock( json=get_cancel_payment_result) picpay = Picpay("some things...") picpay.downloader = downloader response = await picpay.cancel_payment_async("102030", "5c8e4c711c7e4c8d21b1") snapshot.assert_match(response.json)
def test_get_status(mock_downloader, get_status_result, snapshot): referenceId = "11111" token = "some things..." mock_downloader.return_value.get.return_value = mock.Mock( json=get_status_result) # get status of payment... picpay = Picpay(token) response = picpay.get_status(referenceId) snapshot.assert_match(response.json)
def test_cancel_payment(mock_downloader, get_cancel_payment_result, snapshot): referenceId = "11111" authorizationId = "2ce49cu917a8ci10cn" token = "some things..." mock_downloader.return_value.post.return_value = mock.Mock( json=get_cancel_payment_result) # get cancel payment... picpay = Picpay(token) response = picpay.cancel_payment(referenceId, authorizationId) snapshot.assert_match(response.json)
def test_cancel_payment(mock_downloader, get_cancel_payment_result, snapshot): mock_downloader.return_value.post.return_value = mock.Mock( json=get_cancel_payment_result) picpay = Picpay("some things...") response = picpay.cancel_payment("102030", "5c8e4c711c7e4c8d21b1") snapshot.assert_match(response.json)
import os from picpay import Picpay picpay = Picpay(os.environ["PICPAY_TOKEN"])