def velo_countries(): configuration = velo_payments.Configuration() configuration.host = os.environ.get("VELO_BASE_URL") api_instance = velo_payments.CountriesApi( velo_payments.ApiClient(configuration)) try: api_response = api_instance.list_supported_countries() except ApiException as e: print( "Exception when calling CountriesApi->list_supported_countries: %s\n" % e) res = [] for country in api_response.countries: c = {} c['currencies'] = country.currencies c['iso_country_code'] = country.iso_country_code ra = [] for region in country.regions: r = {} r['abbreviation'] = region.abbreviation r['name'] = region.name ra.append(r) c['regions'] = ra res.append(c) return jsonify(res)
def refreshVeloOAuth(): # Check if OAuth2 token is about to expire ... if so .. issue event to refresh it # grab the VELO_API_ACCESSTOKENEXPIRATION from django.constance # if now is >= VELO_API_ACCESSTOKENEXPIRATION ... call api and update configs with access_token & expires_in # when updating expiration be sure to remove 5 mins (300 sec) off of expires_in now_int = int(time.time()) if int(app.config['VELO_API_ACCESSTOKENEXPIRATION']) <= now_int: print('CALL VELO API TO REFRESH TOKEN') configuration = velo_payments.Configuration() configuration.username = os.environ.get("VELO_API_APIKEY") configuration.password = os.environ.get("VELO_API_APISECRET") configuration.host = os.environ.get("VELO_BASE_URL") grant_type = 'client_credentials' try: # Authentication endpoint api_instance = velo_payments.LoginApi( velo_payments.ApiClient(configuration)) api_response = api_instance.velo_auth(grant_type=grant_type) print(api_response) app.config['VELO_API_ACCESSTOKEN'] = api_response.access_token app.config['VELO_API_ACCESSTOKENEXPIRATION'] = ( now_int + int(api_response.expires_in)) - 300 print("new velo oauth2 token expires at: %s\n" % app.config['VELO_API_ACCESSTOKENEXPIRATION']) except ApiException as e: print("Exception when calling AuthApi->velo_auth: %s\n" % e) else: print("velo oauth token has not expired")
def test_get_payout_stats_v4(self): """Test case for get_payout_stats_v4 Get Payout Statistics # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PaymentAuditServiceApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | api_response = api_instance.get_payout_stats_v4(payor_id=payor_id)
def test_list_supported_currencies_v2(self): """Test case for list_supported_currencies_v2 List Supported Currencies # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.CurrenciesApi(velo_payments.ApiClient(configuration)) try: api_response = api_instance.list_supported_currencies_v2() except ApiException as e: print("Exception when calling CurrenciesApi->list_supported_currencies_v2: %s\n" % e)
def velo_payor_info(): configuration = velo_payments.Configuration() configuration.access_token = app.config['VELO_API_ACCESSTOKEN'] configuration.host = os.environ.get("VELO_BASE_URL") api_instance = velo_payments.PayorsApi( velo_payments.ApiClient(configuration)) payor_id = os.environ.get("VELO_API_PAYORID") try: api_response = api_instance.get_payor_by_id_v2(payor_id) except ApiException as e: print("Exception when calling PayorsApi->get_payor_by_id_v2: %s\n" % e) res = {} a = {} a['city'] = api_response.address.city a['country'] = api_response.address.country a['county_or_province'] = api_response.address.county_or_province a['line1'] = api_response.address.line1 a['line2'] = api_response.address.line2 a['line3'] = api_response.address.line3 a['line4'] = api_response.address.line4 a['zip_or_postcode'] = api_response.address.zip_or_postcode res['address'] = a res['allows_language_choice'] = api_response.allows_language_choice res['collective_alias'] = api_response.collective_alias res['dba_name'] = api_response.dba_name res['includes_reports'] = api_response.includes_reports res['kyc_state'] = api_response.kyc_state res['language'] = api_response.language res['manual_lockout'] = api_response.manual_lockout res['max_master_payor_admins'] = api_response.max_master_payor_admins res['payee_grace_period_days'] = api_response.payee_grace_period_days res['payee_grace_period_processing_enabled'] = api_response.payee_grace_period_processing_enabled res['payment_rails'] = api_response.payment_rails res['payor_id'] = api_response.payor_id res['payor_name'] = api_response.payor_name res['primary_contact_email'] = api_response.primary_contact_email res['primary_contact_name'] = api_response.primary_contact_name res['primary_contact_phone'] = api_response.primary_contact_phone res['reminder_emails_opt_out'] = api_response.reminder_emails_opt_out res['support_contact'] = api_response.support_contact res['wu_customer_id'] = api_response.wu_customer_id return jsonify(res)
def test_payor_links(self): """Test case for payor_links List Payor Links # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PayorsApi( velo_payments.ApiClient(configuration)) descendants_of_payor = os.environ[ "PAYOR"] # str | The Payor ID from which to start the query to show all descendants (optional) parent_of_payor = None # str | Look for the parent payor details for this payor id (optional) fields = None # str | List of additional Payor fields to include in the response for each Payor. The values of payorId and payorName and always included for each Payor - 'fields' allows you to add to this. Example: ```fields=primaryContactEmail,kycState``` - will include payorId+payorName+primaryContactEmail+kycState for each Payor Default if not specified is to include only payorId and payorName. The supported fields are any combination of: primaryContactEmail,kycState (optional) api_response = api_instance.payor_links( descendants_of_payor=descendants_of_payor)
def test_get_payouts_for_payor_v4(self): """Test case for get_payouts_for_payor_v4 Get Payouts for Payor # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PaymentAuditServiceApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | page = 1 # int | Page number. Default is 1. (optional) (default to 1) page_size = 25 # int | The number of results to return in a page (optional) (default to 25) sort = 'submittedDateTime:desc' # str | List of sort fields (e.g. ?sort=submittedDateTime:asc,instructedDateTime:asc,status:asc) Default is submittedDateTime:asc The supported sort fields are: submittedDateTime, instructedDateTime, status, totalPayments, payoutId (optional) api_response = api_instance.get_payouts_for_payor_v4( payor_id=payor_id, page=page, page_size=page_size, sort=sort)
def test_get_payees_invitation_status_v3(self): """Test case for get_payees_invitation_status_v3 Get Payee Invitation Status # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PayeeInvitationApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | payee_id = None # str | The UUID of the payee. (optional) invitation_status = None # velo_payments.InvitationStatus() # InvitationStatus | The invitation status of the payees. (optional) page = 1 # int | Page number. Default is 1. (optional) (default to 1) page_size = 25 # int | Page size. Default is 25. Max allowable is 100. (optional) (default to 25) api_response = api_instance.get_payees_invitation_status_v3( payor_id, page=page, page_size=page_size)
def test_list_payee_changes_v3(self): """Test case for list_payee_changes_v3 List Payee Changes # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PayeesApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | updated_since = '2013-10-20T19:20:30+01:00' # datetime | The updatedSince filter in the format YYYY-MM-DDThh:mm:ss+hh:mm page = 1 # int | Page number. Default is 1. (optional) (default to 1) page_size = 100 # int | Page size. Default is 100. Max allowable is 1000. (optional) (default to 100) api_response = api_instance.list_payee_changes_v3(payor_id, updated_since, page=page, page_size=page_size)
def test_get_fundings_v4(self): """Test case for get_fundings_v4 Get Fundings for Payor # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PaymentAuditServiceApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | page = 1 # int | Page number. Default is 1. (optional) (default to 1) page_size = 25 # int | The number of results to return in a page (optional) (default to 25) sort = 'dateTime:desc' # str | List of sort fields. Example: ```?sort=destinationCurrency:asc,destinationAmount:asc``` Default is no sort. The supported sort fields are: dateTime and amount. (optional) api_response = api_instance.get_fundings_v4(payor_id, page=page, page_size=page_size, sort=sort)
def velo_currencies(): configuration = velo_payments.Configuration() configuration.host = os.environ.get("VELO_BASE_URL") api_instance = velo_payments.CurrenciesApi( velo_payments.ApiClient(configuration)) try: api_response = api_instance.list_supported_currencies() except ApiException as e: print( "Exception when calling CurrenciesApi->list_supported_currencies: %s\n" % e) res = [] for currency in api_response.currencies: c = {} c['currency'] = currency.currency c['max_payment_amount'] = currency.max_payment_amount res.append(c) return jsonify(res)
def velo_fund_account(): content = request.json configuration = velo_payments.Configuration() configuration.access_token = app.config['VELO_API_ACCESSTOKEN'] configuration.host = os.environ.get("VELO_BASE_URL") api_instance = velo_payments.FundingManagerApi( velo_payments.ApiClient(configuration)) source_account_id = content['source_account'] funding_request_v1 = velo_payments.FundingRequestV1( amount=content['amount']) try: api_instance.create_ach_funding_request(source_account_id, funding_request_v1) except ApiException as e: print( "Exception when calling FundingManagerApi->create_ach_funding_request: %s\n" % e) return jsonify({})
def setUp(self): self.api = velo_payments.api.countries_api.CountriesApi() # noqa: E501 if os.environ.get('APITOKEN') == "": configuration = velo_payments.Configuration() # Configure HTTP basic authorization: basicAuth configuration.username = os.environ.get('KEY') configuration.password = os.environ.get('SECRET') # Defining host is optional and default to https://api.sandbox.velopayments.com configuration.host = os.environ.get('APIURL') # Create an instance of the API class api_instance = velo_payments.LoginApi(velo_payments.ApiClient(configuration)) grant_type = 'client_credentials' # str | OAuth grant type. Should use 'client_credentials' (optional) (default to 'client_credentials') try: # Authentication endpoint api_response = api_instance.velo_auth(grant_type=grant_type) os.environ["APITOKEN"] = api_response.access_token except ApiException as e: print("Exception when calling LoginApi->velo_auth: %s\n" % e)
def test_list_payees_v3(self): """Test case for list_payees_v3 List Payees # noqa: E501 """ configuration = velo_payments.Configuration() configuration.access_token = os.environ["APITOKEN"] configuration.host = os.environ.get('APIURL') api_instance = velo_payments.PayeesApi( velo_payments.ApiClient(configuration)) payor_id = os.environ["PAYOR"] # str | disabled = False # bool | Payee disabled (optional) payee_country = 'US' # str | The country of the payee - 2 letter ISO 3166-1 country code (upper case) (optional) page = 1 # int | Page number. Default is 1. (optional) (default to 1) page_size = 25 # int | Page size. Default is 25. Max allowable is 100. (optional) (default to 25) sort = 'displayName:asc' # str | List of sort fields (e.g. ?sort=onboardedStatus:asc,name:asc) Default is name:asc 'name' is treated as company name for companies - last name + ',' + firstName for individuals The supported sort fields are - payeeId, displayName, payoutStatus, onboardedStatus. (optional) (default to 'displayName:asc') api_response = api_instance.list_payees_v3(payor_id, disabled=disabled, payee_country=payee_country, page=page, page_size=page_size, sort=sort)
def velo_source_accounts(): configuration = velo_payments.Configuration() configuration.access_token = app.config['VELO_API_ACCESSTOKEN'] configuration.host = os.environ.get("VELO_BASE_URL") api_instance = velo_payments.FundingManagerApi( velo_payments.ApiClient(configuration)) payor_id = os.environ.get("VELO_API_PAYORID") try: api_response = api_instance.get_source_accounts_v2(payor_id=payor_id) except ApiException as e: print( "Exception when calling FundingManagerApi->get_source_accounts_v2: %s\n" % e) res = {} c = [] for con in api_response.content: atuc = {} catuc = con.auto_top_up_config atuc['enabled'] = catuc.enabled atuc['min_balance'] = catuc.min_balance atuc['target_balance'] = catuc.target_balance arc = {} arc['auto_top_up_config'] = atuc arc['balance'] = con.balance arc['balance_visible'] = con.balance_visible arc['currency'] = con.currency arc['customer_id'] = con.customer_id arc['funding_account_id'] = con.funding_account_id arc['funding_ref'] = con.funding_ref arc['id'] = con.id arc['name'] = con.name nots = {} nots['minimum_balance'] = con.notifications.minimum_balance arc['notifications'] = nots arc['payor_id'] = con.payor_id arc['physical_account_id'] = con.physical_account_id arc['physical_account_name'] = con.physical_account_name arc['pooled'] = con.pooled arc['rails_id'] = con.rails_id c.append(arc) l = [] for lin in api_response.links: arl = {} arl['href'] = lin.href arl['rel'] = lin.rel l.append(arl) p = {} p['number_of_elements'] = api_response.page.number_of_elements p['page'] = api_response.page.page p['page_size'] = api_response.page.page_size p['total_elements'] = api_response.page.total_elements p['total_pages'] = api_response.page.total_pages res['content'] = c res['links'] = l res['page'] = p return jsonify(res)