Update Account

Update an account

Accounts Overview

{
  "profileFields": [{
    "fieldId": "individualLegalName",
    "value": "Johnny Quest"
  }, {
    "fieldId": "individualCellphoneNumber",
    "value": "+1 715-111-2222"
  }, {
    "fieldId": "individualEmail",
    "value": "[email protected]"
  }, {
    "fieldId": "individualDateOfBirth",
    "value": "1990-09-24"
  }, {
    "fieldId": "individualResidenceAddress",
    "value": {
        "street1": "1 Market St",
        "street2": "Suite 420",
        "city": "San Francisco",
        "state": "CA",
        "postalCode": "94105",
        "country": "US"
      }
  }
  ]
}
'''
This is a Python 3.7 Module that updates a Wyre Account
using secret key authentication.

You can only use this module for updating individual
or business accounts if you already have an account set up.

If you do not have a business or individual account with a secretKey/ApiKey,
go through the sign-up process for a test account here: https://www.testwyre.com/
'''

import hashlib
import hmac
import json
import os
import requests
import time
import urllib.parse


class WyreApi:
    ACCOUNT_ID = os.getenv("ACCOUNT_ID")
    API_KEY = os.getenv("WYRE_APIKEY")
    SEC_KEY = os.getenv("WYRE_TOKEN")
    API_VER3 = "/v3"
    API_ACCOUNT_PATH = "/accounts"
    API_URL = "https://api.testwyre.com"




    '''
        This method calculates the auth signature hash required for secret key 
        authentication
    '''

    def calc_auth_sig_hash(self, url_body):
        # calculates a signature per Wyre API:
        # https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth
        message, secret = bytes(
            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')
        newhash = hmac.new(secret, message, hashlib.sha256)
        return newhash.hexdigest()





    '''
        This method calculates a timesteamp required for the secret key 
        authentication
    '''

    def calcTimeStamp(self):
        # creates a timestamp to the millisecond
        return str(round(time.time() * 1000))





    '''
        This method updates an account
    '''

    def updateAccount(self, post_data=None):
        if not post_data:
            print("You need to pass in an update object")
            return

        params = {
            "timestamp": self.calcTimeStamp()
            # If you are masquerading (acting on behalf) of your subaccount
            # enter your account_id associated with your business account
            # You could add that field in when passing data into the method
            # "masqueradeAs": "ENTER ACCOUNT ID HERE"
        }
        url = WyreApi.API_URL + WyreApi.API_VER3 + WyreApi.API_ACCOUNT_PATH + \
            "?" + urllib.parse.urlencode(params, encoding='utf-8')
        headers = {
            'X-API-Key': WyreApi.API_KEY,
            'X-API-Signature': self.calc_auth_sig_hash(url + json.dumps(post_data))
        }
        response = requests.post(url, headers=headers, json=post_data)
        if response.status_code == 200:
            return json.loads(response.text)
        else:
            print(response)

            
            

if __name__ == "__main__":
    #=========== Initializes a Wyre Obj ============= #
    account = WyreApi()

    #======== Updating account with payment method ==== #
    # You can add/subtract any fields you'd like to update an account
    # https://docs.sendwyre.com/docs/account-resource#section-field-ids
    updateObj = {
        "profileFields": [{
            "fieldId": "individualLegalName",
            "value": "Johnny Quest"
        }, {
            "fieldId": "individualCellphoneNumber",
            "value": "+1 715-111-2222"
        }, {
            "fieldId": "individualEmail",
            "value": "[email protected]"
        }, {
            "fieldId": "individualDateOfBirth",
            "value": "1990-09-24"
        }, {
            "fieldId": "individualResidenceAddress",
            "value": {
                "street1": "1 Market St",
                "street2": "Suite 420",
                "city": "San Francisco",
                "state": "CA",
                "postalCode": "94105",
                "country": "US"
            }
        }
        ]
    }

    update = account.updateAccount(updateObj)
    # Prints the server response
    if update:
      print(update)

Field Statuses

You'll submit the account information to be processed on Wyre. The status field is then going to be updated to either OPEN | PENDING | APPROVED. We provide a note field, which will provide guidance on resolving the issue.

StatusDescriptionExample
OPENAwaiting action from user.Expired document, awaiting resubmission.
PENDINGAwaiting action from Wyre.Processing on Wyre.
APPROVEDNo further action needed.Document successfully verified.
Language
Authorization
Bearer
URL
Click Try It! to start a request and see the response here!