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. |
---|
System.IO.InvalidDataException: MetaData is potentially malicious. Expected scalar value, Received: 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 example with a total of $1.00. The firstPaymentMethod (the Gift Card) will be attempted for $1.00. If it partially approves for less than 1.00 (example: $0.80), the second payment method (PreferredOnFile) will be attempted for the lesser of it'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. at ServiceStack.NativeTypes.VbNet.VbNetGeneratorExtensions.SafeValue(String value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 791 at ServiceStack.NativeTypes.VbNet.VbNetGeneratorExtensions.QuotedSafeValue(String value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 796 at ServiceStack.NativeTypes.VbNet.VbNetGenerator.TypeValue(String type, String value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 589 at ServiceStack.NativeTypes.VbNet.VbNetGenerator.AppendAttributes(StringBuilderWrapper sb, List`1 attributes) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 560 at ServiceStack.NativeTypes.VbNet.VbNetGenerator.AddProperties(StringBuilderWrapper sb, MetadataType type, Boolean includeResponseStatus) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 483 at ServiceStack.NativeTypes.VbNet.VbNetGenerator.AppendType(StringBuilderWrapper& sb, MetadataType type, String lastNS, List`1 allTypes, CreateTypeOptions options) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 402 at ServiceStack.NativeTypes.VbNet.VbNetGenerator.GetCode(MetadataTypes metadata, IRequest request, INativeTypesMetadata nativeTypes) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/VbNet/VbNetGenerator.cs:line 269 at ServiceStack.NativeTypes.LangGeneratorExtensions.g__Generate|1_0(ILangGenerator gen, <>c__DisplayClass1_0& ) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/ILangGenerator.cs:line 40 at ServiceStack.NativeTypes.LangGeneratorExtensions.GenerateSourceCode(MetadataTypes metadataTypes, MetadataTypesConfig typesConfig, String lang, IRequest req, Action`1 configure) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/ILangGenerator.cs:line 51 at ServiceStack.NativeTypes.LangGeneratorExtensions.GenerateSourceCode(List`1 metadataTypes, String lang, IRequest req, Action`1 configure) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/NativeTypes/ILangGenerator.cs:line 26 at ServiceStack.Metadata.BaseMetadataHandler. d__12.MoveNext() in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Metadata/BaseMetadataHandler.cs:line 203
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
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/jsv
Content-Type: text/jsv
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-01
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { ContractSaleID: String, description: String, Success: False }