bunq / sdk_python

Python SDK for bunq API
MIT License
106 stars 25 forks source link

reopening of question #12 generated.Payment.FIELD_COUNTERPARTY_ALIAS not working with IBAN #96

Closed CharlPels closed 6 years ago

CharlPels commented 6 years ago

In issue #12 a solution was given for sending money to IBAN numbers, this is no longer working for the new SDK. Would love to know how to do the same in the with the new sdk,

thinker sample is only for sending to email

    endpoint.Payment.create(
        amount=Amount(amount_string, self._CURRENCY_EUR),
        counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
        description=description
    )
OGKevin commented 6 years ago

https://github.com/bunq/sdk_python/blob/25c6e353dfcefedfd4e1cd01e6cea529c710e7ef/bunq/sdk/model/generated/object_.py#L440-L463

I think this says enough ? :)

Closing as this is not a bug or feature request. Feel free to continue commenting.

CharlPels commented 6 years ago

Thanks Kevin,

issue solved, and for others this may help them

for the core part i added this

from bunq.sdk.model import core

then 2 classes

class Pointer(core.BunqModel): 
""" 
:param type_: The alias type, can be: EMAIL|PHONE_NUMBER|IBAN. 
:type type_: str 
:param value: The alias value. 
:type value: str 
:param name: The alias name. 
:type name: str 
""" 

    def __init__(self, type_=None, value=None, name=None): 
     """ 
     :param type_: The alias type, can be: EMAIL|PHONE_NUMBER|IBAN. 
     :type type_: str 
     :param value: The alias value. Phone number are formatted conform E.123 
     without spaces (e.g., +314211234567). 
     :type value: str 
     :param name: The alias name. Only required for IBANs. 
     :type name: str 
     """ 

     self.type_ = type_ 
     self.value = value 
     self.name = name 

 class Amount(core.BunqModel): 
    def __init__(self, value=None, currency=None):  
     self.value = value 
     self.currency = currency

Here is my payment function

   def Payment(_PAYMENT_AMOUNT,_COUNTERPARTY_IBAN,_COUNTERPARTY_NAME,_PAYMENT_DESCRIPTION,_MONETARY_ACCOUNT_ITEM_ID):
    endpoint.Payment.create(
        amount=Amount(_PAYMENT_AMOUNT, "EUR"),
        counterparty_alias=Pointer("IBAN",_COUNTERPARTY_IBAN,_COUNTERPARTY_NAME),
        description=_PAYMENT_DESCRIPTION,
        monetary_account_id=_MONETARY_ACCOUNT_ITEM_ID
    )