Skip to content

Commit

Permalink
Update onboard entity request, payment contexts (#104)
Browse files Browse the repository at this point in the history
* Update payment sessions response. Fix tests

* Update payment contexts properties

* Update onboard entity request

* Fix tests
  • Loading branch information
armando-rodriguez-cko authored Mar 15, 2024
1 parent 0f47e52 commit 11f810d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 53 deletions.
39 changes: 21 additions & 18 deletions accounts/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ type (
}

Representative struct {
FirstName string `json:"first_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Address *common.Address `json:"address,omitempty"`
Identification *Identification `json:"identification,omitempty"`
Phone *Phone `json:"phone,omitempty"`
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
PlaceOfBirth *PlaceOfBirth `json:"place_of_birth,omitempty"`
Roles []string `json:"roles,omitempty"`
FirstName string `json:"first_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Address *common.Address `json:"address,omitempty"`
Identification *Identification `json:"identification,omitempty"`
Phone *Phone `json:"phone,omitempty"`
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
PlaceOfBirth *PlaceOfBirth `json:"place_of_birth,omitempty"`
Roles []string `json:"roles,omitempty"`
Documents *OnboardSubEntityDocuments `json:"documents,omitempty"`
}

Identification struct {
Expand Down Expand Up @@ -85,15 +86,16 @@ type (
}

Individual struct {
FirstName string `json:"first_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name,omitempty"`
TradingName string `json:"trading_name,omitempty"`
NationalTaxId string `json:"national_tax_id,omitempty"`
RegisteredAddress *common.Address `json:"registered_address,omitempty"`
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
PlaceOfBirth *PlaceOfBirth `json:"place_of_birth,omitempty"`
Identification *Identification `json:"identification,omitempty"`
FirstName string `json:"first_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name,omitempty"`
TradingName string `json:"trading_name,omitempty"`
NationalTaxId string `json:"national_tax_id,omitempty"`
RegisteredAddress *common.Address `json:"registered_address,omitempty"`
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
PlaceOfBirth *PlaceOfBirth `json:"place_of_birth,omitempty"`
Identification *Identification `json:"identification,omitempty"`
FinancialDetails *EntityFinancialDetails `json:"financial_details,omitempty"`
}

Capabilities struct {
Expand Down Expand Up @@ -133,6 +135,7 @@ type (
AverageTransactionValue int64 `json:"average_transaction_value,omitempty"`
HighestTransactionValue int64 `json:"highest_transaction_value,omitempty"`
Documents *EntityFinancialDocuments `json:"documents,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
}

EntityFinancialDocuments struct {
Expand Down
2 changes: 2 additions & 0 deletions payments/contexts/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ type (
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
AuthorizationType string `json:"authorization_type,omitempty"`
Capture bool `json:"capture,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
Shipping *payments.ShippingDetails `json:"shipping,omitempty"`
Processing *PaymentContextsProcessing `json:"processing,omitempty"`
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
Expand Down
16 changes: 0 additions & 16 deletions payments/sessions/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,9 @@ import (

func TestCreateAPaymentSessions(t *testing.T) {
var (
paymentMethods = PaymentMethods{
Type: "card",
CardSchemes: []string{
"Visa",
},
}
paymentSessionsResponse = PaymentSessionsResponse{
HttpMetadata: mocks.HttpMetadataStatusCreated,
Id: "pct_y3oqhf46pyzuxjbcn2giaqnb44",
Amount: 2000,
Locale: "en-GB",
Currency: common.GBP,
Customer: &common.CustomerRequest{
Email: "[email protected]",
Name: "John Smith",
},
PaymentMethods: []PaymentMethods{
paymentMethods,
},
Links: map[string]common.Link{
"self": {
HRef: &[]string{"https://api.checkout.com/payment-contexts/pct_y3oqhf46pyzuxjbcn2giaqnb44"}[0],
Expand Down
11 changes: 3 additions & 8 deletions payments/sessions/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ type (
}

PaymentSessionsResponse struct {
HttpMetadata common.HttpMetadata
Id string `json:"id,omitempty"`
Amount int64 `json:"amount,omitempty"`
Locale string `json:"locale,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
PaymentMethods []PaymentMethods `json:"payment_methods,omitempty"`
Links map[string]common.Link `json:"links,omitempty"`
HttpMetadata common.HttpMetadata
Id string `json:"id,omitempty"`
Links map[string]common.Link `json:"links,omitempty"`
}
)
4 changes: 0 additions & 4 deletions test/payment_sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ func TestRequestPaymentSessions(t *testing.T) {
assert.NotNil(t, response)
assert.Equal(t, 201, response.HttpMetadata.StatusCode)
assert.NotNil(t, response.Id)
assert.Equal(t, int64(2000), response.Amount)
assert.Equal(t, "en-GB", response.Locale)
assert.Equal(t, common.GBP, response.Currency)
assert.NotNil(t, response.PaymentMethods)
if response.Links != nil {
assert.NotNil(t, response.Links)
}
Expand Down
24 changes: 17 additions & 7 deletions test/payments_request_apm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
"net/http"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -152,12 +153,14 @@ func TestRequestPaymentsAPM(t *testing.T) {
{
name: "test Tamara source for request payment",
request: nas.PaymentRequest{
Source: getTamaraSourceRequest(),
Amount: 1000,
Currency: common.SAR,
Reference: Reference,
Description: Description,
Customer: &customer,
Source: getTamaraSourceRequest(),
Amount: 1000,
Currency: common.GBP,
Capture: true,
Reference: Reference,
Description: Description,
Customer: &customer,
ProcessingChannelId: os.Getenv("CHECKOUT_PROCESSING_CHANNEL_ID"),
Items: []payments.Product{
{
Name: "test item",
Expand Down Expand Up @@ -515,7 +518,14 @@ func getAfterPaySourceRequest() payments.PaymentSource {

func getTamaraSourceRequest() payments.PaymentSource {
source := apm.NewRequestTamaraSource()
source.BillingAddress = Address()
source.BillingAddress = &common.Address{
AddressLine1: "Cecilia Chapman",
AddressLine2: "711-2880 Nulla St.",
City: "Mankato",
State: "Mississippi",
Zip: "96522",
Country: common.GB,
}

return source
}
Expand Down

0 comments on commit 11f810d

Please sign in to comment.