Create a customer, line of credit account, and card

These entities are used to eventually test transactions.

At this point, the following steps should be complete:

  • Generate your API keys
  • Generate a swipe processor key
  • Create an issuer
  • Create a card program
  • Create a line of credit program

With an issuer ID, card program ID, and line of credit ID in hand, use the following steps to create the next set of required entities.

1. Create a customer

A customer profile represents the borrower and cardholder and stores their information. Customers are created within LoanPro, and once a card is created, LoanPro automatically pushes customer information into Secure Payments as well.

Create a customer profile via the following request:

curl --request POST \
     --url https://loanpro.simnang.com/api/public/api/1/odata.svc/Customers \
     --header 'Authorization: Bearer {token}' \
     --header 'Autopal-Instance-Id: {tenant ID}' \
     --header 'content-type: application/json' \
     --data '
{
  "status": "Active",
  "firstName": "John",
  "lastName": "Doe",
  "birthDate": "1970-01-15",
  "ssn": "000000000",
  "accessUserName": "johndoeapiuser",
  "email": "johndoeapiuser@gmail.com",
  "customerType": "customer.type.individual",
  "customerIdType": "customer.idType.ssn",
  "gender": "customer.gender.male",
  "generationCode": "customer.generationCode.none",
  "__ignoreWarnings": true,
  "Phones": {
    "results": [
      {
        "phone": "5551234567",
        "isPrimary": "1",
        "isSecondary": "0",
        "type": "customer.phoneType.cell",
        "carrierVerified": 1,
        "isLandLine": 0
      }
    ]
  },
  "PrimaryAddress": {
    "country": "company.country.usa",
    "verify": true,
    "address1": "201 E Randolph St",
    "city": "Chicago",
    "state": "geo.state.IL",
    "zipcode": "60602",
    "geoLat": "41.882648",
    "geoLon": "-87.623102"
  },
  "MailAddress": {
    "country": "company.country.usa",
    "verify": true,
    "address1": "201 E Randolph St",
    "city": "Chicago",
    "state": "geo.state.IL",
    "zipcode": "60602",
    "geoLat": "41.882648",
    "geoLon": "-87.623102"
  }
}
'

A success response provides details regarding the customer profile:

{
    "d": {
        "__metadata": {
            "uri": "https://loanpro.simnang.com/api/public/api/1/odata.svc/Customers(id=2266)",
            "type": "Entity.Customer"
        },
        "id": 2266,
        "customId": null,
        "mcId": 0,
        "customerType": "customer.type.individual",
        "status": "Active",
        "firstName": "John",
        "lastName": "Doe",
        "middleName": "",
        "birthDate": "/Date(1209600)/",
        "gender": "customer.gender.male",
        "generationCode": "customer.generationCode.none",
        "email": "johndoeapiuser@gmail.com",
        "ssn": "000000000",
        "driverLicense": "",
        "companyName": "",
        "contactName": "",
        "customerIdType": "customer.idType.ssn",
        "customerId": "",
        "creditLimit": 0,
        "accessUserName": "johndoeapiuser@gmail.com",
        "active": 1,
        "ofacMatch": 0,
        "ofacTested": 0,
        "saleTransferPii": 1,
        "passwordChanged": 0,
        "hasAvatar": 0,
        "loanRole": null,
        "created": "/Date(1739838174)/",
        "lastUpdate": "/Date(1739838175)/",
        "creditScoreId": 0,
        "PrimaryAddress": {
            "__metadata": {
                "uri": "https://loanpro.simnang.com/api/public/api/1/odata.svc/Address(id=4639)",
                "type": "Entity.Address"
            },
            "id": 4639,
            "address1": "201 E Randolph St",
            "address2": "",
            "city": "Chicago",
            "state": "geo.state.IL",
            "zipcode": "60602",
            "country": "company.country.usa",
            "geoLat": -1,
            "geoLon": -1,
            "created": null,
            "active": 1,
            "isVerified": 0,
            "isStandardized": 0
        },
        "MailAddress": {
            "__metadata": {
                "uri": "https://loanpro.simnang.com/api/public/api/1/odata.svc/Address(id=4640)",
                "type": "Entity.Address"
            },
            "id": 4640,
            "address1": "201 E Randolph St",
            "address2": "",
            "city": "Chicago",
            "state": "geo.state.IL",
            "zipcode": "60602",
            "country": "company.country.usa",
            "geoLat": -1,
            "geoLon": -1,
            "created": null,
            "active": 1,
            "isVerified": 0,
            "isStandardized": 0
        },
        "Employer": {
            "__deferred": {
                "uri": "Customers(2266)/Employer"
            }
        },
        "References": {
            "__deferred": {
                "uri": "Customers(2266)/References"
            }
        },
        "PaymentAccounts": {
            "__deferred": {
                "uri": "Customers(2266)/PaymentAccounts"
            }
        },
        "Phones": {
            "results": []
        },
        "CustomFieldValues": {
            "__deferred": {
                "uri": "Customers(2266)/CustomFieldValues"
            }
        },
        "Documents": {
            "__deferred": {
                "uri": "Customers(2266)/Documents"
            }
        },
        "CreditScore": {
            "__deferred": {
                "uri": "Customers(2266)/CreditScore"
            }
        },
        "Loans": {
            "__deferred": {
                "uri": "Customers(2266)/Loans"
            }
        },
        "LineOfCredits": {
            "__deferred": {
                "uri": "Customers(2266)/LineOfCredits"
            }
        },
        "SocialProfiles": {
            "__deferred": {
                "uri": "Customers(2266)/SocialProfiles"
            }
        },
        "Notes": {
            "__deferred": {
                "uri": "Customers(2266)/Notes"
            }
        }
    }
}

