POST | /sales/contract/sold | Sell a package to an existing user | Sell a package to an existing user. The PaymentMethods property is an array of objects describing how you want ClubReady to take payment while selling the PackageId/InstallmentPlanId. If omitted (or null), the preferred on-file profile will be used. |
---|
import java.math.*;
import java.util.*;
import net.servicestack.client.*;
public class dtos
{
@ApiResponse(Description="", ResponseType=SellContractResultDto.class, StatusCode=200)
public static class SellContractRequest extends SellContractRequestDto implements IRestrictedApiRequest
{
/**
* Api Authentication Key
*/
@ApiMember(Description="Api Authentication Key", IsRequired=true, ParameterType="query")
public String ApiKey = null;
/**
* Member Id of the user buying the Package
*/
@ApiMember(Description="Member Id of the user buying the Package", IsRequired=true, ParameterType="query")
public Integer MemberId = null;
/**
* Id for the chain of the Api Key
*/
@ApiMember(Description="Id for the chain of the Api Key")
public Integer ChainId = null;
/**
* Id of the store for the user
*/
@ApiMember(Description="Id of the store for the user", IsRequired=true)
public Integer StoreId = null;
/**
* Package Id number of the package being purchased
*/
@ApiMember(Description="Package Id number of the package being purchased", IsRequired=true)
public Integer PackageId = null;
/**
* Installment Plan Id being purchased. If empty, the default package will be selected.
*/
@ApiMember(Description="Installment Plan Id being purchased. If empty, the default package will be selected.")
public Integer InstallmentId = null;
/**
* Amount being paid down, including tax
*/
@ApiMember(Description="Amount being paid down, including tax", IsRequired=true)
public BigDecimal PaymentAmount = null;
/**
* Promo code to apply a discount.
*/
@ApiMember(Description="Promo code to apply a discount.")
public String PromoCode = null;
/**
* Staff Id of salesperson who sold the agreement.
*/
@ApiMember(Description="Staff Id of salesperson who sold the agreement.")
public Integer StaffId = null;
/**
* An array of Payment Methods to be used for this purchase. Any entry with PreferredOnFile is assumed if omitted or null. Each object of the array may contain properties:| Property | Description || --- | --- || PaymentMethodType | Usually "AcctToken" (Default or omitted/null) or "PreferredOnFile" || PaymentAmount | The amount to be attempted for this Payment Method. When omitted (or null), the Request's PaymentAmount will be attempted || AcctToken | The AcctToken to attempt payment (when using PaymentMethodType:AcctToken) || ProfileToken | When provided (with AcctToken), a Payment Profile will be created (this will prevent the requirement to call `/sales/paymentprofile/import` (when using PaymentMethodType:AcctToken) || DoNotUpdatePaymentTypePreference | When using ProfileToken, do not set the PaymentTypePreference (for more information, see `/sales/paymentprofile/import` (when using PaymentMethodType:AcctToken) || | |* Scenario #1: Use the on file profile only. PaymentMethods can be omitted/null, or : JSON:```json{ PaymentMethods: [ { "PaymentMethodType":"PreferredOnFile", "PaymentAmount":"1.00" } ]}```JSV:```jsv[{PaymentMethodType:PreferredOnFile,PaymentAmount:1.00}]```* Scenario #2: Use a Gift Card with PreferredOnFile to cover the amount not approved by the Gift Card. JSON:```json{ PaymentMethods: [ { "PaymentMethodType":"AcctToken", "PaymentAmount":"1.00", "AcctToken":"eyJ...GiftCard AcctToken...", "ProfileToken":"eyJ...Gift Card ProfileToken..." }, { "PaymentMethodType":"PreferredOnFile", "PaymentAmount":"1.00" } ]}```JSV:```jsv[{PaymentMethodType:AcctToken,PaymentAmount:1.00,AcctToken:eyj...,ProfileToken:eyJ...},{PaymentMethodType:PreferredOnFile,PaymentAmount:1.00}]``` Notes: * The example shows PaymentAmount of 1.00 for both "AcctToken" and "PreferredOnFile". This is for the examplewith a total of $1.00. The firstPaymentMethod (the Gift Card) will be attempted for $1.00. If it partially approvesfor less than 1.00 (example: $0.80), the second payment method (PreferredOnFile) will be attempted for the lesser ofit's PaymentAmount and the remaining amount (example: $0.20).* If ProfileToken has already been used (e.g. used with `/sales/paymentprofile/import`), it does not need to be included,but AcctToken is required. ProfileToken is only needed once to 'activate' the AcctToken.* When using Query String (or this web site), this value must be encoded with JSV [(JSON-like Separated Values)](https://docs.servicestack.net/jsv-format).Basic steps to convert JSON to JSV: 1) Remove properties that are null, 2) Remove white space including line feeds, 3) Remove quotes.
*/
@ApiMember(Description="\r\nAn array of Payment Methods to be used for this purchase. Any entry with PreferredOnFile is assumed if omitted or null. \r\n\r\nEach object of the array may contain properties:\r\n\r\n| Property | Description |\r\n| --- | --- |\r\n| PaymentMethodType | Usually \"AcctToken\" (Default or omitted/null) or \"PreferredOnFile\" |\r\n| PaymentAmount | The amount to be attempted for this Payment Method. When omitted (or null), the Request's PaymentAmount will be attempted |\r\n| AcctToken | The AcctToken to attempt payment (when using PaymentMethodType:AcctToken) |\r\n| ProfileToken | When provided (with AcctToken), a Payment Profile will be created (this will prevent the requirement to call `/sales/paymentprofile/import` (when using PaymentMethodType:AcctToken) |\r\n| DoNotUpdatePaymentTypePreference | When using ProfileToken, do not set the PaymentTypePreference (for more information, see `/sales/paymentprofile/import` (when using PaymentMethodType:AcctToken) |\r\n| | |\r\n\r\n* Scenario #1: Use the on file profile only. PaymentMethods can be omitted/null, or : \r\n\r\nJSON:\r\n```json\r\n{\r\n PaymentMethods: [\r\n {\r\n \"PaymentMethodType\":\"PreferredOnFile\",\r\n \"PaymentAmount\":\"1.00\"\r\n }\r\n ]\r\n}\r\n```\r\nJSV:\r\n```jsv\r\n[{PaymentMethodType:PreferredOnFile,PaymentAmount:1.00}]\r\n```\r\n\r\n\r\n* Scenario #2: Use a Gift Card with PreferredOnFile to cover the amount not approved by the Gift Card. \r\n\r\nJSON:\r\n```json\r\n{\r\n PaymentMethods: [\r\n {\r\n \"PaymentMethodType\":\"AcctToken\",\r\n \"PaymentAmount\":\"1.00\",\r\n \"AcctToken\":\"eyJ...GiftCard AcctToken...\",\r\n \"ProfileToken\":\"eyJ...Gift Card ProfileToken...\"\r\n },\r\n {\r\n \"PaymentMethodType\":\"PreferredOnFile\",\r\n \"PaymentAmount\":\"1.00\"\r\n }\r\n ]\r\n}\r\n```\r\nJSV:\r\n```jsv\r\n[{PaymentMethodType:AcctToken,PaymentAmount:1.00,AcctToken:eyj...,ProfileToken:eyJ...},{PaymentMethodType:PreferredOnFile,PaymentAmount:1.00}]\r\n``` \r\n\r\nNotes: \r\n\r\n* The example shows PaymentAmount of 1.00 for both \"AcctToken\" and \"PreferredOnFile\". This is for the example\r\nwith a total of $1.00. The firstPaymentMethod (the Gift Card) will be attempted for $1.00. If it partially approves\r\nfor less than 1.00 (example: $0.80), the second payment method (PreferredOnFile) will be attempted for the lesser of\r\nit's PaymentAmount and the remaining amount (example: $0.20).\r\n\r\n* If ProfileToken has already been used (e.g. used with `/sales/paymentprofile/import`), it does not need to be included,\r\nbut AcctToken is required. ProfileToken is only needed once to 'activate' the AcctToken.\r\n\r\n* When using Query String (or this web site), this value must be encoded with JSV [(JSON-like Separated Values)](https://docs.servicestack.net/jsv-format).\r\nBasic steps to convert JSON to JSV: 1) Remove properties that are null, 2) Remove white space including line feeds, 3) Remove quotes.\r\n")
public ArrayList<PaymentMethodDto> PaymentMethods = null;
public Integer RestrictedId = null;
public RestrictedResourceType RestrictedResourceType = null;
public String getApiKey() { return ApiKey; }
public SellContractRequest setApiKey(String value) { this.ApiKey = value; return this; }
public Integer getMemberId() { return MemberId; }
public SellContractRequest setMemberId(Integer value) { this.MemberId = value; return this; }
public Integer getChainId() { return ChainId; }
public SellContractRequest setChainId(Integer value) { this.ChainId = value; return this; }
public Integer getStoreId() { return StoreId; }
public SellContractRequest setStoreId(Integer value) { this.StoreId = value; return this; }
public Integer getPackageId() { return PackageId; }
public SellContractRequest setPackageId(Integer value) { this.PackageId = value; return this; }
public Integer getInstallmentId() { return InstallmentId; }
public SellContractRequest setInstallmentId(Integer value) { this.InstallmentId = value; return this; }
public BigDecimal getPaymentAmount() { return PaymentAmount; }
public SellContractRequest setPaymentAmount(BigDecimal value) { this.PaymentAmount = value; return this; }
public String getPromoCode() { return PromoCode; }
public SellContractRequest setPromoCode(String value) { this.PromoCode = value; return this; }
public Integer getStaffId() { return StaffId; }
public SellContractRequest setStaffId(Integer value) { this.StaffId = value; return this; }
public ArrayList<PaymentMethodDto> getPaymentMethods() { return PaymentMethods; }
public SellContractRequest setPaymentMethods(ArrayList<PaymentMethodDto> value) { this.PaymentMethods = value; return this; }
public Integer getRestrictedId() { return RestrictedId; }
public SellContractRequest setRestrictedId(Integer value) { this.RestrictedId = value; return this; }
public RestrictedResourceType getRestrictedResourceType() { return RestrictedResourceType; }
public SellContractRequest setRestrictedResourceType(RestrictedResourceType value) { this.RestrictedResourceType = value; return this; }
}
public static class SellContractRequestDto extends ApiDtoBase
{
public Integer MemberId = null;
public Integer PackageId = null;
public Integer InstallmentId = null;
public Date StartDate = null;
public BigDecimal PaymentAmount = null;
public String PromoCode = null;
public ArrayList<PaymentMethodDto> PaymentMethods = null;
public Integer StaffId = null;
public Integer getMemberId() { return MemberId; }
public SellContractRequestDto setMemberId(Integer value) { this.MemberId = value; return this; }
public Integer getPackageId() { return PackageId; }
public SellContractRequestDto setPackageId(Integer value) { this.PackageId = value; return this; }
public Integer getInstallmentId() { return InstallmentId; }
public SellContractRequestDto setInstallmentId(Integer value) { this.InstallmentId = value; return this; }
public Date getStartDate() { return StartDate; }
public SellContractRequestDto setStartDate(Date value) { this.StartDate = value; return this; }
public BigDecimal getPaymentAmount() { return PaymentAmount; }
public SellContractRequestDto setPaymentAmount(BigDecimal value) { this.PaymentAmount = value; return this; }
public String getPromoCode() { return PromoCode; }
public SellContractRequestDto setPromoCode(String value) { this.PromoCode = value; return this; }
public ArrayList<PaymentMethodDto> getPaymentMethods() { return PaymentMethods; }
public SellContractRequestDto setPaymentMethods(ArrayList<PaymentMethodDto> value) { this.PaymentMethods = value; return this; }
public Integer getStaffId() { return StaffId; }
public SellContractRequestDto setStaffId(Integer value) { this.StaffId = value; return this; }
}
public static class ApiDtoBase
{
public String ApiKey = null;
public Integer StoreId = null;
public Integer ChainId = null;
public String getApiKey() { return ApiKey; }
public ApiDtoBase setApiKey(String value) { this.ApiKey = value; return this; }
public Integer getStoreId() { return StoreId; }
public ApiDtoBase setStoreId(Integer value) { this.StoreId = value; return this; }
public Integer getChainId() { return ChainId; }
public ApiDtoBase setChainId(Integer value) { this.ChainId = value; return this; }
}
@DataContract
public static class PaymentMethodDto
{
@DataMember
public String AcctToken = null;
@DataMember
public String ProfileToken = null;
@DataMember
public String PaymentProfileId = null;
@DataMember
public BigDecimal PaymentAmount = null;
@DataMember
public PaymentMethodType PaymentMethodType = null;
@DataMember
public Boolean DoNotUpdatePaymentTypePreference = null;
public String getAcctToken() { return AcctToken; }
public PaymentMethodDto setAcctToken(String value) { this.AcctToken = value; return this; }
public String getProfileToken() { return ProfileToken; }
public PaymentMethodDto setProfileToken(String value) { this.ProfileToken = value; return this; }
public String getPaymentProfileId() { return PaymentProfileId; }
public PaymentMethodDto setPaymentProfileId(String value) { this.PaymentProfileId = value; return this; }
public BigDecimal getPaymentAmount() { return PaymentAmount; }
public PaymentMethodDto setPaymentAmount(BigDecimal value) { this.PaymentAmount = value; return this; }
public PaymentMethodType getPaymentMethodType() { return PaymentMethodType; }
public PaymentMethodDto setPaymentMethodType(PaymentMethodType value) { this.PaymentMethodType = value; return this; }
public Boolean isDoNotUpdatePaymentTypePreference() { return DoNotUpdatePaymentTypePreference; }
public PaymentMethodDto setDoNotUpdatePaymentTypePreference(Boolean value) { this.DoNotUpdatePaymentTypePreference = value; return this; }
}
public static enum PaymentMethodType
{
Uninitialized(0),
PaymentProfileId(1),
PreferredOnFile(2),
AcctToken(3),
Error(-1);
private final int value;
PaymentMethodType(final int intValue) { value = intValue; }
public int getValue() { return value; }
}
public static enum RestrictedResourceType
{
Store,
Chain,
User,
Undefined;
}
public static class SellContractResultDto
{
public String ContractSaleID = null;
public String description = null;
public Boolean Success = null;
public IReadOnlyList<PendingPaymentResponse> PaymentResponses = null;
public String getContractSaleID() { return ContractSaleID; }
public SellContractResultDto setContractSaleID(String value) { this.ContractSaleID = value; return this; }
public String getDescription() { return description; }
public SellContractResultDto setDescription(String value) { this.description = value; return this; }
public Boolean isSuccess() { return Success; }
public SellContractResultDto setSuccess(Boolean value) { this.Success = value; return this; }
public IReadOnlyList<PendingPaymentResponse> getPaymentResponses() { return PaymentResponses; }
public SellContractResultDto setPaymentResponses(IReadOnlyList<PendingPaymentResponse> value) { this.PaymentResponses = value; return this; }
}
public static class PendingPaymentResponse
{
public String ResponseTransactionId = null;
public String ResponseTxnId = null;
public ResponseStatus ResponseStatus = null;
public BigDecimal ResponseAmount = null;
public String ResponseText = null;
public String Last4 = null;
public String AcctClass = null;
public String AcctType = null;
public String AcctToken = null;
public String getResponseTransactionId() { return ResponseTransactionId; }
public PendingPaymentResponse setResponseTransactionId(String value) { this.ResponseTransactionId = value; return this; }
public String getResponseTxnId() { return ResponseTxnId; }
public PendingPaymentResponse setResponseTxnId(String value) { this.ResponseTxnId = value; return this; }
public ResponseStatus getResponseStatus() { return ResponseStatus; }
public PendingPaymentResponse setResponseStatus(ResponseStatus value) { this.ResponseStatus = value; return this; }
public BigDecimal getResponseAmount() { return ResponseAmount; }
public PendingPaymentResponse setResponseAmount(BigDecimal value) { this.ResponseAmount = value; return this; }
public String getResponseText() { return ResponseText; }
public PendingPaymentResponse setResponseText(String value) { this.ResponseText = value; return this; }
public String getLast4() { return Last4; }
public PendingPaymentResponse setLast4(String value) { this.Last4 = value; return this; }
public String getAcctClass() { return AcctClass; }
public PendingPaymentResponse setAcctClass(String value) { this.AcctClass = value; return this; }
public String getAcctType() { return AcctType; }
public PendingPaymentResponse setAcctType(String value) { this.AcctType = value; return this; }
public String getAcctToken() { return AcctToken; }
public PendingPaymentResponse setAcctToken(String value) { this.AcctToken = value; return this; }
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /sales/contract/sold HTTP/1.1
Host: clubready.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<SellContractRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Web.Api.Sales.Model">
<ApiKey xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">String</ApiKey>
<ChainId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</ChainId>
<StoreId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</StoreId>
<InstallmentId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</InstallmentId>
<MemberId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</MemberId>
<PackageId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</PackageId>
<PaymentAmount xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</PaymentAmount>
<PaymentMethods xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">
<PaymentMethodDto>
<AcctToken>String</AcctToken>
<DoNotUpdatePaymentTypePreference>false</DoNotUpdatePaymentTypePreference>
<PaymentAmount>0</PaymentAmount>
<PaymentMethodType>Uninitialized</PaymentMethodType>
<PaymentProfileId>String</PaymentProfileId>
<ProfileToken>String</ProfileToken>
</PaymentMethodDto>
</PaymentMethods>
<PromoCode xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">String</PromoCode>
<StaffId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0</StaffId>
<StartDate xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models">0001-01-01T00:00:00</StartDate>
</SellContractRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <SellContractResultDto xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Core.Api.Models"> <ContractSaleID>String</ContractSaleID> <PaymentResponses i:nil="true" /> <Success>false</Success> <description>String</description> </SellContractResultDto>