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 'package:servicestack/servicestack.dart';
class ApiDtoBase implements IConvertible
{
String? ApiKey;
int? StoreId;
int? ChainId;
ApiDtoBase({this.ApiKey,this.StoreId,this.ChainId});
ApiDtoBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
ApiKey = json['ApiKey'];
StoreId = json['StoreId'];
ChainId = json['ChainId'];
return this;
}
Map<String, dynamic> toJson() => {
'ApiKey': ApiKey,
'StoreId': StoreId,
'ChainId': ChainId
};
getTypeName() => "ApiDtoBase";
TypeContext? context = _ctx;
}
enum PaymentMethodType
{
Uninitialized,
PaymentProfileId,
PreferredOnFile,
AcctToken,
Error,
}
// @DataContract
class PaymentMethodDto implements IConvertible
{
// @DataMember
String? AcctToken;
// @DataMember
String? ProfileToken;
// @DataMember
String? PaymentProfileId;
// @DataMember
double? PaymentAmount;
// @DataMember
PaymentMethodType? PaymentMethodType;
// @DataMember
bool? DoNotUpdatePaymentTypePreference;
PaymentMethodDto({this.AcctToken,this.ProfileToken,this.PaymentProfileId,this.PaymentAmount,this.PaymentMethodType,this.DoNotUpdatePaymentTypePreference});
PaymentMethodDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
AcctToken = json['AcctToken'];
ProfileToken = json['ProfileToken'];
PaymentProfileId = json['PaymentProfileId'];
PaymentAmount = JsonConverters.toDouble(json['PaymentAmount']);
PaymentMethodType = JsonConverters.fromJson(json['PaymentMethodType'],'PaymentMethodType',context!);
DoNotUpdatePaymentTypePreference = json['DoNotUpdatePaymentTypePreference'];
return this;
}
Map<String, dynamic> toJson() => {
'AcctToken': AcctToken,
'ProfileToken': ProfileToken,
'PaymentProfileId': PaymentProfileId,
'PaymentAmount': PaymentAmount,
'PaymentMethodType': JsonConverters.toJson(PaymentMethodType,'PaymentMethodType',context!),
'DoNotUpdatePaymentTypePreference': DoNotUpdatePaymentTypePreference
};
getTypeName() => "PaymentMethodDto";
TypeContext? context = _ctx;
}
class SellContractRequestDto extends ApiDtoBase implements IConvertible
{
int? MemberId;
int? PackageId;
int? InstallmentId;
DateTime? StartDate;
double? PaymentAmount;
String? PromoCode;
List<PaymentMethodDto>? PaymentMethods;
int? StaffId;
SellContractRequestDto({this.MemberId,this.PackageId,this.InstallmentId,this.StartDate,this.PaymentAmount,this.PromoCode,this.PaymentMethods,this.StaffId});
SellContractRequestDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
MemberId = json['MemberId'];
PackageId = json['PackageId'];
InstallmentId = json['InstallmentId'];
StartDate = JsonConverters.fromJson(json['StartDate'],'DateTime',context!);
PaymentAmount = JsonConverters.toDouble(json['PaymentAmount']);
PromoCode = json['PromoCode'];
PaymentMethods = JsonConverters.fromJson(json['PaymentMethods'],'List<PaymentMethodDto>',context!);
StaffId = json['StaffId'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'MemberId': MemberId,
'PackageId': PackageId,
'InstallmentId': InstallmentId,
'StartDate': JsonConverters.toJson(StartDate,'DateTime',context!),
'PaymentAmount': PaymentAmount,
'PromoCode': PromoCode,
'PaymentMethods': JsonConverters.toJson(PaymentMethods,'List<PaymentMethodDto>',context!),
'StaffId': StaffId
});
getTypeName() => "SellContractRequestDto";
TypeContext? context = _ctx;
}
enum RestrictedResourceType
{
Store,
Chain,
User,
Undefined,
}
// @ApiResponse(Description="", ResponseType=typeof(SellContractResultDto), StatusCode=200)
class SellContractRequest extends SellContractRequestDto implements IRestrictedApiRequest, IConvertible
{
/**
* Api Authentication Key
*/
// @ApiMember(Description="Api Authentication Key", IsRequired=true, ParameterType="query")
String? ApiKey;
/**
* Member Id of the user buying the Package
*/
// @ApiMember(Description="Member Id of the user buying the Package", IsRequired=true, ParameterType="query")
int? MemberId;
/**
* Id for the chain of the Api Key
*/
// @ApiMember(Description="Id for the chain of the Api Key")
int? ChainId;
/**
* Id of the store for the user
*/
// @ApiMember(Description="Id of the store for the user", IsRequired=true)
int? StoreId;
/**
* Package Id number of the package being purchased
*/
// @ApiMember(Description="Package Id number of the package being purchased", IsRequired=true)
int? PackageId;
/**
* 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.")
int? InstallmentId;
/**
* Amount being paid down, including tax
*/
// @ApiMember(Description="Amount being paid down, including tax", IsRequired=true)
double? PaymentAmount;
/**
* Promo code to apply a discount.
*/
// @ApiMember(Description="Promo code to apply a discount.")
String? PromoCode;
/**
* Staff Id of salesperson who sold the agreement.
*/
// @ApiMember(Description="Staff Id of salesperson who sold the agreement.")
int? StaffId;
/**
* 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")
List<PaymentMethodDto>? PaymentMethods;
int? RestrictedId;
RestrictedResourceType? RestrictedResourceType;
SellContractRequest({this.ApiKey,this.MemberId,this.ChainId,this.StoreId,this.PackageId,this.InstallmentId,this.PaymentAmount,this.PromoCode,this.StaffId,this.PaymentMethods,this.RestrictedId,this.RestrictedResourceType});
SellContractRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
ApiKey = json['ApiKey'];
MemberId = json['MemberId'];
ChainId = json['ChainId'];
StoreId = json['StoreId'];
PackageId = json['PackageId'];
InstallmentId = json['InstallmentId'];
PaymentAmount = JsonConverters.toDouble(json['PaymentAmount']);
PromoCode = json['PromoCode'];
StaffId = json['StaffId'];
PaymentMethods = JsonConverters.fromJson(json['PaymentMethods'],'List<PaymentMethodDto>',context!);
RestrictedId = json['RestrictedId'];
RestrictedResourceType = JsonConverters.fromJson(json['RestrictedResourceType'],'RestrictedResourceType',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'ApiKey': ApiKey,
'MemberId': MemberId,
'ChainId': ChainId,
'StoreId': StoreId,
'PackageId': PackageId,
'InstallmentId': InstallmentId,
'PaymentAmount': PaymentAmount,
'PromoCode': PromoCode,
'StaffId': StaffId,
'PaymentMethods': JsonConverters.toJson(PaymentMethods,'List<PaymentMethodDto>',context!),
'RestrictedId': RestrictedId,
'RestrictedResourceType': JsonConverters.toJson(RestrictedResourceType,'RestrictedResourceType',context!)
});
getTypeName() => "SellContractRequest";
TypeContext? context = _ctx;
}
enum ResponseStatus
{
stsUnknown,
stsSuccess,
stsDecline,
stsError,
HardDeclineAccount,
HardDeclineExpiry,
PartialApproval,
PendingSuccess,
}
class PendingPaymentResponse implements IConvertible
{
String? ResponseTransactionId;
String? ResponseTxnId;
ResponseStatus? ResponseStatus;
double? ResponseAmount;
String? ResponseText;
String? Last4;
String? AcctClass;
String? AcctType;
String? AcctToken;
PendingPaymentResponse({this.ResponseTransactionId,this.ResponseTxnId,this.ResponseStatus,this.ResponseAmount,this.ResponseText,this.Last4,this.AcctClass,this.AcctType,this.AcctToken});
PendingPaymentResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
ResponseTransactionId = json['ResponseTransactionId'];
ResponseTxnId = json['ResponseTxnId'];
ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'ResponseStatus',context!);
ResponseAmount = JsonConverters.toDouble(json['ResponseAmount']);
ResponseText = json['ResponseText'];
Last4 = json['Last4'];
AcctClass = json['AcctClass'];
AcctType = json['AcctType'];
AcctToken = json['AcctToken'];
return this;
}
Map<String, dynamic> toJson() => {
'ResponseTransactionId': ResponseTransactionId,
'ResponseTxnId': ResponseTxnId,
'ResponseStatus': JsonConverters.toJson(ResponseStatus,'ResponseStatus',context!),
'ResponseAmount': ResponseAmount,
'ResponseText': ResponseText,
'Last4': Last4,
'AcctClass': AcctClass,
'AcctType': AcctType,
'AcctToken': AcctToken
};
getTypeName() => "PendingPaymentResponse";
TypeContext? context = _ctx;
}
class SellContractResultDto implements IConvertible
{
String? ContractSaleID;
String? description;
bool? Success;
IReadOnlyList<PendingPaymentResponse>? PaymentResponses;
SellContractResultDto({this.ContractSaleID,this.description,this.Success,this.PaymentResponses});
SellContractResultDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
ContractSaleID = json['ContractSaleID'];
description = json['description'];
Success = json['Success'];
PaymentResponses = JsonConverters.fromJson(json['PaymentResponses'],'IReadOnlyList<PendingPaymentResponse>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'ContractSaleID': ContractSaleID,
'description': description,
'Success': Success,
'PaymentResponses': JsonConverters.toJson(PaymentResponses,'IReadOnlyList<PendingPaymentResponse>',context!)
};
getTypeName() => "SellContractResultDto";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'clubready.com', types: <String, TypeInfo> {
'ApiDtoBase': TypeInfo(TypeOf.Class, create:() => ApiDtoBase()),
'PaymentMethodType': TypeInfo(TypeOf.Enum, enumValues:PaymentMethodType.values),
'PaymentMethodDto': TypeInfo(TypeOf.Class, create:() => PaymentMethodDto()),
'SellContractRequestDto': TypeInfo(TypeOf.Class, create:() => SellContractRequestDto()),
'List<PaymentMethodDto>': TypeInfo(TypeOf.Class, create:() => <PaymentMethodDto>[]),
'RestrictedResourceType': TypeInfo(TypeOf.Enum, enumValues:RestrictedResourceType.values),
'SellContractRequest': TypeInfo(TypeOf.Class, create:() => SellContractRequest()),
'PendingPaymentResponse': TypeInfo(TypeOf.Class, create:() => PendingPaymentResponse()),
'SellContractResultDto': TypeInfo(TypeOf.Class, create:() => SellContractResultDto()),
'IReadOnlyList<PendingPaymentResponse>': TypeInfo(TypeOf.Class, create:() => IReadOnlyList<PendingPaymentResponse>()),
});
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
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: text/csv
Content-Type: text/csv
Content-Length: length
{"ApiKey":"String","MemberId":0,"ChainId":0,"StoreId":0,"PackageId":0,"InstallmentId":0,"PaymentAmount":0,"PromoCode":"String","StaffId":0,"PaymentMethods":[{"AcctToken":"String","ProfileToken":"String","PaymentProfileId":"String","PaymentAmount":0,"PaymentMethodType":"Uninitialized","DoNotUpdatePaymentTypePreference":false}],"RestrictedId":0,"RestrictedResourceType":"Chain","StartDate":"0001-01-01T00:00:00.0000000"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"ContractSaleID":"String","description":"String","Success":false}