diff --git a/payments/nas/payments.go b/payments/nas/payments.go index 0b9f22b..317296e 100644 --- a/payments/nas/payments.go +++ b/payments/nas/payments.go @@ -82,33 +82,36 @@ type ( // 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"` - AuthorizationType AuthorizationType `json:"authorization_type,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"` - ProcessingChannelId string `json:"processing_channel_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"` - 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"` + PaymentContextId string `json:"payment_context_id,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"` + AuthorizationType AuthorizationType `json:"authorization_type,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"` + Segment *payments.PaymentSegment `json:"segment,omitempty"` + ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"` + PreviousPaymentId string `json:"previous_payment_id,omitempty"` + ProcessingChannelId string `json:"processing_channel_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"` + 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"` + Retry *payments.PaymentRetryRequest `json:"retry,omitempty"` + Metadata map[string]interface{} `json:"metadata,omitempty"` } PayoutRequest struct { @@ -150,27 +153,28 @@ type ( type ( PaymentResponse struct { HttpMetadata common.HttpMetadata - ActionId string `json:"action_id,omitempty"` - Amount int64 `json:"amount,omitempty"` - Approved bool `json:"approved,omitempty"` - AuthCode string `json:"auth_code,omitempty"` - Id string `json:"id,omitempty"` - Currency common.Currency `json:"currency,omitempty"` - Customer *common.CustomerResponse `json:"customer,omitempty"` - Source *SourceResponse `json:"source,omitempty"` - Status payments.PaymentStatus `json:"status,omitempty"` - ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"` - Reference string `json:"reference,omitempty"` - ResponseCode string `json:"response_code,omitempty"` - ResponseSummary string `json:"response_summary,omitempty"` - Risk *payments.RiskAssessment `json:"risk,omitempty"` - ProcessedOn *time.Time `json:"processed_on,omitempty"` - ExpiresOn *time.Time `json:"expires_on,omitempty"` - Balances *PaymentResponseBalances `json:"balances,omitempty"` - Processing *payments.PaymentProcessing `json:"processing,omitempty"` - Eci string `json:"eci,omitempty"` - SchemeId string `json:"scheme_id,omitempty"` - Links map[string]common.Link `json:"_links"` + ActionId string `json:"action_id,omitempty"` + Amount int64 `json:"amount,omitempty"` + Approved bool `json:"approved,omitempty"` + AuthCode string `json:"auth_code,omitempty"` + Id string `json:"id,omitempty"` + Currency common.Currency `json:"currency,omitempty"` + Customer *common.CustomerResponse `json:"customer,omitempty"` + Source *SourceResponse `json:"source,omitempty"` + Status payments.PaymentStatus `json:"status,omitempty"` + ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"` + Reference string `json:"reference,omitempty"` + ResponseCode string `json:"response_code,omitempty"` + ResponseSummary string `json:"response_summary,omitempty"` + Risk *payments.RiskAssessment `json:"risk,omitempty"` + ProcessedOn *time.Time `json:"processed_on,omitempty"` + ExpiresOn *time.Time `json:"expires_on,omitempty"` + Balances *PaymentResponseBalances `json:"balances,omitempty"` + Processing *payments.PaymentProcessing `json:"processing,omitempty"` + Eci string `json:"eci,omitempty"` + SchemeId string `json:"scheme_id,omitempty"` + Retry *payments.PaymentRetryResponse `json:"retry,omitempty"` + Links map[string]common.Link `json:"_links"` } PayoutResponse struct { diff --git a/payments/nas/source.go b/payments/nas/source.go index 311ebfc..483915e 100644 --- a/payments/nas/source.go +++ b/payments/nas/source.go @@ -39,6 +39,7 @@ type ( AvsCheck string `json:"avs_check,omitempty"` CvvCheck string `json:"cvv_check,omitempty"` PaymentAccountReference string `json:"payment_account_reference,omitempty"` + EncryptedCardNumber string `json:"encrypted_card_number,omitempty"` } ResponseCurrencyAccountSource struct { diff --git a/payments/nas/sources/apm/apm.go b/payments/nas/sources/apm/apm.go index 3a3422a..6ec7efb 100644 --- a/payments/nas/sources/apm/apm.go +++ b/payments/nas/sources/apm/apm.go @@ -87,7 +87,8 @@ type ( } requestGiropaySource struct { - Type payments.SourceType `json:"type,omitempty"` + Type payments.SourceType `json:"type,omitempty"` + AccountHolder *common.AccountHolder `json:"account_holder,omitempty"` } requestIdealSource struct { diff --git a/payments/payments.go b/payments/payments.go index 3d86abf..1681582 100644 --- a/payments/payments.go +++ b/payments/payments.go @@ -223,6 +223,18 @@ type ( Delay int `json:"delay,omitempty"` } + PaymentSegment struct { + Brand string `json:"brand,omitempty"` + BusinessCategory string `json:"business_category,omitempty"` + Market string `json:"market,omitempty"` + } + + PaymentRetryRequest struct { + Enabled bool `json:"enabled,omitempty"` + MaxAttempts int `json:"max_attempts,omitempty"` + EndAfterDays int `json:"end_after_days,omitempty"` + } + BillingDescriptor struct { Name string `json:"name,omitempty"` City string `json:"city,omitempty"` @@ -319,6 +331,9 @@ type ( RetrievalReferenceNumber string `json:"retrieval_reference_number,omitempty"` AcquirerTransactionId string `json:"acquirer_transaction_id,omitempty"` RecommendationCode string `json:"recommendation_code,omitempty"` + Scheme string `json:"scheme,omitempty"` + PartnerMerchantAdviceCode string `json:"partner_merchant_advice_code,omitempty"` + PartnerResponseCode string `json:"partner_response_code,omitempty"` PartnerOrderId string `json:"partner_order_id,omitempty"` PartnerSessionId string `json:"partner_session_id,omitempty"` PartnerClientToken string `json:"partner_client_token,omitempty"` @@ -333,6 +348,12 @@ type ( PartnerAuthorizationResponseCode string `json:"partner_authorization_response_code,omitempty"` } + PaymentRetryResponse struct { + MaxAttempts int `json:"max_attempts,omitempty"` + EndsOn *time.Time `json:"ends_on,omitempty"` + NextAttemptOn *time.Time `json:"next_attempt_on,omitempty"` + } + ThreeDsData struct { Downgraded bool `json:"downgraded,omitempty"` Enrolled string `json:"enrolled,omitempty"` diff --git a/test/payments_request_apm_test.go b/test/payments_request_apm_test.go index 5ca8ed1..a1b3f1b 100644 --- a/test/payments_request_apm_test.go +++ b/test/payments_request_apm_test.go @@ -477,7 +477,7 @@ func TestRequestPaymentsAPM(t *testing.T) { assert.Nil(t, response) ckoErr := err.(errors.CheckoutAPIError) assert.Equal(t, http.StatusUnprocessableEntity, ckoErr.StatusCode) - assert.Equal(t, "payment_type_required", ckoErr.Data.ErrorCodes[0]) + assert.Equal(t, "apm_service_unavailable", ckoErr.Data.ErrorCodes[0]) }, }, } @@ -538,7 +538,13 @@ func getEpsSource() payments.PaymentSource { } func getGiropaySource() payments.PaymentSource { + accountHolder := common.AccountHolder{ + FirstName: FirstName, + LastName: LastName, + } + source := apm.NewRequestGiropaySource() + source.AccountHolder = &accountHolder return source }