From 6be9b8180fc1cf0665e1e9a05adcc9338804d51c Mon Sep 17 00:00:00 2001 From: Martin Seco Date: Mon, 23 Jan 2023 12:41:15 -0300 Subject: [PATCH] Review payment & payout request schemas --- common/common.go | 4 +- payments/abc/payments.go | 84 +++++++++++++++---------------- payments/abc/sources/sources.go | 19 +++---- payments/nas/payments.go | 1 + payments/nas/sources/sources.go | 7 ++- payments/payments.go | 89 ++++++++++++++++++++------------- payments/sources.go | 84 +++++++++++++++---------------- 7 files changed, 158 insertions(+), 130 deletions(-) diff --git a/common/common.go b/common/common.go index af81584..93b1023 100644 --- a/common/common.go +++ b/common/common.go @@ -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"` diff --git a/payments/abc/payments.go b/payments/abc/payments.go index 99493bd..988193a 100644 --- a/payments/abc/payments.go +++ b/payments/abc/payments.go @@ -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 { diff --git a/payments/abc/sources/sources.go b/payments/abc/sources/sources.go index 2a8b904..76d9515 100644 --- a/payments/abc/sources/sources.go +++ b/payments/abc/sources/sources.go @@ -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"` } ) diff --git a/payments/nas/payments.go b/payments/nas/payments.go index a4f1e08..c26b8ea 100644 --- a/payments/nas/payments.go +++ b/payments/nas/payments.go @@ -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"` diff --git a/payments/nas/sources/sources.go b/payments/nas/sources/sources.go index c29047d..403d448 100644 --- a/payments/nas/sources/sources.go +++ b/payments/nas/sources/sources.go @@ -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"` @@ -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 } diff --git a/payments/payments.go b/payments/payments.go index 1b8d48f..994ef9f 100644 --- a/payments/payments.go +++ b/payments/payments.go @@ -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 { @@ -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"` diff --git a/payments/sources.go b/payments/sources.go index 0051291..6e55fae 100644 --- a/payments/sources.go +++ b/payments/sources.go @@ -3,51 +3,51 @@ package payments type SourceType string const ( - CardSource SourceType = "card" - IdSource SourceType = "id" - CustomerSource SourceType = "customer" - NetworkTokenSource SourceType = "network_token" - TokenSource SourceType = "token" - DLocalSource SourceType = "dLocal" - AlipaySource SourceType = "alipay" - BenefitPaySource SourceType = "benefitpay" - BoletoSource SourceType = "boleto" - EpsSource SourceType = "eps" - GiropaySource SourceType = "giropay" - IdealSource SourceType = "ideal" - KlarnaSource SourceType = "klarna" - KnetSource SourceType = "knet" - OxxoSource SourceType = "oxxo" - P24Source SourceType = "p24" - PagoFacilSource SourceType = "pagofacil" - PayPalSource SourceType = "paypal" - PoliSource SourceType = "poli" - RapiPagoSource SourceType = "rapipago" - BancontactSource SourceType = "bancontact" - FawrySource SourceType = "fawry" - QPaySource SourceType = "qpay" - MultiBancoSource SourceType = "multibanco" - SepaSource SourceType = "sepa" - SofortSource SourceType = "sofort" - AlipayHk SourceType = "alipay_hk" - AlipayCn SourceType = "alipay_cn" - AlipayPlus SourceType = "alipay_plus" - Gcash SourceType = "gcash" - Wechatpay SourceType = "wechatpay" - Dana SourceType = "dana" - Kakaopay SourceType = "kakaopay" - Truemoney SourceType = "truemoney" - Tng SourceType = "tng" - Afterpay SourceType = "afterpay" - Benefit SourceType = "benefit" - Mbway SourceType = "mbway" - Postfinance SourceType = "postfinance" - Stcpay SourceType = "stcpay" - Alma SourceType = "alma" - + CardSource SourceType = "card" + IdSource SourceType = "id" + CustomerSource SourceType = "customer" + NetworkTokenSource SourceType = "network_token" + TokenSource SourceType = "token" + DLocalSource SourceType = "dLocal" + AlipaySource SourceType = "alipay" + BenefitPaySource SourceType = "benefitpay" + BoletoSource SourceType = "boleto" + EpsSource SourceType = "eps" + GiropaySource SourceType = "giropay" + IdealSource SourceType = "ideal" + KlarnaSource SourceType = "klarna" + KnetSource SourceType = "knet" + OxxoSource SourceType = "oxxo" + P24Source SourceType = "p24" + PagoFacilSource SourceType = "pagofacil" + PayPalSource SourceType = "paypal" + PoliSource SourceType = "poli" + RapiPagoSource SourceType = "rapipago" + BancontactSource SourceType = "bancontact" + FawrySource SourceType = "fawry" + QPaySource SourceType = "qpay" + MultiBancoSource SourceType = "multibanco" + SepaSource SourceType = "sepa" + SofortSource SourceType = "sofort" + AlipayHk SourceType = "alipay_hk" + AlipayCn SourceType = "alipay_cn" + AlipayPlus SourceType = "alipay_plus" + Gcash SourceType = "gcash" + Wechatpay SourceType = "wechatpay" + Dana SourceType = "dana" + Kakaopay SourceType = "kakaopay" + Truemoney SourceType = "truemoney" + Tng SourceType = "tng" + Afterpay SourceType = "afterpay" + Benefit SourceType = "benefit" + Mbway SourceType = "mbway" + Postfinance SourceType = "postfinance" + Stcpay SourceType = "stcpay" + Alma SourceType = "alma" BankAccountSource SourceType = "bank_account" ProviderTokenSource SourceType = "provider_token" CurrencyAccountSource SourceType = "currency_account" + EntitySource SourceType = "entity" TamaraSource SourceType = "tamara" )