def test_create_capture(self): payment_facade = Payment() with patch('yandex_checkout.client.ApiClient.request') as request_mock: request_mock.return_value = { 'amount': { 'currency': 'RUB', 'value': 1.0 }, 'created_at': '2017-11-30T15:45:31.130Z', 'id': '21b23b5b-000f-5061-a000-0674e49a8c10', 'metadata': { 'float_value': '123.32', 'key': 'data' }, 'paid': False, 'payment_method': { 'type': 'bank_card' }, 'recipient': { 'account_id': '156833', 'gateway_id': '468284' }, 'status': 'waiting_for_capture' } payment = payment_facade.capture( '21b23b5b-000f-5061-a000-0674e49a8c10') self.assertIsInstance(payment, PaymentResponse) self.assertIsInstance(payment.amount, Amount) self.assertIsInstance(payment.payment_method, PaymentDataBankCard)
def test_create_capture_with_object(self): payment_facade = Payment() with patch('yandex_checkout.client.ApiClient.request') as request_mock: request_mock.return_value = { 'amount': {'currency': 'RUB', 'value': 1.0}, 'created_at': '2017-11-30T15:45:31.130Z', 'id': '21b23b5b-000f-5061-a000-0674e49a8c10', 'metadata': {'float_value': '123.32', 'key': 'data'}, 'paid': False, 'payment_method': {'type': 'bank_card'}, 'recipient': {'account_id': '156833', 'gateway_id': '468284'}, 'status': 'waiting_for_capture' } payment = payment_facade.capture('21b23b5b-000f-5061-a000-0674e49a8c10', CapturePaymentRequest({ "amount": { "value": "1.00", "currency": "RUB" }, "receipt": { "items": [ { "description": "Item description", "amount": { "value": "1.00", "currency": "RUB" }, "quantity": 1, "vat_code": 3 } ], "tax_system_id": 2, "email": "test@test" }, "payment_method_data": { "type": "bank_card" }, "confirmation": { "type": "redirect", "return_url": "https://test.test/test" }, "capture": False, "save_payment_method": False, "metadata": { "key": "data", "float_value": 123.32 } })) self.assertIsInstance(payment, PaymentResponse) self.assertIsInstance(payment.amount, Amount) self.assertIsInstance(payment.payment_method, PaymentDataBankCard)