The Credit Application process enables users to secure auto loans, providing them with information on loan amounts and interest rates. This guide covers various scenarios, including applications for primary applicants and co-applicants, with or without trade-ins.
Now, we can export the sdk to use in our application
3
Make a function to CREATE the Credit Application.
credit.action.ts
'use server'// Next JS specific for server actionsimport{CreditApplication}from'@drivly/commerce'import{ sdk }from'./sdk'type CreditData=Omit<CreditApplication,'id'|'createdAt'|'updatedAt'>exportconstcreateCreditApp=async(data:CreditData)=>{try{// Change to 'Production' for live applicationsconst environment ='Development'const result =await sdk?.commerce.creditApplications.create({doc:{ environment,...data },})console.log(result)}catch(error){console.error(error)}}
4
We might need to CREATE a Trade, we will need a few more functions.
In cases where a trade-in is involved, we need to create a trade record for the vehicle being traded.
We can use https://commerce.driv.ly/api/creditApplications to create and manage Credit Applications.
1
Create an environment variable for your API Key.
.env
DRIVLY_API_KEY='YOUR_API_KEY'
2
Make a function to CREATE the Credit Application.
credit.action.ts
import{CreditApplication}from'@drivly/commerce'type CreditData=Omit<CreditApplication,'id'|'createdAt'|'updatedAt'>const url ='https://commerce.driv.ly/api/creditApplications'exportconstcreateCreditApp=async(data:CreditData)=>{try{// Change to 'Production' for live applicationsconst environment ='Development'const response =awaitfetch(url,{method:'POST',headers:{'Content-Type':'application/json',Authorization:`${process.env.DRIVLY_API_KEY}`,},body:JSON.stringify({ environment,...data }),}).then((res)=> res.json())console.log(response)}catch(error){console.error(error)}}
3
We might need to CREATE a Trade, we will need a few more functions.
In cases where a trade-in is involved, we need to create a trade record for the vehicle being traded.
Danny found the car of his dreams. He wants to secure a loan to buy the car. He goes to your
website and fills out a form to find out how much of a loan he can secure.
When a user, such as Danny, wishes to secure a loan for his dream car, follow these steps:
1
Direct the user to the Credit Application Form on your Website.
Make sure the form includes fields for the primary applicant’s personal, residence, employment, and vehicle information.
Also include fields for the application type, finance amount, pre-approval ID and has
co-applicant.
primaryApplicant
Applicant Object
firstName
string
lastName
string
birthDate
string
emailAddress
string
cellPhone
string
ssn
string
relationshipType
enum<string> | null
Available options: SPOUSE, RELATIVE, FRIEND, or null (for primary applicant)
currentResidence | previousResidence
Residence Object
If current monthsAtResidence < 24, previousResidence is REQUIRED
monthlyPaymentAmount
number
monthsAtResidence
number
ownershipStatus
enum<string>
Available options: RENT, OWN, RELATIVE_OWNED
address
Address Object
lineOne
string
lineTwo
string
city
string
state
enum<string>
Available options: AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI,
ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO,
MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI,
SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY
postalCode
string
currentEmployment | previousEmployment
Employment Object
If currentEmployment monthsAtEmployer < 24, previousEmployment is REQUIRED
yearlyIncomeAmount
number
monthsAtEmployer
number
employmentType
enum<string>
Available options: FULL_TIME, PART_TIME, SELF_EMPLOYED, UNEMPLOYED, RETIRED
employerName
string
employmentPosition
string
employmentAddress
Address Object
lineOne
string
lineTwo
string
city
string
state
enum<string>
Available options: AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI,
ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO,
MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI,
SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY
postalCode
string
additionalIncomeAmount
number | null
additionalIncomeFrequency
enum<string> | null
Available options: WEEKLY, BI_WEEKLY, TWICE_MONTHLY, MONTHLY, YEARLY
additionalIncomeSource
string | null
terms
Terms Object
agreeToTerms
boolean
agreeIP
string
agreeUserAgent
string
vehicle
Vehicle Object
vin
string
year
number
make
string
model
string
trim
string
mileage
number
lien
Lien Object
lienHolder
string | null
monthlyPaymentAmount
number | null
payoffAmount
number | null
initialTerm
number | null
remainingTerm
number | null
originalAmount
number | null
apr
number | null
applicationType
enum<string>
Available options: PURCHASE, REFINANCE, LEASE_BUYOUT
hasCoApplicant
boolean
financeAmount
number
preApproval
string
2
Format your Request Body
Before sending the request, we need to include the following fields in the request body:
sendTo: The recipient of the application. Available options: RouteOne, TSG
state: Set to DRAFT in order to create a new application for processing.
environment: The application can be submitted in Production or Development
Danny’s wife Michelle found a car she loves. They want to secure a loan to buy the car. They go to
your website and fill out a form to find out how much of a loan they can secure.
When both Danny and Michelle want to secure a loan for a car they love, their journey through your website will be slightly different to account for the additional information needed from the co-applicant. Here’s how to guide them:
1
Direct Both Applicants to the Credit Application Form.
Ensure your form is set up to handle input from both the primary applicant and the co-applicant. It’s crucial to clearly label which sections pertain to each applicant to avoid confusion.
Include identical fields for both the primary applicant and the co-applicant.
2
Collect and Format Data for Both Applicants.
While collecting the data, remember to gather information from both Danny and Michelle, treating Michelle’s data as the coApplicant’s or vice-versa. The data structure for the coApplicant will mirror that of the primaryApplicant.
For the relationshipType in the coApplicant’s data, select the appropriate option that describes
their relationship to the primary applicant.
Format Data
const creditData ={sendTo:'RouteOne',state:'DRAFT',environment:'Production',// Previous fields for primaryApplicantcoApplicant:{// Repeat the fields from primaryApplicant,// filling in Michelle's information},hasCoApplicant:true,// Other necessary fields (vehicle, applicationType, etc.)}
3
Send the Request.
Now that we have the data formatted, we can send the request to create the Credit Application.
Danny is looking to trade-in his 2011 Lincoln Town Car for a 2023 Genesis G80. He wants to secure
a loan to buy the car and trade-in his old car. He goes to your website and fills out a form to
find out how much of a loan he can secure.
In cases where Danny is looking to trade in his current vehicle as part of securing a new loan, the process involves an additional step to include trade-in information.
1
Guide Danny to the Enhanced Credit Application Form.
Adjust your form to include a section for vehicle trade-in details.
tradeInVehicle
Trade-In Object
vin
string
year
string
make
string
model
string
trim
string
odometer
number
payoff
string
lienholder
string
Ensure the form includes fields for the primary applicant’s personal, residence, employment, and vehicle information.
2
Collect Information Including Trade-In Details.
Apart from collecting the standard application information, you’ll need to gather details about the vehicle Danny intends to trade.
tradeInData
const tradeInDetails ={make:'Lincoln',model:'Town Car',year:'2011',payoff:'7000',// Additional fields as necessary}
3
Create a Trade.
Before sending the Credit Application, you’ll need to create a trade-in record for Danny’s vehicle.
Danny and Michelle are looking to trade-in their 2011 Lincoln Town Car for a 2023 Genesis G80.
They want to secure a loan to buy the car and trade-in their old car. They go to your website and
fill out a form to find out how much of a loan they can secure.
For scenarios involving both a primary and a co-applicant intending to trade in a vehicle, combine the steps and considerations from the previous scenarios.
1
Guide Both Applicants to the Enhanced Credit Application Form.
Ensure your form includes sections for both applicants and trade-in details. Ensure clarity and ease of navigation within the form.
2
Collect Information Including Trade-In Details.
Gather information from both Danny and Michelle, including details about the vehicle they intend to trade.
3
Create a Trade.
Before sending the Credit Application, create a trade-in record for the vehicle Danny and Michelle intend to trade.
Congratulations! You’ve successfully integrated Credit Applications into your platform.
By following this guide, you’ve learned how to handle various scenarios, including primary applicants, co-applicants, and trade-ins. You’re now equipped to provide a seamless experience for users looking to secure auto loans.
If you have any questions or need further assistance, please don’t hesitate to reach out to our support team. Happy coding!