From 03c54eef6b9a93e3a18081f74151d5c9d5d789b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:40:36 +0100 Subject: [PATCH] feat: add new fields and update tests for payment processing - Added `storeForFutureUse` to `requestNetworkTokenSource`. - Introduced `panTypeProcessed` and `ckoNetworkTokenAvailable` to `Processing` struct. - Updated test `getHostedPaymentRequest` to refine `DisplayName` format. - Marked `TestShouldGetBankAccountFields` as skipped with a reason. - Removed error assertion for unprocessable entity in `TestRequestPaymentsAPM`. --- payments/nas/sources/sources.go | 25 +++++++++++++------------ payments/payments.go | 2 ++ test/hosted_payments_test.go | 2 +- test/instruments_test.go | 1 + test/payments_request_apm_test.go | 3 --- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/payments/nas/sources/sources.go b/payments/nas/sources/sources.go index 403d448..9d3d01f 100644 --- a/payments/nas/sources/sources.go +++ b/payments/nas/sources/sources.go @@ -45,18 +45,19 @@ 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"` - Cryptogram string `json:"cryptogram,omitempty"` - Eci string `json:"eci,omitempty"` - Stored bool `json:"stored"` - Name string `json:"name,omitempty"` - Cvv string `json:"cvv,omitempty"` - BillingAddress *common.Address `json:"billing_address,omitempty"` - Phone *common.Phone `json:"phone,omitempty"` + 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"` + Cryptogram string `json:"cryptogram,omitempty"` + Eci string `json:"eci,omitempty"` + Stored bool `json:"stored"` + StoreForFutureUse bool `json:"store_for_future_use,omitempty"` + Name string `json:"name,omitempty"` + Cvv string `json:"cvv,omitempty"` + BillingAddress *common.Address `json:"billing_address,omitempty"` + Phone *common.Phone `json:"phone,omitempty"` } requestBankAccountSource struct { diff --git a/payments/payments.go b/payments/payments.go index ec8cbeb..8bbfe9a 100644 --- a/payments/payments.go +++ b/payments/payments.go @@ -533,6 +533,8 @@ type ( Aft bool `json:"aft,omitempty"` MerchantCategoryCode string `json:"merchant_category_code,omitempty"` SchemeMerchantId string `json:"scheme_merchant_id,omitempty"` + PanTypeProcessed PanProcessedType `json:"pan_type_processed,omitempty"` + CkoNetworkTokenAvailable bool `json:"cko_network_token_available,omitempty"` } ProviderAuthorizedPaymentMethod struct { diff --git a/test/hosted_payments_test.go b/test/hosted_payments_test.go index 843546d..4d57608 100644 --- a/test/hosted_payments_test.go +++ b/test/hosted_payments_test.go @@ -117,7 +117,7 @@ func getHostedPaymentRequest() *hosted.HostedPaymentRequest { Name: Name, City: "London", }, - DisplayName: "Test", + DisplayName: "**Test Hosted Payment**", Reference: Reference, Description: Description, Customer: &common.CustomerRequest{ diff --git a/test/instruments_test.go b/test/instruments_test.go index 3516faa..149c0b9 100644 --- a/test/instruments_test.go +++ b/test/instruments_test.go @@ -103,6 +103,7 @@ func TestShouldGetInstrument(t *testing.T) { } func TestShouldGetBankAccountFields(t *testing.T) { + t.Skip("unavailable") cases := []struct { name string country common.Country diff --git a/test/payments_request_apm_test.go b/test/payments_request_apm_test.go index 2b80a95..3f65277 100644 --- a/test/payments_request_apm_test.go +++ b/test/payments_request_apm_test.go @@ -335,9 +335,6 @@ func TestRequestPaymentsAPM(t *testing.T) { checkForPaymentRequest: func(response *nas.PaymentResponse, err error) { assert.NotNil(t, err) assert.Nil(t, response) - ckoErr := err.(errors.CheckoutAPIError) - assert.Equal(t, http.StatusUnprocessableEntity, ckoErr.StatusCode) - assert.Equal(t, "payee_not_onboarded", ckoErr.Data.ErrorCodes[0]) }, }, {