Skip to content

A PHP callback demonstrating how to use TransferWise Webhooks

License

Notifications You must be signed in to change notification settings

robclark56/TransferWise_PHP_webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

TransferWise PHP Webhook

Introduction

If you have a (free) TransferWise account, you have free access to both:

  • an API interface to interact with your account, and
  • a Webhook callback to notify you of events/changes in your account.

Basic Details

In this tutorial, you will learn how to use PHP to:

  • Create a webhook that will notify your webserver on deposits (credits),
  • Parse and verify the data passed to your webserver, and
  • Use the API to get details of the transaction.

Importantly, all code here is standalone, and does not use Composer to pull in other code. As such it is light-weight and easy to re-use.

TransferWise 'Issue' (bug?)

Occasionally, when the calllback code queries your TransferWise account and gets the latest statement, the transaction details are not (yet) known and the transaction details look like this:

[details] => stdClass Object
        (
            [type] => UNKNOWN
            [description] => No information
        )

Here is what TransferWise says about this:

Current set up of our system though has an issue , the data which populates to statements can be delayed, that is why in some cases you're missing data.

The best work around at this moment is to hard code the hold off 1-5 minutes and/or in case of missing data do the delayed retry.

I am in conversations with team, we'll be looking for appropriate solution for this, but can't do an estimate on the time line for it to be delivered

Reference Information

Requirements

  1. A public webserver, responding to https requests on port 443, with a valid HTTPS certificate, and allowing you execute PHP scripts
  2. A TransferWise account
  3. You have previously installed and tested TransferWise Simple API PHP Class

Create your PHP Endpoint

  1. Login to your webserver
  2. Create TransferWise_callback.php on your webserver
  3. Edit the CHANGE ME section of TransferWise_callback.php

Test your PHP endpoint

Use your favorite web browser to go to (e.g.): https://your.webserver.domain/TransferWise/TransferWise_callback.php

You should receive an email like this:

To: me@my.domain.com
Subject: TransferWise Callback

File: /xxx/TransferWise/TransferWise_callback.php
Signature not verified. Exiting

Create your Webhook

  1. Login to your TransferWise account (Note: Webhooks will not be called from sandbox accounts)
  2. Goto Settings
  3. Click [Create a new webhook]
  4. Give it a name and enter the URL of the Webhook end-point you tested in the step above
  5. Check Balance deposit events
  6. Click [Create webhook]
  7. Click [Edit webhook]
  8. Click [Test webhook]

You should see on the TransferWise acct page: Everything looks good!

You should receive an email as below.

File: /xxx/TransferWise/TransferWise_callback.php

event_type not set

PAYLOAD:
stdClass Object
(
    [message] => this is a test request
)

Test your Webhook

Sandbox accounts do NOT call Webhooks. The only way to fully test the webhook is to cause a real financial payment into your TransferWise account. When that happens you should receive an email something like this:

File: /xxx/TransferWise/TransferWise_callback.php

currency=USD
amount=88
senderName=FRED BLOGGS
paymentReference=TEST-1234

About

A PHP callback demonstrating how to use TransferWise Webhooks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages