Skip to content

Commit 51cb07b

Browse files
Update Payment Context And Properties (#101)
- Update payment request for payment contexts - Update giropay source - Update properties and tests
1 parent 7d0728a commit 51cb07b

File tree

5 files changed

+83
-50
lines changed

5 files changed

+83
-50
lines changed

payments/nas/payments.go

+52-48
Original file line numberDiff line numberDiff line change
@@ -82,33 +82,36 @@ type (
8282
// Request
8383
type (
8484
PaymentRequest struct {
85-
Source payments.PaymentSource `json:"source,omitempty"`
86-
Amount int64 `json:"amount,omitempty"`
87-
Currency common.Currency `json:"currency,omitempty"`
88-
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
89-
MerchantInitiated bool `json:"merchant_initiated"`
90-
Reference string `json:"reference,omitempty"`
91-
Description string `json:"description,omitempty"`
92-
AuthorizationType AuthorizationType `json:"authorization_type,omitempty"`
93-
Capture bool `json:"capture"`
94-
CaptureOn *time.Time `json:"capture_on,omitempty"`
95-
Customer *common.CustomerRequest `json:"customer,omitempty"`
96-
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
97-
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
98-
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
99-
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
100-
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
101-
Risk *payments.RiskRequest `json:"risk,omitempty"`
102-
SuccessUrl string `json:"success_url,omitempty"`
103-
FailureUrl string `json:"failure_url,omitempty"`
104-
PaymentIp string `json:"payment_ip,omitempty"`
105-
Sender Sender `json:"sender,omitempty"`
106-
Recipient *payments.PaymentRecipient `json:"recipient,omitempty"`
107-
Marketplace *common.MarketplaceData `json:"marketplace,omitempty"`
108-
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
109-
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
110-
Items []payments.Product `json:"items,omitempty"`
111-
Metadata map[string]interface{} `json:"metadata,omitempty"`
85+
PaymentContextId string `json:"payment_context_id,omitempty"`
86+
Source payments.PaymentSource `json:"source,omitempty"`
87+
Amount int64 `json:"amount,omitempty"`
88+
Currency common.Currency `json:"currency,omitempty"`
89+
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
90+
MerchantInitiated bool `json:"merchant_initiated"`
91+
Reference string `json:"reference,omitempty"`
92+
Description string `json:"description,omitempty"`
93+
AuthorizationType AuthorizationType `json:"authorization_type,omitempty"`
94+
Capture bool `json:"capture"`
95+
CaptureOn *time.Time `json:"capture_on,omitempty"`
96+
Customer *common.CustomerRequest `json:"customer,omitempty"`
97+
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
98+
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
99+
Segment *payments.PaymentSegment `json:"segment,omitempty"`
100+
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
101+
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
102+
ProcessingChannelId string `json:"processing_channel_id,omitempty"`
103+
Risk *payments.RiskRequest `json:"risk,omitempty"`
104+
SuccessUrl string `json:"success_url,omitempty"`
105+
FailureUrl string `json:"failure_url,omitempty"`
106+
PaymentIp string `json:"payment_ip,omitempty"`
107+
Sender Sender `json:"sender,omitempty"`
108+
Recipient *payments.PaymentRecipient `json:"recipient,omitempty"`
109+
Marketplace *common.MarketplaceData `json:"marketplace,omitempty"`
110+
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
111+
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
112+
Items []payments.Product `json:"items,omitempty"`
113+
Retry *payments.PaymentRetryRequest `json:"retry,omitempty"`
114+
Metadata map[string]interface{} `json:"metadata,omitempty"`
112115
}
113116

114117
PayoutRequest struct {
@@ -150,27 +153,28 @@ type (
150153
type (
151154
PaymentResponse struct {
152155
HttpMetadata common.HttpMetadata
153-
ActionId string `json:"action_id,omitempty"`
154-
Amount int64 `json:"amount,omitempty"`
155-
Approved bool `json:"approved,omitempty"`
156-
AuthCode string `json:"auth_code,omitempty"`
157-
Id string `json:"id,omitempty"`
158-
Currency common.Currency `json:"currency,omitempty"`
159-
Customer *common.CustomerResponse `json:"customer,omitempty"`
160-
Source *SourceResponse `json:"source,omitempty"`
161-
Status payments.PaymentStatus `json:"status,omitempty"`
162-
ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"`
163-
Reference string `json:"reference,omitempty"`
164-
ResponseCode string `json:"response_code,omitempty"`
165-
ResponseSummary string `json:"response_summary,omitempty"`
166-
Risk *payments.RiskAssessment `json:"risk,omitempty"`
167-
ProcessedOn *time.Time `json:"processed_on,omitempty"`
168-
ExpiresOn *time.Time `json:"expires_on,omitempty"`
169-
Balances *PaymentResponseBalances `json:"balances,omitempty"`
170-
Processing *payments.PaymentProcessing `json:"processing,omitempty"`
171-
Eci string `json:"eci,omitempty"`
172-
SchemeId string `json:"scheme_id,omitempty"`
173-
Links map[string]common.Link `json:"_links"`
156+
ActionId string `json:"action_id,omitempty"`
157+
Amount int64 `json:"amount,omitempty"`
158+
Approved bool `json:"approved,omitempty"`
159+
AuthCode string `json:"auth_code,omitempty"`
160+
Id string `json:"id,omitempty"`
161+
Currency common.Currency `json:"currency,omitempty"`
162+
Customer *common.CustomerResponse `json:"customer,omitempty"`
163+
Source *SourceResponse `json:"source,omitempty"`
164+
Status payments.PaymentStatus `json:"status,omitempty"`
165+
ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"`
166+
Reference string `json:"reference,omitempty"`
167+
ResponseCode string `json:"response_code,omitempty"`
168+
ResponseSummary string `json:"response_summary,omitempty"`
169+
Risk *payments.RiskAssessment `json:"risk,omitempty"`
170+
ProcessedOn *time.Time `json:"processed_on,omitempty"`
171+
ExpiresOn *time.Time `json:"expires_on,omitempty"`
172+
Balances *PaymentResponseBalances `json:"balances,omitempty"`
173+
Processing *payments.PaymentProcessing `json:"processing,omitempty"`
174+
Eci string `json:"eci,omitempty"`
175+
SchemeId string `json:"scheme_id,omitempty"`
176+
Retry *payments.PaymentRetryResponse `json:"retry,omitempty"`
177+
Links map[string]common.Link `json:"_links"`
174178
}
175179

176180
PayoutResponse struct {

payments/nas/source.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type (
3939
AvsCheck string `json:"avs_check,omitempty"`
4040
CvvCheck string `json:"cvv_check,omitempty"`
4141
PaymentAccountReference string `json:"payment_account_reference,omitempty"`
42+
EncryptedCardNumber string `json:"encrypted_card_number,omitempty"`
4243
}
4344

4445
ResponseCurrencyAccountSource struct {

payments/nas/sources/apm/apm.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ type (
8787
}
8888

8989
requestGiropaySource struct {
90-
Type payments.SourceType `json:"type,omitempty"`
90+
Type payments.SourceType `json:"type,omitempty"`
91+
AccountHolder *common.AccountHolder `json:"account_holder,omitempty"`
9192
}
9293

9394
requestIdealSource struct {

payments/payments.go

+21
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ type (
223223
Delay int `json:"delay,omitempty"`
224224
}
225225

226+
PaymentSegment struct {
227+
Brand string `json:"brand,omitempty"`
228+
BusinessCategory string `json:"business_category,omitempty"`
229+
Market string `json:"market,omitempty"`
230+
}
231+
232+
PaymentRetryRequest struct {
233+
Enabled bool `json:"enabled,omitempty"`
234+
MaxAttempts int `json:"max_attempts,omitempty"`
235+
EndAfterDays int `json:"end_after_days,omitempty"`
236+
}
237+
226238
BillingDescriptor struct {
227239
Name string `json:"name,omitempty"`
228240
City string `json:"city,omitempty"`
@@ -319,6 +331,9 @@ type (
319331
RetrievalReferenceNumber string `json:"retrieval_reference_number,omitempty"`
320332
AcquirerTransactionId string `json:"acquirer_transaction_id,omitempty"`
321333
RecommendationCode string `json:"recommendation_code,omitempty"`
334+
Scheme string `json:"scheme,omitempty"`
335+
PartnerMerchantAdviceCode string `json:"partner_merchant_advice_code,omitempty"`
336+
PartnerResponseCode string `json:"partner_response_code,omitempty"`
322337
PartnerOrderId string `json:"partner_order_id,omitempty"`
323338
PartnerSessionId string `json:"partner_session_id,omitempty"`
324339
PartnerClientToken string `json:"partner_client_token,omitempty"`
@@ -333,6 +348,12 @@ type (
333348
PartnerAuthorizationResponseCode string `json:"partner_authorization_response_code,omitempty"`
334349
}
335350

351+
PaymentRetryResponse struct {
352+
MaxAttempts int `json:"max_attempts,omitempty"`
353+
EndsOn *time.Time `json:"ends_on,omitempty"`
354+
NextAttemptOn *time.Time `json:"next_attempt_on,omitempty"`
355+
}
356+
336357
ThreeDsData struct {
337358
Downgraded bool `json:"downgraded,omitempty"`
338359
Enrolled string `json:"enrolled,omitempty"`

test/payments_request_apm_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ func TestRequestPaymentsAPM(t *testing.T) {
477477
assert.Nil(t, response)
478478
ckoErr := err.(errors.CheckoutAPIError)
479479
assert.Equal(t, http.StatusUnprocessableEntity, ckoErr.StatusCode)
480-
assert.Equal(t, "payment_type_required", ckoErr.Data.ErrorCodes[0])
480+
assert.Equal(t, "apm_service_unavailable", ckoErr.Data.ErrorCodes[0])
481481
},
482482
},
483483
}
@@ -538,7 +538,13 @@ func getEpsSource() payments.PaymentSource {
538538
}
539539

540540
func getGiropaySource() payments.PaymentSource {
541+
accountHolder := common.AccountHolder{
542+
FirstName: FirstName,
543+
LastName: LastName,
544+
}
545+
541546
source := apm.NewRequestGiropaySource()
547+
source.AccountHolder = &accountHolder
542548

543549
return source
544550
}

0 commit comments

Comments
 (0)