This article presents a possible use case and corresponding sample flow that you can support. This can be a helpful jumping off point as you plan your implementation.
A company wants to build an app that imports payment method type names and icons for transactions from their Wix site into their external accounting software.
To import payment method type data, retrieve it using the API.
There are two parts to this flow:
To retrieve the display names and icons of payment method types for existing transactions:
Call List Site Payment Method Types to get all payment method types. The total number of objects received should be no more than several hundred, so you can keep them all in memory.
Call Transactions List to load a portion of existing transactions by setting limit
to 1000
. Save the returned pagination
object for later use.
For each transaction retrieved in step 2:
a. Save the transaction's id
.
b. Find the transaction's payment method type by comparing it's paymentMethod
property with the id
or legacyId
property of each site payment method type loaded in step 1.
c. Read the displayName
and merchantFlow.icons
properties of the identified payment method type. Check the icon's format
and tag
properties to determine which icon image you want to use.
d. Save the displayName
, and the image
of the selected icon from the merchantFlow.icons
along with the transaction's id
. Use the retrieved display name and image in your accounting software.
Read the values in the the pagination
object received in step 2. If the sum of offset
and limit
is less than the total
, repeat the flow starting from step 2, passing the sum ofoffset
and limit
as a new offset
.
For each payment event your app receives via the Payment webhook:
Check the data from the event. If the event has a transactionCreatedEvent
or a transactionUpdatedEvent
property, save the value of the transaction
object's id
and paymentMethod
. Otherwise, ignore the event.
Call List Site Payment Method Types, specifying the paymentMethod
value saved in step 1 as the ids
parameter.
Read the displayName
and merchantFlow.icons
properties from the returned site payment method type. Check the icon's format
and tag
properties to determine which icon image you want to use.
Save the displayName
, and the image
of the selected icon from the merchantFlow.icons
along with the transaction's id
. Use the retrieved display name and image in your accounting software.
You now have a continuously updating record of every transaction id
, along with it's associated displayName
and image
.