Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Account payment profile API handlers

Manage user payment profiles (saved credit cards/payment methods).

GET Account Payment Profile Collection

HTTP Verb – GET

URL – /api/v1/accounts/current/paymentprofiles

Description – Get a collection of payment profiles for the current user

Base – HandlerBase<GetAccountPaymentProfileCollectionParameter, GetAccountPaymentProfileCollectionResult>

Handlers

OrderHandlerDescription
500GetPaymentProfilesQueryCreates the base query for UserPaymentProfile entities filtered by the current user's UserProfileId.
600ApplyExpandsIf parameter GetCustomProperties is true, includes CustomProperties in the query via eager loading.
700ApplyFilteringIf parameter AccountPaymentProfileId is specified, filters query by that Id. If parameter Query is specified, filters by Description containing that text.
800ApplySortIf parameter Sort is blank, sorts by IsDefault descending, then by Description, CardType, and MaskedCardNumber. If Sort is specified, validates the sort property exists on UserPaymentProfile and applies dynamic ordering. Returns error if sort property is invalid.
900ApplyPagingApplies standard paging to the query using the base ApplyPaging method.
1000ExecuteQueryExecutes the query by calling ToList() and sets the result to UserPaymentProfiles.
1100CreateGetAccountPaymentProfileResultsCreates a GetAccountPaymentProfileResult for each UserPaymentProfile in the collection. If GetCustomProperties is true, copies custom properties to each result.

GET Account Payment Profile

HTTP Verb – GET

URL – /api/v1/accounts/current/paymentprofiles/{AccountPaymentProfileId}

Description – Get a single payment profile by Id

Base – HandlerBase<GetAccountPaymentProfileParameter, GetAccountPaymentProfileResult>

Handlers

OrderHandlerDescription
500GetPaymentProfileCalls GetAccountPaymentProfileCollection with the specified AccountPaymentProfileId. If the collection result fails, returns an error. If no results are found, returns a NotFound error. Otherwise returns the first result.

POST Account Payment Profile

HTTP Verb – POST

URL – /api/v1/accounts/current/paymentprofiles

Description – Add a new payment profile for the current user

Base – HandlerBase<AddAccountPaymentProfileParameter, AddAccountPaymentProfileResult>

Handlers

OrderHandlerDescription
500AddPaymentProfileCreates a new UserPaymentProfile entity from the parameter values (Description, ExpirationDate, CardType, CardHolderName, CardIdentifier, MaskedCardNumber, Address fields, IsDefault, TokenScheme). Integrates with payment gateways (Square, Spreedly, Paymetric) to store payment profiles when applicable. Validates that a duplicate card does not already exist for the user. If IsDefault is true, sets all other user payment profiles to not default. Inserts the entity and saves.

PATCH Account Payment Profile

HTTP Verb – PATCH

URL – /api/v1/accounts/current/paymentprofiles/{AccountPaymentProfileId}

Description – Update an existing payment profile

Base – HandlerBase<UpdateAccountPaymentProfileParameter, UpdateAccountPaymentProfileResult>

Handlers

OrderHandlerDescription
500GetPaymentProfileRetrieves the existing payment profile by calling GetAccountPaymentProfile with the specified AccountPaymentProfileId. Returns error if not found.
600UpdatePaymentProfileUpdates the UserPaymentProfile fields (Description, ExpirationDate, CardHolderName, Address fields, IsDefault) with parameter values where provided. If IsDefault is set to true, sets all other user payment profiles to not default. Saves changes.

DELETE Account Payment Profile

HTTP Verb – DELETE

URL – /api/v1/accounts/current/paymentprofiles/{AccountPaymentProfileId}

Description – Remove a payment profile

Base – HandlerBase<RemoveAccountPaymentProfileParameter, RemoveAccountPaymentProfileResult>

Handlers

OrderHandlerDescription
500GetPaymentProfileRetrieves the existing payment profile by calling GetAccountPaymentProfile with the specified AccountPaymentProfileId. Returns error if not found.
600RemovePaymentProfileDeletes the UserPaymentProfile entity from the repository and saves changes.