Capture the value stored within the "id" field. We'll reference this in future steps as {customer-id}.

View the API reference to learn more ↗

2. Create a line of credit account

Line of credit accounts are a type of lending product that can be created and serviced within LoanPro. A line of credit can exist with or without a card; however, in this use case, a card will be associated with the account.

Line of credit accounts are associated with line of credit programs.

A program dictates the default configuration for the account; however, each time a line of credit account is created, its configuration settings can deviate from the program if desired. In this example, we'll use the program's default configuration by including the program's ID within the "productId" field included in the payload.

Send the following request to create a line of credit account. Note that the following variables from previous steps are used within payload of this request:

  1. {loc-program-id} : the ID of the line of credit program
  2. {customer-id} : the ID of the customer profile
curl --request POST \
     --url https://loanpro.simnang.com/api/public/api/1/odata.svc/LineOfCredits \
     --header 'Authorization: Bearer {token}' \
     --header 'Autopal-Instance-Id: {tenant ID}' \
     --header 'content-type: application/json' \
     --data '
{
    "productId": {loc-program-id},
    "Customers": {
        "results": [
            {
                "__id": {customer-id},
                "__setLoanRole": "loan.customerRole.primary"
            }
        ]
    }
}
'

A success response provides details regarding the line of credit account:

{
  "d": {
    "__metadata": {
      "uri": "http://loanpro.simnang.com/api/public/api/1/odata.svc/LineOfCredits(id=3)",
      "type": "Entity.LineOfCredit"
    },
    "id": 3,
    "displayId": 3,
    "title": 3,
    "productId": 1,
    "settingsId": 3,
    "setupId": 2,
    "linkedLineOfCredit": 0,
    "humanActivityDate": null,
    "created": "/Date(1666105451)/",
    "lastMaintRun": null,
    "createdBy": 13057,
    "active": 0,
    "archived": 0,
    "temporaryAccount": 0,
    "lineOfCreditAlert": "",
    "deleted": 0,
    "deletedAt": null,
    "LineOfCreditDocuments": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditDocuments"
      }
    },
    "LineOfCreditSettings": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditSettings"
      }
    },
    "LineOfCreditSetup": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditSetup"
      }
    },
    "Notes": {
      "__deferred": {
        "uri": "LineOfCredits(3)/Notes"
      }
    },
    "ChecklistItemValues": {
      "__deferred": {
        "uri": "LineOfCredits(3)/ChecklistItemValues"
      }
    },
    "Customers": {
      "results": [
        {
          "__metadata": {
            "uri": "http://loanpro.simnang.com/api/public/api/1/odata.svc/Customers(id=1183)",
            "type": "Entity.Customer"
          },
          "id": 2266,
          "customId": null,
          "mcId": 3874462,
          "customerType": "customer.type.individual",
          "status": "Active",
          "firstName": "John",
          "lastName": "Doe",
          "middleName": "",
          "birthDate": "/Date(0)/",
          "gender": "customer.gender.male",
          "generationCode": "customer.generationCode.iii",
          "email": "johndoe@email.com",
          "ssn": "000000000",
          "driverLicense": "",
          "companyName": "",
          "contactName": "",
          "customerIdType": "customer.idType.ssn",
          "customerId": "",
          "creditLimit": 0,
          "accessUserName": "johndoe@email.com",
          "active": 1,
          "ofacMatch": 0,
          "ofacTested": 0,
          "saleTransferPii": 1,
          "passwordChanged": 0,
          "hasAvatar": 0,
          "loanRole": "loan.customerRole.primary",
          "created": "/Date(1632417901)/",
          "lastUpdate": "/Date(1663174095)/",
          "creditScoreId": 213,
          "PrimaryAddress": {
            "__deferred": {
              "uri": "Customers(1183)/PrimaryAddress"
            }
          },
          "MailAddress": {
            "__deferred": {
              "uri": "Customers(1183)/MailAddress"
            }
          },
          "Employer": {
            "__deferred": {
              "uri": "Customers(1183)/Employer"
            }
          },
          "References": {
            "__deferred": {
              "uri": "Customers(1183)/References"
            }
          },
          "PaymentAccounts": {
            "__deferred": {
              "uri": "Customers(1183)/PaymentAccounts"
            }
          },
          "Phones": {
            "__deferred": {
              "uri": "Customers(1183)/Phones"
            }
          },
          "CustomFieldValues": {
            "__deferred": {
              "uri": "Customers(1183)/CustomFieldValues"
            }
          },
          "Documents": {
            "__deferred": {
              "uri": "Customers(1183)/Documents"
            }
          },
          "CreditScore": {
            "__deferred": {
              "uri": "Customers(1183)/CreditScore"
            }
          },
          "Loans": {
            "__deferred": {
              "uri": "Customers(1183)/Loans"
            }
          },
          "LineOfCredits": {
            "__deferred": {
              "uri": "Customers(1183)/LineOfCredits"
            }
          },
          "SocialProfiles": {
            "__deferred": {
              "uri": "Customers(1183)/SocialProfiles"
            }
          },
          "Notes": {
            "__deferred": {
              "uri": "Customers(1183)/Notes"
            }
          }
        }
      ]
    },
    "Portfolios": {
      "__deferred": {
        "uri": "LineOfCredits(3)/Portfolios"
      }
    },
    "SubPortfolios": {
      "__deferred": {
        "uri": "LineOfCredits(3)/SubPortfolios"
      }
    },
    "RuleApplied": {
      "__deferred": {
        "uri": "LineOfCredits(3)/RuleApplied"
      }
    },
    "ActionResultLineOfCreditNotes": {
      "__deferred": {
        "uri": "LineOfCredits(3)/ActionResultLineOfCreditNotes"
      }
    },
    "Autopays": {
      "__deferred": {
        "uri": "LineOfCredits(3)/Autopays"
      }
    },
    "LineOfCreditCreditLimitAdjustments": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditCreditLimitAdjustments"
      }
    },
    "LineOfCreditBucketTransferTransactions": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditBucketTransferTransactions"
      }
    },
    "LineOfCreditSwipes": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditSwipes"
      }
    },
    "LineOfCreditFinanceCharges": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditFinanceCharges"
      }
    },
    "LineOfCreditPayments": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditPayments"
      }
    },
    "LineOfCreditCharges": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditCharges"
      }
    },
    "LineOfCreditCreditTransactions": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditCreditTransactions"
      }
    },
    "LineOfCreditBillingCycles": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditBillingCycles"
      }
    },
    "LineOfCreditDailyArchives": {
      "__deferred": {
        "uri": "LineOfCredits(3)/LineOfCreditDailyArchives"
      }
    }
  }
}

