Skip to content

Commit b23fc20

Browse files
Update Hosted Payment Page Payment Contexts and tests: (#150)
- Update Hosted Payment Page with latest changes - Update Customer Requests implementations - Enhance Accounts for Account holder implementations - Update tests
1 parent c1d8d26 commit b23fc20

12 files changed

+339
-178
lines changed

accounts/accounts.go

+12-18
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,17 @@ type (
3939

4040
type (
4141
AccountHolder struct {
42-
Type AccountHolderType `json:"type,omitempty"`
43-
FirstName string `json:"first_name,omitempty"`
44-
LastName string `json:"last_name,omitempty"`
45-
CompanyName string `json:"company_name,omitempty"`
46-
TaxId string `json:"tax_id,omitempty"`
47-
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
48-
CountryOfBirth common.Country `json:"country_of_birth,omitempty"`
49-
ResidentialStatus string `json:"residential_status,omitempty"`
50-
BillingAddress *common.Address `json:"billing_address,omitempty"`
51-
Phone *common.Phone `json:"phone,omitempty"`
52-
Identification AccountHolderIdentification `json:"identification,omitempty"`
53-
Email string `json:"email,omitempty"`
54-
}
55-
56-
AccountHolderIdentification struct {
57-
Type common.AccountHolderIdentificationType `json:"type,omitempty"`
58-
Number string `json:"number,omitempty"`
59-
IssuingCountry common.Country `json:"issuing_country,omitempty"`
42+
Type AccountHolderType `json:"type,omitempty"`
43+
FirstName string `json:"first_name,omitempty"`
44+
LastName string `json:"last_name,omitempty"`
45+
CompanyName string `json:"company_name,omitempty"`
46+
TaxId string `json:"tax_id,omitempty"`
47+
DateOfBirth *DateOfBirth `json:"date_of_birth,omitempty"`
48+
CountryOfBirth common.Country `json:"country_of_birth,omitempty"`
49+
ResidentialStatus string `json:"residential_status,omitempty"`
50+
BillingAddress *common.Address `json:"billing_address,omitempty"`
51+
Phone *common.Phone `json:"phone,omitempty"`
52+
Identification *common.AccountHolderIdentification `json:"identification,omitempty"`
53+
Email string `json:"email,omitempty"`
6054
}
6155
)

common/common.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type (
193193
CompanyName string `json:"company_name,omitempty"`
194194
TaxId string `json:"tax_id,omitempty"`
195195
DateOfBirth string `json:"date_of_birth,omitempty"`
196-
CountryOfBirth string `json:"country_of_birth,omitempty"`
196+
CountryOfBirth Country `json:"country_of_birth,omitempty"`
197197
ResidentialStatus string `json:"residential_status,omitempty"`
198198
BillingAddress *Address `json:"billing_address,omitempty"`
199199
Phone *Phone `json:"phone,omitempty"`
@@ -267,7 +267,7 @@ type (
267267

268268
Commission struct {
269269
Amount int64 `json:"amount,omitempty"`
270-
Percentage float32 `json:"percentage,omitempty"`
270+
Percentage float64 `json:"percentage,omitempty"`
271271
}
272272
)
273273

payments/contexts/contexts.go

+31-15
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,38 @@ const (
2020
const PaymentContextsPath = "payment-contexts"
2121

2222
type (
23+
PaymentContextsCustomerSummary struct {
24+
RegistrationDate *time.Time `json:"registration_date,omitempty"`
25+
FirstTransactionDate *time.Time `json:"first_transaction_date,omitempty"`
26+
LastPaymentDate *time.Time `json:"last_payment_date,omitempty"`
27+
TotalOrderCount int64 `json:"total_order_count,omitempty"`
28+
LastPaymentAmount float64 `json:"last_payment_amount,omitempty"`
29+
}
30+
31+
PaymentContextCustomerRequest struct {
32+
EmailVerified bool `json:"email_verified,omitempty"`
33+
Email string `json:"email,omitempty"`
34+
Name string `json:"name,omitempty"`
35+
Phone *common.Phone `json:"phone,omitempty"`
36+
Summary *PaymentContextsCustomerSummary `json:"summary,omitempty"`
37+
}
38+
2339
PaymentContextsRequest struct {
24-
Source payments.PaymentSource `json:"source,omitempty"`
25-
Amount int64 `json:"amount,omitempty"`
26-
Currency common.Currency `json:"currency,omitempty"`
27-
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
28-
AuthorizationType string `json:"authorization_type,omitempty"`
29-
Capture bool `json:"capture,omitempty"`
30-
Customer *common.CustomerRequest `json:"customer,omitempty"`
31-
Shipping *payments.ShippingDetails `json:"shipping,omitempty"`
32-
Processing *PaymentContextsProcessing `json:"processing,omitempty"`
33-
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
34-
Reference string `json:"reference,omitempty"`
35-
Description string `json:"description,omitempty"`
36-
SuccessUrl string `json:"success_url,omitempty"`
37-
FailureUrl string `json:"failure_url,omitempty"`
38-
Items []PaymentContextsItems `json:"items,omitempty"`
40+
Source payments.PaymentSource `json:"source,omitempty"`
41+
Amount int64 `json:"amount,omitempty"`
42+
Currency common.Currency `json:"currency,omitempty"`
43+
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
44+
AuthorizationType string `json:"authorization_type,omitempty"`
45+
Capture bool `json:"capture,omitempty"`
46+
Customer *PaymentContextCustomerRequest `json:"customer,omitempty"`
47+
Shipping *payments.ShippingDetails `json:"shipping,omitempty"`
48+
Processing *PaymentContextsProcessing `json:"processing,omitempty"`
49+
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
50+
Reference string `json:"reference,omitempty"`
51+
Description string `json:"description,omitempty"`
52+
SuccessUrl string `json:"success_url,omitempty"`
53+
FailureUrl string `json:"failure_url,omitempty"`
54+
Items []PaymentContextsItems `json:"items,omitempty"`
3955
}
4056
)
4157

payments/hosted/hosted.go

+50-46
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55

66
"github.com/checkout/checkout-sdk-go/common"
77
"github.com/checkout/checkout-sdk-go/payments"
8+
9+
"github.com/checkout/checkout-sdk-go/payments/nas"
810
)
911

1012
const HostedPaymentsPath = "hosted-payments"
@@ -19,34 +21,37 @@ const (
1921

2022
type (
2123
HostedPaymentRequest struct {
22-
Amount int `json:"amount,omitempty"`
23-
Currency common.Currency `json:"currency,omitempty"`
24-
PaymentType payments.PaymentType `json:"payment_type,omitempty,omitempty"`
25-
PaymentIp string `json:"payment_ip,omitempty"`
26-
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
27-
Reference string `json:"reference,omitempty"`
28-
Description string `json:"description,omitempty"`
29-
DisplayName string `json:"display_name,omitempty"`
30-
Customer *common.CustomerRequest `json:"customer,omitempty"`
31-
Shipping *payments.ShippingDetails `json:"shipping,omitempty"`
32-
Billing *payments.BillingInformation `json:"billing,omitempty"`
33-
Recipient *payments.PaymentRecipient `json:"recipient,omitempty"`
34-
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
35-
AllowPaymentMethods []payments.SourceType `json:"allow_payment_methods,omitempty"`
36-
DisabledPaymentMethods []payments.SourceType `json:"disabled_payment_methods,omitempty"`
37-
Products []payments.Product `json:"products,omitempty"`
38-
Risk *payments.RiskRequest `json:"risk,omitempty"`
39-
SuccessUrl string `json:"success_url,omitempty"`
40-
CancelUrl string `json:"cancel_url,omitempty"`
41-
FailureUrl string `json:"failure_url,omitempty"`
42-
Metadata map[string]interface{} `json:"metadata,omitempty"`
43-
Locale string `json:"locale,omitempty"`
44-
ThreeDs *payments.ThreeDsRequest `json:"3ds,omitempty"`
45-
Capture bool `json:"capture,omitempty"`
46-
CaptureOn *time.Time `json:"capture_on,omitempty"`
47-
//Not available on previous
48-
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
49-
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
24+
Currency common.Currency `json:"currency,omitempty"`
25+
Billing *payments.BillingInformation `json:"billing,omitempty"`
26+
SuccessUrl string `json:"success_url,omitempty"`
27+
CancelUrl string `json:"cancel_url,omitempty"`
28+
FailureUrl string `json:"failure_url,omitempty"`
29+
Amount int `json:"amount,omitempty"`
30+
PaymentType payments.PaymentType `json:"payment_type,omitempty,omitempty"`
31+
PaymentIp string `json:"payment_ip,omitempty"`
32+
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
33+
Reference string `json:"reference,omitempty"`
34+
Description string `json:"description,omitempty"`
35+
DisplayName string `json:"display_name,omitempty"`
36+
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
37+
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
38+
Customer *common.CustomerRequest `json:"customer,omitempty"`
39+
Shipping *payments.ShippingDetails `json:"shipping,omitempty"`
40+
Recipient *payments.PaymentRecipient `json:"recipient,omitempty"`
41+
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
42+
AllowPaymentMethods []payments.SourceType `json:"allow_payment_methods,omitempty"`
43+
DisabledPaymentMethods []payments.SourceType `json:"disabled_payment_methods,omitempty"`
44+
Products []payments.Product `json:"products,omitempty"`
45+
Risk *payments.RiskRequest `json:"risk,omitempty"`
46+
CustomerRetry *payments.PaymentRetryRequest `json:"customer_retry,omitempty"`
47+
Sender *nas.Sender `json:"sender,omitempty"`
48+
Metadata map[string]interface{} `json:"metadata,omitempty"`
49+
Locale payments.LocalType `json:"locale,omitempty"`
50+
ThreeDs *payments.ThreeDsRequest `json:"3ds,omitempty"`
51+
Capture bool `json:"capture,omitempty"`
52+
CaptureOn *time.Time `json:"capture_on,omitempty"`
53+
Instruction *payments.PaymentInstruction `json:"instruction,omitempty"`
54+
PaymentMethodConfiguration *payments.PaymentMethodConfiguration `json:"payment_method_configuration,omitempty"`
5055
}
5156
)
5257

@@ -60,23 +65,22 @@ type (
6065
}
6166

6267
HostedPaymentDetails struct {
63-
HttpMetadata common.HttpMetadata
64-
Id string `json:"id,omitempty"`
65-
Status PaymentStatus `json:"status,omitempty"`
66-
PaymentId string `json:"payment_id,omitempty"`
67-
Amount int `json:"amount,omitempty"`
68-
Currency common.Currency `json:"currency,omitempty"`
69-
Reference string `json:"reference,omitempty"`
70-
Description string `json:"description,omitempty"`
71-
Customer *common.CustomerRequest `json:"customer,omitempty"`
72-
Billing *payments.BillingInformation `json:"billing,omitempty"`
73-
Products []payments.Product `json:"products,omitempty"`
74-
Metadata map[string]interface{} `json:"metadata,omitempty"`
75-
SuccessUrl string `json:"success_url,omitempty"`
76-
CancelUrl string `json:"cancel_url,omitempty"`
77-
FailureUrl string `json:"failure_url,omitempty"`
78-
Links map[string]common.Link `json:"_links"`
79-
//Not available on previous
80-
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
68+
HttpMetadata common.HttpMetadata
69+
Id string `json:"id,omitempty"`
70+
Status PaymentStatus `json:"status,omitempty"`
71+
Amount int `json:"amount,omitempty"`
72+
Currency common.Currency `json:"currency,omitempty"`
73+
Billing *payments.BillingInformation `json:"billing,omitempty"`
74+
SuccessUrl string `json:"success_url,omitempty"`
75+
CancelUrl string `json:"cancel_url,omitempty"`
76+
FailureUrl string `json:"failure_url,omitempty"`
77+
PaymentId string `json:"payment_id,omitempty"`
78+
Reference string `json:"reference,omitempty"`
79+
Description string `json:"description,omitempty"`
80+
Customer *common.CustomerResponse `json:"customer,omitempty"`
81+
Products []payments.Product `json:"products,omitempty"`
82+
Metadata map[string]interface{} `json:"metadata,omitempty"`
83+
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
84+
Links map[string]common.Link `json:"_links"`
8185
}
8286
)

0 commit comments

Comments
 (0)