def test_get_payment_method_details(): payment_intent = StripeObject() payment_intent.charges = { "data": [{ "payment_method_details": { "type": "card", "card": { "last4": "1234", "exp_year": "2222", "exp_month": "12", "brand": "visa", }, } }] } payment_method_info = get_payment_method_details(payment_intent) assert payment_method_info == PaymentMethodInfo( last_4="1234", exp_year=2222, exp_month=12, brand="visa", type="card", )
def test_get_payment_method_info_no_additional_data(dummy_payment_data): # given data = {"paymentMethod": {"type": "scheme"}} dummy_payment_data.data = data api_call_result_mock = mock.Mock() message = {} api_call_result_mock.message = message # when payment_method_info = get_payment_method_info(dummy_payment_data, api_call_result_mock) # then assert payment_method_info == PaymentMethodInfo(type="card")
def test_get_payment_method_info_scheme_payment_method_type( dummy_payment_data): # given data = {"paymentMethod": {"type": "scheme"}} dummy_payment_data.data = data api_call_result_mock = mock.Mock() message = {"additionalData": {"paymentMethod": "visa-test"}} api_call_result_mock.message = message # when payment_method_info = get_payment_method_info(dummy_payment_data, api_call_result_mock) # then assert payment_method_info == PaymentMethodInfo( brand=message["additionalData"]["paymentMethod"], type="card")