View the API reference to learn more ↗

Capture the value stored within the "id" field. We'll reference this in future steps as {loc-id}.

3. Activate the line of credit account

Activating an account enables the LoanPro calculator. Once activated, LoanPro views the account as live and eligible for LoanPro's Daily Maintenance service that calculates, updates, and stores a daily snapshot of the account values.

Send the following request to activate the line of credit account. Note that the following variables from previous steps are used within the endpoint of this request:

curl --request PUT \
     --url 'https://loanpro.simnang.com/api/public/api/1/LineOfCredits({loc-id})/activate' \
     --header 'Authorization: Bearer {token}' \
     --header 'Autopal-Instance-Id: {tenant ID}' \
     --header 'accept: application/json'

A successful request returns the following response:

{  
  "d": {  
    "success": true  
  }  
}

4. Create a card

Lastly, create a card. This specific request creates a card in both LoanPro and Secure payments, and it automatically facilitates the transfer of information between the two systems.

Note that the following variables from previous steps are used within the payload of this request:

  1. {loc-id} : the ID of the line of credit account
  2. {customer-id} : the ID of the customer profile
  3. {card-program-id} : the ID of the card program
curl --request POST \
     --url https://loanpro.simnang.com/api/public/api/1/Cards/createCardForMe \
     --header 'Authorization: Bearer {token}' \
     --header 'Autopal-Instance-Id: {tenant ID}' \
     --header 'content-type: application/json' \
     --data '
{
  "cardName": "Sample Card Title",
  "entityType": "Entity.LineOfCredit",
  "entityId": {loc-id},
  "customerId": {customer-id},
  "programId": {card-program-id},
  "bucketId": 2
}
'

