POST | /sales/paymentprofile/import | Import a Payment Method (using ProfileToken) | After a Payment Method is created in the Vault API (www.clubreadygateway.com), the information has to be imported into the ClubReady system. The Vault API will return a ProfileToken and AcctToken. This endpoint will import a ProfileToken as a separate step. If the ProfileToken is sent to any other endpoints, those endpoints will import the ProfileToken and this endpoint is not needed. ### ProfileToken * JSON Web Token (JWT) * Length is variable, but generally around 1,000 to 4,000 characters * Contains non-PCI information about the Payment Method * Signed by the Vault API, preventing modification * Must be sent to ClubReady API within 5 minutes of creation * Can only be used once (though retrying is allowed) * You can parse and read the JWT, but the format is subject to change without notice * You cannot validate the signature in the JWT as the public key is not available ### AcctToken * A short string that is used to reference the Payment Method in the ClubReady system * Usually around 60 to 80 characters * Should not be stored for long-term use as it can change |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentProfileImportRequest:
profile_token: Optional[str] = None
do_not_update_payment_type_preference: bool = False
new_owner_id: Optional[int] = None
# @ApiResponse(Description="", ResponseType=typeof(PaymentProfileImportResponse), StatusCode=200)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentProfileImportEndpoint(PaymentProfileImportRequest, IApiKeyEndpoint):
# @ApiMember(Description="IP address of the end user", Name="X-Forwarded-For", ParameterType="header")
x_forwarded_for: Optional[str] = None
"""
IP address of the end user
"""
# @ApiMember(Description="API Authentication Key", IsRequired=true, ParameterType="query")
api_key: Optional[str] = None
"""
API Authentication Key
"""
# @ApiMember(Description="The ProfileToken JWT to import (see description above)", IsRequired=true)
profile_token: Optional[str] = None
"""
The ProfileToken JWT to import (see description above)
"""
# @ApiMember(Description="When adding a PaymentMethod that is 'on-file' (`IsTemp == true`), the default behavior is to\r\nset this PaymentMethod as the preferred method. If you do not wish this to be the preferred\r\nmethod, you can set `DoNotUpdatePaymentTypePreference` to `true`. Otherwise, this can be\r\nomitted or `false`.\r\n\r\nFor non 'on-file' PaymentMethods, this setting is ignored.")
do_not_update_payment_type_preference: bool = False
"""
When adding a PaymentMethod that is 'on-file' (`IsTemp == true`), the default behavior is toset this PaymentMethod as the preferred method. If you do not wish this to be the preferredmethod, you can set `DoNotUpdatePaymentTypePreference` to `true`. Otherwise, this can beomitted or `false`.For non 'on-file' PaymentMethods, this setting is ignored.
"""
# @ApiMember(Description="**Conditionally Required** \r\n\r\nWhen importing a ProfileToken with an OwnerType of `TempStUser`, the ownership will be changed to\r\nOwnerType of `User` with the userId of the supplied `NewOwnerId`.\r\n\r\nThis is needed when a PaymentMethod is created for a User that has not been selected or created, yet.")
new_owner_id: Optional[int] = None
"""
**Conditionally Required** When importing a ProfileToken with an OwnerType of `TempStUser`, the ownership will be changed toOwnerType of `User` with the userId of the supplied `NewOwnerId`.This is needed when a PaymentMethod is created for a User that has not been selected or created, yet.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentProfile(IFullNameContainer):
payment_profile_id: int = 0
acct_token: Optional[str] = None
owner_id: int = 0
owner_type_id: int = 0
acct_type_id: int = 0
acct_class_id: int = 0
prefix_name: Optional[str] = None
first_name: Optional[str] = None
middle_name: Optional[str] = None
last_name: Optional[str] = None
suffix_name: Optional[str] = None
address1: Optional[str] = None
address2: Optional[str] = None
urbanization: Optional[str] = None
city: Optional[str] = None
state: Optional[str] = None
postal_code: Optional[str] = None
country_code: Optional[str] = None
last4: Optional[str] = None
cc_exp_month: Optional[int] = None
cc_exp_year: Optional[int] = None
is_temp: bool = False
is_disabled: bool = False
on_hold_utc: Optional[datetime.datetime] = None
on_hold_reason_code: Optional[int] = None
on_hold_reason_detail: Optional[str] = None
acct_updater_flag_utc: Optional[datetime.datetime] = None
created_by: int = 0
created_utc: datetime.datetime = datetime.datetime(1, 1, 1)
modified_by: int = 0
modified_utc: datetime.datetime = datetime.datetime(1, 1, 1)
acct_updater_flag: bool = False
entry_mode_id: int = 0
exclude_from_acct_updater: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PaymentProfileImportResponse:
success: bool = False
message: Optional[str] = None
payment_profile: Optional[PaymentProfile] = None
Python PaymentProfileImportEndpoint DTOs
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/paymentprofile/import HTTP/1.1
Host: www.clubready.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<PaymentProfileImportEndpoint xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Web.Api.Sales">
<DoNotUpdatePaymentTypePreference xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Payments">false</DoNotUpdatePaymentTypePreference>
<NewOwnerId xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Payments">0</NewOwnerId>
<ProfileToken xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Payments">String</ProfileToken>
<ApiKey>String</ApiKey>
<XForwardedFor>String</XForwardedFor>
</PaymentProfileImportEndpoint>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <PaymentProfileImportResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ClubReady.Payments"> <Message>String</Message> <PaymentProfile xmlns:d2p1="http://schemas.datacontract.org/2004/07/ClubReady.Payments.PaymentsDb"> <d2p1:AcctClassId>0</d2p1:AcctClassId> <d2p1:AcctToken>String</d2p1:AcctToken> <d2p1:AcctTypeId>0</d2p1:AcctTypeId> <d2p1:AcctUpdaterFlag>false</d2p1:AcctUpdaterFlag> <d2p1:AcctUpdaterFlagUtc>0001-01-01T00:00:00</d2p1:AcctUpdaterFlagUtc> <d2p1:Address1>String</d2p1:Address1> <d2p1:Address2>String</d2p1:Address2> <d2p1:CcExpMonth>0</d2p1:CcExpMonth> <d2p1:CcExpYear>0</d2p1:CcExpYear> <d2p1:City>String</d2p1:City> <d2p1:CountryCode>String</d2p1:CountryCode> <d2p1:CreatedBy>0</d2p1:CreatedBy> <d2p1:CreatedUtc>0001-01-01T00:00:00</d2p1:CreatedUtc> <d2p1:EntryModeId>0</d2p1:EntryModeId> <d2p1:ExcludeFromAcctUpdater>false</d2p1:ExcludeFromAcctUpdater> <d2p1:FirstName>String</d2p1:FirstName> <d2p1:IsDisabled>false</d2p1:IsDisabled> <d2p1:IsTemp>false</d2p1:IsTemp> <d2p1:Last4>String</d2p1:Last4> <d2p1:LastName>String</d2p1:LastName> <d2p1:MiddleName>String</d2p1:MiddleName> <d2p1:ModifiedBy>0</d2p1:ModifiedBy> <d2p1:ModifiedUtc>0001-01-01T00:00:00</d2p1:ModifiedUtc> <d2p1:OnHoldReasonCode>0</d2p1:OnHoldReasonCode> <d2p1:OnHoldReasonDetail>String</d2p1:OnHoldReasonDetail> <d2p1:OnHoldUtc>0001-01-01T00:00:00</d2p1:OnHoldUtc> <d2p1:OwnerId>0</d2p1:OwnerId> <d2p1:OwnerTypeId>0</d2p1:OwnerTypeId> <d2p1:PaymentProfileId>0</d2p1:PaymentProfileId> <d2p1:PostalCode>String</d2p1:PostalCode> <d2p1:PrefixName>String</d2p1:PrefixName> <d2p1:State>String</d2p1:State> <d2p1:SuffixName>String</d2p1:SuffixName> <d2p1:Urbanization>String</d2p1:Urbanization> </PaymentProfile> <Success>false</Success> </PaymentProfileImportResponse>