Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

Ejen
Dabbler

Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscription

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.

5 REPLIES 5
jenn_kh
Community Moderator

Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

Hi @EjenThank 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.

API_Products
Visa Developer Support Specialist

Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

Hi @Ejen,

 

I'll take a look and get back soon. 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

API_Products
Visa Developer Support Specialist

Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

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.

  1. Get the value from mrchRef field returned by the COF Merchant Aggregation API
  2. Use the mrchRef value as a query parameter in the COF Raw Merchant Details API
  3. The COF Raw Merchant Details API will return the raw merchant name (Field: rawMrchName)

Examples of the raw merchant name can be found on VDP.

 

For further help, please reach out to your Visa Representative.




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

Ejen
Dabbler

Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

Hi Tee,
Thank you for your answer!

It would help a lot but addMerchant API doesn’t work as you’ve mentioned. I can’t use the merchant name + CAID in my request as it’s said in documentation like
{
“duration”: 1,
“merchantIdentifiers”: {
“grouped”: [
{
“cardAcceptotId”: “…”,
“merchantName”: “…”
}
] },
“pan”: “…”,
“startDate”: “2024-09-27”
}

because then I get in Search API 2(two) different stopInstructionId for each parameter (CAID and merchantName).

Check it please.

It would help a lot because I have equal rawMerchantNames for one or more merchants
API_Products
Visa Developer Support Specialist

Re: Problem matching COFs' and VSPS-Search API responses to create lists of Active/Stopped subscript

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.

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.