Card creation uses an asynchronous process. After this request is made, a sequence of actions is started in the background. This sequence is referred to and represented by a job_uuid, which is returned in the response of this request.

Some card information is not immediately returned within the initial response due to the asynchronous sequence. For example, you'll notice that there are several parameters with null values:

{
  "id": "85",
  "entityId": 3,
  "entityType": "Entity.LineOfCredit",
  "bucketId": 1,
  "customerId": 2266,
  "merchantCardId": null,
  "cardName": "Sample Card Title",
  "merchantCardToken": null,
  "cardJobId": "01HMFGZS303G1ZFZWEVSADPWY0",
  "programId": 1,
  "created": null,
  "lastUpdated": null,
  "status": null,
  "cardStatus": null,
  "availableBalance": null,
  "availableAdvanceBalance": null,
  "lastFourPan": null,
  "swipeRestrictions": [],
  "cardTextColor": null,
  "cardColor": null,
  "cardBackground": null,
  "processingType": null,
  "spendLimit": 5000,
  "spendLimitInterval": "monthly",
  "bin": null,
  "cardCurrency": "USD",
  "name": null,
  "cardTitle": null,
  "network": null,
  "cardType": "virtual",
  "issuerAccountName": null,
  "issuerProductId": null,
  "shippingMethod": null,
  "swipeExpirationExceptions": null,
  "authorizationExpirationDays": null,
  "billingAddress": {
    "address1": "2047 Omari Groves",
    "address2": null,
    "zipcode": "60602",
    "city": "Chicago",
    "state": "IL",
    "country": "USA"
  },
  "cardProgramId": null,
  "shippingAddress": null,
  "merchantCreateCardStatus": "createCardForMe.status.pending"
}

As the asynchronous process completes, this data is compiled and stored within the card's information. However, the "merchantCardToken" field value is needed when authorizing card transactions.

During the asynchronous process, a card is assigned a UUID—which is used when authorizing transactions. This UUID is important to store, as it's used to create cards in a future step. To view and store this ID, choose one of the following options:

  1. Following a 5 to 10-second delay, send a follow-up request to pull the UUID ↗ by referencing the resource_id parameter
  2. Use the following post-request script when creating a card to store the UUID automatically:
// Declare response as json object:
var jsonData = pm.response.json(); 

// Set job-id variable as collection-level variable:
pm.collectionVariables.set("job-uuid", jsonData.cardJobId);
pm.collectionVariables.set("lms-card-id", jsonData.id);


//Job Update request declaration:
const jobUpdateRequest = {
    url: pm.environment.get("SP URL V2") + '/job/' + pm.collectionVariables.get("job-uuid") + '/updates',
    method: 'GET',
    header: {
        'Authorization': pm.environment.get("SP Authorization"),
        'Secret': pm.environment.get("Secret")
    },
    body: {
        mode: 'raw',
        raw: JSON.stringify()
  }
};


//Send the Job Updates request and pull the correct resource ID:
pm.sendRequest(jobUpdateRequest, function (err, response) {

// Function that finds the correct resource and its success status:
function getResourceID(subStatus, resourceType) {
    let profile = response.json().updates.find(
        results =>
            results["sub_status"] === subStatus && 
            results["resource_type"] === resourceType);
    return profile["resource_id"];
        }

        if(err) {
            console.log(err);
        } 
        else if (response.json().name === "Create card endpoint") {
             pm.collectionVariables.set("card-uuid", getResourceID("succeeded", "card"));
             console.log(response);  
            }
        }
);

We recommend using the post-request script, and we've included it in this guide's complementary Postman collection. In future requests, we'll reference this ID as {card-uuid}.

View the API reference to learn more ↗