Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/main/java/com/beanstream/api/ProfilesAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,48 @@ public void setCard(Card card) {
this.card = card;
}

}
/**
* Add a new token to the profile. It gets appended to the end of the list of
* cards. Make sure your Merchant account can support more cards. The
* default amount is 1. You can change this limit in the online Members area
* for Merchants located at: https://www.beanstream.com/admin/sDefault.asp
* and heading to Configuration : Payment Profile Configuration
*
* @param profileId The profile id.
* @param token The token to add.
* @return ProfileResponse
* @throws BeanstreamApiException when not successful
*/
public ProfileResponse addToken(String profileId, Token token)
throws BeanstreamApiException {
ProfilesUtils.validateProfileId(profileId);
String url = PaymentsUrls.getProfileCardsUrl(config.getPlatform(),
config.getVersion(), profileId);

ProfilesUtils.validateToken(token);

TokenWrapper tw = new TokenWrapper(token);
String response = connector.ProcessTransaction(HttpMethod.post, url, tw);
return gson.fromJson(response, ProfileResponse.class);

}

private class TokenWrapper {
private Token token;

private TokenWrapper(Card token) {
this.token = token;
}

public Token getToken() {
return token;
}

public void setToken(Card token) {
this.token = token;
}

}
/**
* Removes the card from the profile. Card IDs are their index in
Expand Down