Skip to content

Commit

Permalink
Update payment sessions schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko committed Aug 14, 2024
1 parent 62da3b7 commit 03d5e67
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 141 deletions.
65 changes: 50 additions & 15 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ const (
type CardType string

const (
Charge CardType = "Charge"
Credit CardType = "Credit"
Debit CardType = "Debit"
Prepaid CardType = "Prepaid"
Charge CardType = "Charge"
DeferredDebit CardType = "Deferred Debit"
Prepaid CardType = "Prepaid"
)

type CardCategory string

const (
Consumer CardCategory = "Consumer"
Commercial CardCategory = "Commercial"
All CardCategory = "All"
Commercial CardCategory = "Commercial"
Consumer CardCategory = "Consumer"
NotSet CardCategory = "NotSet"
OtherCardCategory CardCategory = "Other"
)

Expand All @@ -50,10 +51,15 @@ const (
type ChallengeIndicator string

const (
NoPreference ChallengeIndicator = "no_preference"
NoChallengeRequested ChallengeIndicator = "no_challenge_requested"
ChallengeRequested ChallengeIndicator = "challenge_requested"
ChallengeRequestedMandate ChallengeIndicator = "challenge_requested_mandate"
ChallengeRequested ChallengeIndicator = "challenge_requested"
ChallengeRequestedMandate ChallengeIndicator = "challenge_requested_mandate"
ChallengeIndicatorDataShare ChallengeIndicator = "data_share"
ChallengeIndicatorLowValue ChallengeIndicator = "low_value"
NoChallengeRequested ChallengeIndicator = "no_challenge_requested"
NoPreference ChallengeIndicator = "no_preference"
ChallengeIndicatorTransactionRiskAssessment ChallengeIndicator = "transaction_risk_assessment"
ChallengeIndicatorTrustedListing ChallengeIndicator = "trusted_listing"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
secret
.
ChallengeIndicatorTrustedListingPrompt ChallengeIndicator = "trusted_listing_prompt"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
secret
.
)

type DocumentType string
Expand Down Expand Up @@ -88,17 +94,17 @@ const (
type Exemption string

const (
None Exemption = "none"
LowRiskProgram Exemption = "low_risk_program"
LowValue Exemption = "low_value"
None Exemption = "none"
Other Exemption = "other"
OutOfScaScope Exemption = "out_of_sca_scope"
RecurringOperation Exemption = "recurring_operation"
TransactionRiskAssessment Exemption = "transaction_risk_assessment"
ScaDelegation Exemption = "sca_delegation"
SecureCorporatePayment Exemption = "secure_corporate_payment"
TrustedListing Exemption = "trusted_listing"
ThreeDsOutage Exemption = "3ds_outage"
ScaDelegation Exemption = "sca_delegation"
OutOfScaScope Exemption = "out_of_sca_scope"
Other Exemption = "other"
LowRiskProgram Exemption = "low_risk_program"
TransactionRiskAssessment Exemption = "transaction_risk_assessment"
TrustedListing Exemption = "trusted_listing"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
secret
.
)

type ThreeDsMethodCompletion string
Expand Down Expand Up @@ -290,3 +296,32 @@ type (
Bank *BankDetails `json:"bank,omitempty"`
}
)

type CardholderAccountAgeIndicatorType string

const (
CardholderLessThanThirtyDays CardholderAccountAgeIndicatorType = "less_than_thirty_days"
CardholderMoreThanSixtyDays CardholderAccountAgeIndicatorType = "more_than_sixty_days"
CardholderNoAccount CardholderAccountAgeIndicatorType = "no_account"
CardholderThirtyToSixtyDays CardholderAccountAgeIndicatorType = "thirty_to_sixty_days"
CardholderThisTransaction CardholderAccountAgeIndicatorType = "this_transaction"
)

type AccountChangeIndicatorType string

const (
AccountChangeLessThanThirtyDays AccountChangeIndicatorType = "less_than_thirty_days"
AccountChangeMoreThanSixtyDays AccountChangeIndicatorType = "more_than_sixty_days"
AccountChangeThirtyToSixtyDays AccountChangeIndicatorType = "thirty_to_sixty_days"
AccountChangeThisTransaction AccountChangeIndicatorType = "this_transaction"
)

type AccountPasswordChangeIndicatorType string

const (
PasswordChangeLessThanThirtyDays AccountPasswordChangeIndicatorType = "less_than_thirty_days"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
password
.
PasswordChangeMoreThanSixtyDays AccountPasswordChangeIndicatorType = "more_than_sixty_days"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
password
.
PasswordChangeNoChange AccountPasswordChangeIndicatorType = "no_change"
PasswordChangeThirtyToSixtyDays AccountPasswordChangeIndicatorType = "thirty_to_sixty_days"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
password
.
PasswordChangeThisTransaction AccountPasswordChangeIndicatorType = "this_transaction"

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

Hard-coded
password
.
)
46 changes: 38 additions & 8 deletions sessions/channels/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,43 @@ import (
type ChannelType string

const (
Browser ChannelType = "browser"
App ChannelType = "app"
App ChannelType = "app"
Browser ChannelType = "browser"
MerchantInitiated ChannelType = "merchant_initiated"
)

type SdkInterfaceType string

const (
Native SdkInterfaceType = "native"
Html SdkInterfaceType = "html"
Both SdkInterfaceType = "both"
Html SdkInterfaceType = "html"
Native SdkInterfaceType = "native"
)

type UIElements string

const (
Text UIElements = "text"
SingleSelect UIElements = "single_select"
HtmlOther UIElements = "html_other"
MultiSelect UIElements = "multi_select"
Oob UIElements = "oob"
HtmlOther UIElements = "html_other"
SingleSelect UIElements = "single_select"
Text UIElements = "text"
)

type RequestType string

const (
AccountVerification RequestType = "account_verification"
AddCard RequestType = "add_card"
InstallmentTransaction RequestType = "installment_transaction"
MailOrder RequestType = "mail_order"
MaintainCardInformation RequestType = "maintain_card_information"
OtherPayment RequestType = "other_payment"
RecurringTransaction RequestType = "recurring_transaction"
SplitOrDelayedShipment RequestType = "split_or_delayed_shipment"
TelephoneOrder RequestType = "telephone_order"
TopUp RequestType = "top_up"
WhitelistStatusCheck RequestType = "whitelist_status_check"
)

type (
Expand All @@ -52,7 +69,7 @@ type (

browserSession struct {
ChannelData
ThreeDsMethodCompletion common.ThreeDsMethodCompletion `json:"three_ds_method_completion,omitempty"`
ThreeDsMethodCompletion common.ThreeDsMethodCompletion `json:"three_ds_method_completion,omitempty" default:"u"`
AcceptHeader string `json:"accept_header,omitempty"`
JavaEnabled bool `json:"java_enabled,omitempty"`
JavascriptEnabled bool `json:"javascript_enabled,omitempty"`
Expand All @@ -64,6 +81,11 @@ type (
UserAgent string `json:"user_agent,omitempty"`
IpAddress string `json:"ip_address,omitempty"`
}

merchantInitiatedSession struct {
ChannelData
RequestType RequestType `json:"request_type,omitempty"`
}
)

func NewAppSession() *appSession {
Expand All @@ -74,6 +96,10 @@ func NewBrowserSession() *browserSession {
return &browserSession{ChannelData: ChannelData{Channel: Browser}}
}

func NewMerchantInitiatedSession() *merchantInitiatedSession {
return &merchantInitiatedSession{ChannelData: ChannelData{Channel: MerchantInitiated}}
}

func (s *appSession) GetType() ChannelType {
return s.Channel
}
Expand All @@ -82,6 +108,10 @@ func (s *browserSession) GetType() ChannelType {
return s.Channel
}

func (s *merchantInitiatedSession) GetType() ChannelType {
return s.Channel
}

type SdkEphemeralPublicKey struct {
Kty string `json:"kty,omitempty"`
Crv string `json:"crv,omitempty"`
Expand Down
77 changes: 58 additions & 19 deletions sessions/sessions.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sessions

import "time"

const (
SessionsPath = "sessions"
CollectDataPath = "collect-data"
Expand All @@ -10,11 +12,11 @@ const (
type AuthenticationType string

const (
RegularAuthType AuthenticationType = "regular"
RecurringAuthType AuthenticationType = "recurring"
AddCardAuthType AuthenticationType = "add_card"
InstallmentAuthType AuthenticationType = "installment"
MaintainCardAuthType AuthenticationType = "maintain_card"
AddCardAuthType AuthenticationType = "add_card"
RecurringAuthType AuthenticationType = "recurring"
RegularAuthType AuthenticationType = "regular"
)

type Category string
Expand All @@ -27,26 +29,26 @@ const (
type TransactionType string

const (
GoodsService TransactionType = "goods_service"
CheckAcceptance TransactionType = "check_acceptance"
AccountFunding TransactionType = "account_funding"
QuashiCardTransaction TransactionType = "quashi_card_transaction"
CheckAcceptance TransactionType = "check_acceptance"
GoodsService TransactionType = "goods_service"
PrepaidActivationAndLoad TransactionType = "prepaid_activation_and_load"
QuashiCardTransaction TransactionType = "quashi_card_transaction"
)

type SessionStatus string

const (
Pending SessionStatus = "pending"
Processing SessionStatus = "processing"
Challenged SessionStatus = "challenged"
ChallengeAbandoned SessionStatus = "challenge_abandoned"
Expired SessionStatus = "expired"
Approved SessionStatus = "approved"
Attempted SessionStatus = "attempted"
Unavailable SessionStatus = "unavailable"
Challenged SessionStatus = "challenged"
ChallengeAbandoned SessionStatus = "challenge_abandoned"
Declined SessionStatus = "declined"
Expired SessionStatus = "expired"
Pending SessionStatus = "pending"
Processing SessionStatus = "processing"
Rejected SessionStatus = "rejected"
Unavailable SessionStatus = "unavailable"
)

type StatusReason string
Expand All @@ -66,21 +68,58 @@ const (
type NextAction string

const (
Authenticate NextAction = "authenticate"
ChallengeCardHolder NextAction = "challenge_cardholder"
CollectChannelData NextAction = "collect_channel_data"
Complete NextAction = "complete"
IssueFingerprint NextAction = "issuer_fingerprint"
ChallengeCardHolder NextAction = "challenge_cardholder"
RedirectCardholder NextAction = "redirect_cardholder"
Complete NextAction = "complete"
Authenticate NextAction = "authenticate"
)

type DeliveryTimeframe string

const (
ElectronicDelivery DeliveryTimeframe = "electronic_delivery"
SameDay DeliveryTimeframe = "same_day"
Overnight DeliveryTimeframe = "overnight"
TwoDayOrMore DeliveryTimeframe = "two_day_or_more"
)

type PreOrderPurchaseIndicatorType string

const (
FutureAvailability PreOrderPurchaseIndicatorType = "future_availability"
MerchandiseAvailable PreOrderPurchaseIndicatorType = "merchandise_available"
)

type ReorderItemsIndicatorType string

const (
FirstTimeOrdered ReorderItemsIndicatorType = "first_time_ordered"
Reordered ReorderItemsIndicatorType = "reordered"
)

type Recurring struct {
DaysBetweenPayments int `json:"days_between_payments,omitempty"`
Expiry string `json:"expiry,omitempty"`
DaysBetweenPayments int `json:"days_between_payments,omitempty" default:"1"`
Expiry string `json:"expiry,omitempty" default:"99991231"`
}

type Installment struct {
NumberOfPayments int `json:"number_of_payments,omitempty"`
DaysBetweenPayments int `json:"days_between_payments,omitempty"`
Expiry string `json:"expiry,omitempty"`
DaysBetweenPayments int `json:"days_between_payments,omitempty" default:"1"`
Expiry string `json:"expiry,omitempty" default:"99991231"`
}

type MerchantRiskInfo struct {
DeliveryEmail string `json:"delivery_email,omitempty"`
DeliveryTimeframe DeliveryTimeframe `json:"delivery_timeframe,omitempty"`
IsPreorder bool `json:"is_preorder,omitempty"`
IsReorder bool `json:"is_reorder,omitempty"`
ShippingIndicator ShippingIndicator `json:"shipping_indicator,omitempty"`
ReorderItemsIndicator ReorderItemsIndicatorType `json:"reorder_items_indicator,omitempty"`
PreOrderPurchaseIndicator PreOrderPurchaseIndicatorType `json:"pre_order_purchase_indicator,omitempty"`
PreOrderDate *time.Time `json:"pre_order_date,omitempty"`
GiftCardAmount string `json:"gift_card_amount,omitempty"`
GiftCardCurrency string `json:"gift_card_currency,omitempty"`
GiftCardCount string `json:"gift_card_count,omitempty"`
}
Loading

0 comments on commit 03d5e67

Please sign in to comment.