# SNACK MasterCard API implementation ## POST {{ HOST }}/product/addTriggerCard Request: ```jsonld= { "cardType": "MasterCard", // "MasterCard", "Visa" "cardAlias": "5412871ddMA5d9V9827" } ``` Response - Success: ```jsonld= { "success": true, "message": "Enrolled successfully." } ``` Response - Failure: ```jsonld= { "success": false, "errors": [ { "code": "-1001", "message": "Card already enrolled" } ] } ``` Response - Failure - Generic: ```jsonld= { "success": false, "errors": [ { "code": "<Generic Error Code>", "message": "<Generic Error message>" } ] } ``` ## POST {{ HOST }}/product/removeTriggerCard Request: ```jsonld= { "cardType": "MasterCard", // "MasterCard", "Visa" "cardAlias": "5412871ddMA5d9V9827" } ``` Response - Success: ```jsonld= { "success": true, "message": "Removed successfully." } ``` ## GET {{ HOST }}/user/triggerCards?cardType=MasterCard cardType is optional, if it not specified, response will contain all cardType informations with active cards. Response - Success: ```jsonld= { "success": true, "data": [ { "cardType": "MasterCard", "cardAlias": "5412871ddMA5d9V9827", "status": 1, "referenceID": "<>", "userID": "<>", "cardID": "<>", "last4Digits": "9827" } ] } ``` ## ZA: {{ HOST }}snack/query/dataSourceList - ZA need to returm MasterCard DataSource. dataSourceCode": "DS0013", "dataSourceName": "MasterCard", ## DB update: trigger_category_datasource datasources ## ML Logic in BE ### addTriggerCard 1. getCustomerAccounts - MasterCard Service. ```javascript success: [accountStatusId= 1 (enroled)or 3 (cancel)] { "data": { "belongsToLoggedInCustomer": true, "accountStatusId": 3 } } if(accountStatusId == 1) { // card is already enrolled. // return an error message } else { if (accountStatusId == 3) { // updateCustmerAccount // set the accountStatusId=1 // Update ML DB card status as active. // API call addMasterCard to ZA. } else { // Enrol API to Enrol: // { referenceId, customerId } // Insert to ML DB // API call addMasterCard to ZA. } } Error: return an error message ``` ### removeTriggerCard ```javascript updateCustomerAccount API Mastercard. accountStatusId=3 Update ML DB card status as inactive. // API call removeMasterCard to ZA. Return the response. ``` ### `mastercard_cards` ```json { "id": 0, "cardAlias": "5412871ddMA5d9V9827", "status": 1, "referenceID": "<>", "userId": "<>", "cardId": "<>", "last4Digits": "9827", "channelUserId": 123223, "createdAt": "<>", "updatedAt": "<>" } ```