Hi there,
I'm confused with documentation and API examples on VSM service.
What I need to do is to filter out stopped transactions (returned by the Search API) from the COF Data service API to get a list of merchants to be displayed under the "Active" section of the screen.
From the outset, I have to stop recurring transactions by retrieved "rawMerchantName"s' from COF-RawMerchantDatails API.
And the problems are:
1) I can't see "rawMerchantName" field in given API examples
2) How do I have to separate correctly Active merchants from Stopped when I get list of main merchants by COF-MerchantAggregation API because I stop subscriptions only by "rawMerchantName"
Hope someone's already run through that process.
I'll be glad any help. Thx.
Hi @Ejen, Thank you for reaching out. One of our agents will get back to you soon. Until then, if anyone else has information you feel may help, please respond to this thread.
Hi @Ejen,
I'll take a look and get back soon.
Hey @Ejen,
To get a list of active subscriptions, use the Card-on-File Merchant Aggregation API. This will give you a list of merchants that have your card on file and placed an authorization request in the last 13 months.
To get a list of merchants with stopped instructions on a PAN, use the Search API. You can filter the list by stop instruction type (MERCHANT).
Compare the results from the COF Merchant aggregation and Search APIs to filter out those merchants that have a stop instruction. These merchants will not be displayed under the ‘Active Subscriptions’ sections.
Our recommendation while creating a stop instruction is to use the PFID/SMID + Merchant Name. If the PFID/SMID is not available, then use the merchant name + CAID.
To get the rawMerchant name, follow these steps.
Examples of the raw merchant name can be found on VDP.
For further help, please reach out to your Visa Representative.
Hey @Ejen,
To filter out stopped transactions and display active merchants, you need to follow a series of steps involving multiple APIs. Here's a streamlined approach:
Steps to Follow
1. Get Active Merchants:
Use the COF Merchant Aggregation API to get a list of merchants that have your card on file and placed an authorization request in the last 13 months.
2. Get Stopped Merchants:
Use the Search API to filter for merchants with stop instructions on a PAN. Filter the list by stop instruction type (MERCHANT).
3. Compare and Filter:
Compare the results from the COF Merchant Aggregation and Search APIs to filter out merchants that have a stop instruction. Only the remaining merchants will be displayed under the ‘Active Subscriptions’ section.
Detailed Steps
1. Get Active Merchants:
```http
GET /v1/cof/merchantaggregation
Host: api.visa.com
```
This API call will return a list of merchants.
2. Get Stopped Merchants:
```http
GET /v1/search
Host: api.visa.com
```
Use filters to get merchants with stop instructions.
3. Retrieve Raw Merchant Name:
For each merchant in the active list, use the `mrchRef` value to get the `rawMerchantName` from the COF Raw Merchant Details API.
```http
GET /v1/cof/rawmerchantdetails?mrchRef=<mrchRef>
Host: api.visa.com
```
This will return the `rawMerchantName`.
4. Filter Out Stopped Merchants:
Compare the `rawMerchantName` from the active list with the `rawMerchantName` from the stopped list obtained via the Search API. Exclude those merchants from the active list that appear in the stopped list.
Example Code Snippet
Here's a Python example to illustrate the process:
```python
# START
import requests
def get_active_merchants():
response = requests.get("https://api.visa.com/v1/cof/merchantaggregation", headers=headers)
return response.json()["merchants"]
def get_stopped_merchants():
response = requests.get("https://api.visa.com/v1/search", headers=headers, params={"type": "MERCHANT"})
return response.json()["merchants"]
def get_raw_merchant_name(mrchRef):
response = requests.get(f"https://api.visa.com/v1/cof/rawmerchantdetails?mrchRef={mrchRef}", headers=headers)
return response.json()["rawMrchName"]
def filter_active_merchants(active_merchants, stopped_merchants):
stopped_merchant_names = [get_raw_merchant_name(m["mrchRef"]) for m in stopped_merchants]
active_merchants_filtered = [m for m in active_merchants if get_raw_merchant_name(m["mrchRef"]) not in stopped_merchant_names]
return active_merchants_filtered
headers = {
"Authorization": "Bearer <your_access_token>",
"Content-Type": "application/json"
}
active_merchants = get_active_merchants()
stopped_merchants = get_stopped_merchants()
active_merchants_filtered = filter_active_merchants(active_merchants, stopped_merchants)
print("Active Merchants:", active_merchants_filtered)
# END
```
Key Points
- Ensure you use the correct fields (`mrchRef`, `rawMerchantName`) as required.
- If `PFID/SMID` is available, use that along with the merchant name.
- Handle API responses properly, including error handling.
By following these steps, you should be able to filter out stopped transactions and display active merchants effectively.