// FetchAccounts returns all accounts registered for a given aqbanking instance func (u *User) FetchAccounts(aq *AQBanking) error { ctx := C.AB_ImExporterContext_new() pro := C.AB_Banking_GetProvider(aq.ptr, C.CString("aqhbci")) if err := C.AH_Provider_GetAccounts(pro, u.ptr, ctx, 1, 0, 1); err != 0 { return fmt.Errorf("Error getting accounts (%d)", err) } C.AB_ImExporterContext_free(ctx) return nil }
// AddPinTanUser implements the simplified, pintan only workflow from // src/plugins/backends/aqhbci/tools/aqhbci-tool/adduser.c func (ab *AQBanking) AddPinTanUser(user *User) error { if user.BankCode == "" { return errors.New("no bankCode given") } if user.UserID == "" { return errors.New("no userid given") } if user.ServerURI == "" { return errors.New("no server_url given") } if _, ok := supportedHBCIVersions[user.HbciVersion]; ok != true { return fmt.Errorf("hbci version %d is not supported", user.HbciVersion) } var aqUser *C.AB_USER aqhbciProviderName := C.CString("aqhbci") defer C.free(unsafe.Pointer(aqhbciProviderName)) countryDe := C.CString("de") defer C.free(unsafe.Pointer(countryDe)) aqPinTan := C.CString("pintan") defer C.free(unsafe.Pointer(aqPinTan)) var _ *C.AB_PROVIDER = C.AB_Banking_GetProvider(ab.ptr, aqhbciProviderName) aqBankCode := C.CString(user.BankCode) defer C.free(unsafe.Pointer(aqBankCode)) aqUserID := C.CString(user.UserID) defer C.free(unsafe.Pointer(aqUserID)) aqName := C.CString(user.Name) defer C.free(unsafe.Pointer(aqName)) aqUser = C.AB_Banking_FindUser( ab.ptr, C.CString(C.AH_PROVIDER_NAME), countryDe, aqBankCode, aqUserID, aqUserID, ) if aqUser != nil { return fmt.Errorf("user %s already exists", user.UserID) } aqUser = C.AB_Banking_CreateUser(ab.ptr, C.CString(C.AH_PROVIDER_NAME)) if aqUser == nil { return errors.New("unable to create user") } url := C.GWEN_Url_fromString(C.CString(user.ServerURI)) if url == nil { return errors.New("invalid server url") } C.GWEN_Url_SetProtocol(url, C.CString("https")) if C.GWEN_Url_GetPort(url) == 0 { C.GWEN_Url_SetPort(url, C.int(443)) } defer C.GWEN_Url_free(url) C.AB_User_SetUserName(aqUser, aqName) C.AB_User_SetCountry(aqUser, countryDe) C.AB_User_SetBankCode(aqUser, aqBankCode) C.AB_User_SetUserId(aqUser, aqUserID) C.AB_User_SetCustomerId(aqUser, aqUserID) C.AH_User_SetTokenType(aqUser, aqPinTan) C.AH_User_SetTokenContextId(aqUser, C.uint32_t(1)) // context C.AH_User_SetCryptMode(aqUser, C.AH_CryptMode_Pintan) C.AH_User_SetHbciVersion(aqUser, C.int(user.HbciVersion)) C.AH_User_SetServerUrl(aqUser, url) C.AB_Banking_AddUser(ab.ptr, aqUser) user.ptr = aqUser return nil }