International Wire

The International Wire Adapter facilitates wire transfers from a U.S. financial institution to foreign institutions.

With the International Wire Adapter, users can:

  • Initiate one-time international wire transfers to recipients in any foreign financial institution.

  • Schedule future-date wire transfers for specific payment dates or set up recurring wire transfer series for regular payments.

  • Make SWIFT wire transfers

By default, the following boilerplate code will be generated in your extension:

async def handle_international_wire(
    self, international_wire: InternationalWireRequest, source_account: HostAccountRequest
) -> bool:
  • international_wire: Contains the destination and transaction details submitted by the end user.

  • source_account: Contains the details of the account from which the transfer is initiated.

This method returns a boolean value, which indicates whether the wire transfer was successful. You can customize the logic within this function to manipulate the flow of the international wire transfer, add validations, and interact with third-party providers.

Walkthrough

Now, let’s walk through an example implementation for handling international wire transfers. We’ll explain the key steps involved in the logic, starting with the handle_international_wire method and diving into the helper functions used to prepare the transfer and communicate with the external wire service.

  1. Import Required Libraries

    To begin, you’ll need to import the relevant libraries for the operation:

    import json
    from q2_sdk.core import q2_requests
    from datetime import datetime
    
  2. Perform the wire transfer

    The handle_international_wire method is the entry point for processing an international wire transfer. It takes two key parameters: international_wire and source_account, which contain the wire details and the account information, respectively.

    async def handle_international_wire(
        self,
        international_wire: InternationalWireRequest,
        source_account: HostAccountRequest,
    ) -> bool:
        """
        Perform your international wire transfer here. If you return true, a transaction will be generated and visible
        throughout the q2 platform-- only return 'true' on a success.
    
        :param international_wire: Wire destination and details submitted by user
        :param source_account: The account from which to source the transfer
        """
    
        # Serialize the wire transfer data to JSON format
        payload = await self.serialize_payload_to_json(
            international_wire, source_account
        )
    
        # Send the transfer request to the external wire provider
        response = await self.send_wire_transfer(payload)
    
        # Handle the response: Log and return success/failure
        if not response.get("success"):
            self.logger.error(f"Error initiating wire transfer: {response}")
            return False
    
        self.logger.info(f"International wire transfer successful: {response}")
        return True
    

    Explanation:

    The handle_international_wire method is responsible for orchestrating the international wire transfer.

    1. It calls the serialize_payload_to_json function to convert the wire details and source account data into the required JSON payload.

    2. Next, it sends the payload to an external service using the send_wire_transfer method.

    3. It then checks if the response indicates a successful transaction and logs the result.

    Important Details:

    • The method returns True on a successful transfer and False on failure.

    • Logs are used to provide detailed information on the status of the wire transfer.

Testing the International Wire Transfer

Now that we have implemented the logic for the international wire transfer, let’s test it within the Q2 Online Banking sandbox environment.

  1. Log in to your sandbox environment: Use commercial0 as the user login for testing or another user under the Commercial group.

  2. Navigate to the International Wire interface: Go to Payments > New Payment > International Wire.

  3. Fill out the form: Enter the details for the international wire transfer, such as the account details, process date, recipient account, and transfer amount.

  4. Approve the transaction: After filling out the form, click on Approve to initiate the transfer.

    When the end user clicks Approve, several actions occur behind the scenes to complete the transfer.

    1. The request is sent to your handle_international_wire method, which processes the data and prepares the payload for submission to the external wire transfer network.

    2. Your custom logic validates the transfer data, and handles the call to the third-party wire provider.

    3. Depending on the response, your function will return a boolean to denote a successful or failed transaction

More details on the flow can be found in the Architecture section.