Skip to content

Commit

Permalink
Review payment & payout request schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
martinseco committed Feb 2, 2023
1 parent 6bd3c41 commit 6be9b81
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 130 deletions.
4 changes: 3 additions & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ type (
Type AccountHolderIdentificationType `json:"type,omitempty"`
Number string `json:"number,omitempty"`
IssuingCountry Country `json:"issuing_country,omitempty"`
DateOfExpiry AccountHolderType `json:"date_of_expiry,omitempty"`
DateOfExpiry string `json:"date_of_expiry,omitempty"`
}

AccountHolder struct {
Type AccountHolderType `json:"type,omitempty"`
Title string `json:"title,omitempty"`
FirstName string `json:"first_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name,omitempty"`
CompanyName string `json:"company_name,omitempty"`
TaxId string `json:"tax_id,omitempty"`
Expand Down
84 changes: 42 additions & 42 deletions payments/abc/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@ import (
// Request
type (
PaymentRequest struct {
Source payments.PaymentSource `json:"source,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
MerchantInitiated bool `json:"merchant_initiated"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Processing map[string]interface{} `json:"processing,omitempty"`
Source payments.PaymentSource `json:"source,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
MerchantInitiated bool `json:"merchant_initiated"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}

PayoutRequest struct {
Destination payments.Destination `json:"destination,omitempty"`
Amount int64 `json:"amount,omitempty"`
FundTransferType payments.FundTransferType `json:"fund_transfer_type,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Processing map[string]interface{} `json:"processing,omitempty"`
Destination payments.Destination `json:"destination,omitempty"`
Amount int64 `json:"amount,omitempty"`
FundTransferType payments.FundTransferType `json:"fund_transfer_type,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}

CaptureRequest struct {
Expand Down
19 changes: 10 additions & 9 deletions payments/abc/sources/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ type (
}

requestDLocalSource struct {
Type payments.SourceType `json:"type,omitempty"`
Number string `json:"number,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
Name string `json:"name,omitempty"`
Cvv string `json:"cvv,omitempty"`
Stored bool `json:"stored"`
BillingAddress *common.Address `json:"billing_address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
Type payments.SourceType `json:"type,omitempty"`
Number string `json:"number,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
Name string `json:"name,omitempty"`
Cvv string `json:"cvv,omitempty"`
Stored bool `json:"stored"`
StoreForFutureUse bool `json:"store_for_future_use,omitempty"`
BillingAddress *common.Address `json:"billing_address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
}
)

Expand Down
1 change: 1 addition & 0 deletions payments/nas/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type (
Sender Sender `json:"sender,omitempty"`
Recipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Marketplace *common.MarketplaceData `json:"marketplace,omitempty"`
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
Items []payments.Product `json:"items,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Expand Down
7 changes: 6 additions & 1 deletion payments/nas/sources/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type (

requestNetworkTokenSource struct {
Type payments.SourceType `json:"type,omitempty"`
Token string `json:"token,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
TokenType payments.NetworkTokenType `json:"token_type,omitempty"`
Expand Down Expand Up @@ -142,10 +143,14 @@ type (
}
)

func NewPayoutRequestSource() *payoutRequestSource {
func NewPayoutCurrencyAccountSource() *payoutRequestSource {
return &payoutRequestSource{Type: payments.CurrencyAccountSource}
}

func NewPayoutEntitySource() *payoutRequestSource {
return &payoutRequestSource{Type: payments.EntitySource}
}

func (s *payoutRequestSource) GetType() payments.SourceType {
return s.Type
}
89 changes: 54 additions & 35 deletions payments/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,44 +241,49 @@ type (
}

PaymentRecipient struct {
DateOfBirth string `json:"dob,omitempty"`
AccountNumber string `json:"account_number,omitempty"`
CountryCode common.Country `json:"country_code,omitempty"`
Zip string `json:"zip,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
DateOfBirth string `json:"dob,omitempty"`
AccountNumber string `json:"account_number,omitempty"`
Address *common.Address `json:"address,omitempty"`
CountryCode common.Country `json:"country_code,omitempty"`
Zip string `json:"zip,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
}

ProcessingSettings struct {
OrderId string `json:"order_id,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
DiscountAmount int64 `json:"discount_amount,omitempty"`
DutyAmount int64 `json:"duty_amount,omitempty"`
ShippingAmount int64 `json:"shipping_amount,omitempty"`
ShippingTaxAmount int64 `json:"shipping_tax_amount,omitempty"`
Aft bool `json:"aft,omitempty"`
PreferredScheme PreferredSchema `json:"preferred_scheme,omitempty"`
MerchantInitiatedReason MerchantInitiatedReason `json:"merchant_initiated_reason,omitempty"`
CampaignId int64 `json:"campaign_id,omitempty"`
ProductType ProductType `json:"product_type,omitempty"`
OpenId string `json:"open_id,omitempty"`
OriginalOrderAmount int64 `json:"original_order_amount,omitempty"`
ReceiptId string `json:"receipt_id,omitempty"`
TerminalType TerminalType `json:"terminal_type,omitempty"`
OsType OsType `json:"os_type,omitempty"`
InvoiceId string `json:"invoice_id,omitempty"`
BrandName string `json:"brand_name,omitempty"`
Locale string `json:"locale,omitempty"`
ShippingPreference ShippingPreference `json:"shipping_preference,omitempty"`
UserAction UserAction `json:"user_action,omitempty"`
SetTransactionContext []map[string]string `json:"set_transaction_context,omitempty"`
AirlineData []AirlineData `json:"airline_data,omitempty"`
OtpValue string `json:"otp_value,omitempty"`
PurchaseCountry common.Country `json:"purchase_country,omitempty"`
CustomPaymentMethodIds []string `json:"custom_payment_method_ids,omitempty"`
ShippingDelay int64 `json:"shipping_delay,omitempty"`
ShippingInfo string `json:"shipping_info,omitempty"`
Dlocal *DLocalProcessingSettings `json:"dlocal,omitempty"`
OrderId string `json:"order_id,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
DiscountAmount int64 `json:"discount_amount,omitempty"`
DutyAmount int64 `json:"duty_amount,omitempty"`
ShippingAmount int64 `json:"shipping_amount,omitempty"`
ShippingTaxAmount int64 `json:"shipping_tax_amount,omitempty"`
Aft bool `json:"aft,omitempty"`
PreferredScheme PreferredSchema `json:"preferred_scheme,omitempty"`
MerchantInitiatedReason MerchantInitiatedReason `json:"merchant_initiated_reason,omitempty"`
CampaignId int64 `json:"campaign_id,omitempty"`
ProductType ProductType `json:"product_type,omitempty"`
OpenId string `json:"open_id,omitempty"`
OriginalOrderAmount int64 `json:"original_order_amount,omitempty"`
ReceiptId string `json:"receipt_id,omitempty"`
TerminalType TerminalType `json:"terminal_type,omitempty"`
OsType OsType `json:"os_type,omitempty"`
InvoiceId string `json:"invoice_id,omitempty"`
BrandName string `json:"brand_name,omitempty"`
Locale string `json:"locale,omitempty"`
ShippingPreference ShippingPreference `json:"shipping_preference,omitempty"`
UserAction UserAction `json:"user_action,omitempty"`
SetTransactionContext []map[string]string `json:"set_transaction_context,omitempty"`
AirlineData []AirlineData `json:"airline_data,omitempty"`
OtpValue string `json:"otp_value,omitempty"`
PurchaseCountry common.Country `json:"purchase_country,omitempty"`
CustomPaymentMethodIds []string `json:"custom_payment_method_ids,omitempty"`
MerchantCallbackUrl string `json:"merchant_callback_url,omitempty"`
ShippingDelay int64 `json:"shipping_delay,omitempty"`
ShippingInfo string `json:"shipping_info,omitempty"`
// Only available on Previous
SenderInformation *SenderInformation `json:"senderInformation,omitempty"`
Purpose string `json:"purpose,omitempty"`
Dlocal *DLocalProcessingSettings `json:"dlocal,omitempty"`
}

ThreeDsEnrollment struct {
Expand Down Expand Up @@ -334,6 +339,20 @@ type (
Count string `json:"count,omitempty"`
}

SenderInformation struct {
Reference string `json:"reference,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Dob string `json:"dob,omitempty"`
Address string `json:"address,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country common.Country `json:"country,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
SourceOfFunds string `json:"sourceOfFunds,omitempty"`
Purpose string `json:"purpose,omitempty"`
}

DLocalProcessingSettings struct {
Country common.Country `json:"country,omitempty"`
Payer Payer `json:"payer,omitempty"`
Expand Down
Loading

0 comments on commit 6be9b81

Please sign in to comment.