From d66577051b9066fc6210a754756a1fc169fa22f7 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Wed, 22 Apr 2020 10:22:59 -0700 Subject: [PATCH 01/11] Updating API versions --- adyen.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adyen.go b/adyen.go index 86c0eef..f102b73 100644 --- a/adyen.go +++ b/adyen.go @@ -17,10 +17,10 @@ const ( DefaultClientTimeout = time.Second * 10 // PaymentAPIVersion - API version of current payment API - PaymentAPIVersion = "v30" + PaymentAPIVersion = "v52" // RecurringAPIVersion - API version of current recurring API - RecurringAPIVersion = "v25" + RecurringAPIVersion = "v49" // PaymentService is used to identify the standard payment workflow. PaymentService = "Payment" @@ -29,7 +29,7 @@ const ( RecurringService = "Recurring" // CheckoutAPIVersion - API version of current checkout API - CheckoutAPIVersion = "v32" + CheckoutAPIVersion = "v52" ) // Adyen - base structure with configuration options From d9df56f5638b0a0196cfb70adb97512823a30c0a Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Thu, 23 Apr 2020 11:04:00 -0700 Subject: [PATCH 02/11] changing module path --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9e174c8..3e1027a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/zhutik/adyen-api-go +module github.com/nirajjayantbolt/adyen-api-go go 1.14 From 8e65a338dbded698a7e8920413e975e1e52fe46c Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Thu, 23 Apr 2020 11:07:58 -0700 Subject: [PATCH 03/11] Revert "changing module path" This reverts commit d9df56f5638b0a0196cfb70adb97512823a30c0a. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3e1027a..9e174c8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nirajjayantbolt/adyen-api-go +module github.com/zhutik/adyen-api-go go 1.14 From b6dcef6e5e54ee38b754ab29b8ed30eee2a3064b Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Thu, 23 Apr 2020 11:48:16 -0700 Subject: [PATCH 04/11] Supporting AVS, CVV and raw versions --- payment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/payment.go b/payment.go index 769d92d..1c1ded6 100644 --- a/payment.go +++ b/payment.go @@ -93,6 +93,10 @@ type AdditionalData struct { FundingSource string `json:"fundingSource,omitempty"` CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen + CVCResult string `json:"cvcResult,omitempty"` + CVCResultRaw string `json:"cvcResultRaw,omitempty"` + AVSResult string `json:"avsResult,omitempty"` + AVSResultRaw string `json:"avsResultRaw,omitempty"` } // BrowserInfo hold information on the user browser From 99ee34a1d9f54e159b50b1949c9b69e90f1e2498 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Fri, 24 Apr 2020 11:45:59 -0700 Subject: [PATCH 05/11] Supporting well-typed AVS responses --- avs.go | 36 ++++++++++++++++++++++++++++++++++++ payment.go | 38 +++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 avs.go diff --git a/avs.go b/avs.go new file mode 100644 index 0000000..a6abaff --- /dev/null +++ b/avs.go @@ -0,0 +1,36 @@ +package adyen + +// AdyenAVSResponse is a type definition for all possible responses from Adyen's AVS system +// +// https://docs.adyen.com/risk-management/avs-checks +type AdyenAVSResponse string + +const ( + AdyenAVSResponse0 AdyenAVSResponse = "0 Unknown" + AdyenAVSResponse1 AdyenAVSResponse = "1 Address matches, but the postal code does not match" + AdyenAVSResponse2 AdyenAVSResponse = "2 Neither postal code nor address match" + AdyenAVSResponse3 AdyenAVSResponse = "3 AVS unavailable" + AdyenAVSResponse4 AdyenAVSResponse = "4 AVS not supported for this card type" + AdyenAVSResponse5 AdyenAVSResponse = "5 No AVS data provided" + AdyenAVSResponse6 AdyenAVSResponse = "6 Postal code matches, but the address does not match" + AdyenAVSResponse7 AdyenAVSResponse = "7 Both postal code and address match" + AdyenAVSResponse8 AdyenAVSResponse = "8 Address not checked, postal code unknown" + AdyenAVSResponse9 AdyenAVSResponse = "9 Address matches, postal code unknown" + AdyenAVSResponse10 AdyenAVSResponse = "10 Address doesn't match, postal code unknown" + AdyenAVSResponse11 AdyenAVSResponse = "11 Postal code not checked, address unknown" + AdyenAVSResponse12 AdyenAVSResponse = "12 Address matches, postal code not checked" + AdyenAVSResponse13 AdyenAVSResponse = "13 Address doesn't match, postal code not checked" + AdyenAVSResponse14 AdyenAVSResponse = "14 Postal code matches, address unknown" + AdyenAVSResponse15 AdyenAVSResponse = "15 Postal code matches, address not checked" + AdyenAVSResponse16 AdyenAVSResponse = "16 Postal code doesn't match, address unknown" + AdyenAVSResponse17 AdyenAVSResponse = "17 Postal code doesn't match, address not checked." + AdyenAVSResponse18 AdyenAVSResponse = "18 Neither postal code nor address were checked" + AdyenAVSResponse19 AdyenAVSResponse = "19 Name and postal code matches" + AdyenAVSResponse20 AdyenAVSResponse = "20 Name, address and postal code matches" + AdyenAVSResponse21 AdyenAVSResponse = "21 Name and address matches" + AdyenAVSResponse22 AdyenAVSResponse = "22 Name matches" + AdyenAVSResponse23 AdyenAVSResponse = "23 Postal code matches, name doesn't match" + AdyenAVSResponse24 AdyenAVSResponse = "24 Both postal code and address matches, name doesn't match" + AdyenAVSResponse25 AdyenAVSResponse = "25 Address matches, name doesn't match" + AdyenAVSResponse26 AdyenAVSResponse = "26 Neither postal code, address nor name matches" +) diff --git a/payment.go b/payment.go index 1c1ded6..baf30b8 100644 --- a/payment.go +++ b/payment.go @@ -78,25 +78,25 @@ type AuthoriseResponse struct { // AdditionalData stores encrypted information about customer's credit card type AdditionalData struct { - Content string `json:"card.encrypted.json,omitempty"` - AliasType string `json:"aliasType,omitempty"` - Alias string `json:"alias,omitempty"` - ExpiryDate string `json:"expiryDate,omitempty"` - CardBin string `json:"cardBin,omitempty"` - CardSummary string `json:"cardSummary,omitempty"` - CardHolderName string `json:"cardHolderName,omitempty"` - PaymentMethod string `json:"paymentMethod,omitempty"` - CardPaymentMethod string `json:"cardPaymentMethod,omitempty"` - CardIssuingCountry string `json:"cardIssuingCountry,omitempty"` - RecurringDetailReference string `json:"recurring.recurringDetailReference,omitempty"` - ExecuteThreeD *StringBool `json:"executeThreeD,omitempty"` - FundingSource string `json:"fundingSource,omitempty"` - CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` - RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen - CVCResult string `json:"cvcResult,omitempty"` - CVCResultRaw string `json:"cvcResultRaw,omitempty"` - AVSResult string `json:"avsResult,omitempty"` - AVSResultRaw string `json:"avsResultRaw,omitempty"` + Content string `json:"card.encrypted.json,omitempty"` + AliasType string `json:"aliasType,omitempty"` + Alias string `json:"alias,omitempty"` + ExpiryDate string `json:"expiryDate,omitempty"` + CardBin string `json:"cardBin,omitempty"` + CardSummary string `json:"cardSummary,omitempty"` + CardHolderName string `json:"cardHolderName,omitempty"` + PaymentMethod string `json:"paymentMethod,omitempty"` + CardPaymentMethod string `json:"cardPaymentMethod,omitempty"` + CardIssuingCountry string `json:"cardIssuingCountry,omitempty"` + RecurringDetailReference string `json:"recurring.recurringDetailReference,omitempty"` + ExecuteThreeD *StringBool `json:"executeThreeD,omitempty"` + FundingSource string `json:"fundingSource,omitempty"` + CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` + RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen + CVCResult string `json:"cvcResult,omitempty"` + CVCResultRaw string `json:"cvcResultRaw,omitempty"` + AVSResult AdyenAVSResponse `json:"avsResult,omitempty"` + AVSResultRaw string `json:"avsResultRaw,omitempty"` } // BrowserInfo hold information on the user browser From 06b93a606f77e3d36ff1c9c6c233502895b38ecc Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Fri, 24 Apr 2020 11:50:29 -0700 Subject: [PATCH 06/11] Fixing codeclimate issues --- avs.go | 59 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/avs.go b/avs.go index a6abaff..034d6a1 100644 --- a/avs.go +++ b/avs.go @@ -1,36 +1,37 @@ package adyen -// AdyenAVSResponse is a type definition for all possible responses from Adyen's AVS system +// AVSResponse is a type definition for all possible responses from Adyen's AVS system // // https://docs.adyen.com/risk-management/avs-checks -type AdyenAVSResponse string +type AVSResponse string +// AVSResponse hard-coded for easy comparison checking later const ( - AdyenAVSResponse0 AdyenAVSResponse = "0 Unknown" - AdyenAVSResponse1 AdyenAVSResponse = "1 Address matches, but the postal code does not match" - AdyenAVSResponse2 AdyenAVSResponse = "2 Neither postal code nor address match" - AdyenAVSResponse3 AdyenAVSResponse = "3 AVS unavailable" - AdyenAVSResponse4 AdyenAVSResponse = "4 AVS not supported for this card type" - AdyenAVSResponse5 AdyenAVSResponse = "5 No AVS data provided" - AdyenAVSResponse6 AdyenAVSResponse = "6 Postal code matches, but the address does not match" - AdyenAVSResponse7 AdyenAVSResponse = "7 Both postal code and address match" - AdyenAVSResponse8 AdyenAVSResponse = "8 Address not checked, postal code unknown" - AdyenAVSResponse9 AdyenAVSResponse = "9 Address matches, postal code unknown" - AdyenAVSResponse10 AdyenAVSResponse = "10 Address doesn't match, postal code unknown" - AdyenAVSResponse11 AdyenAVSResponse = "11 Postal code not checked, address unknown" - AdyenAVSResponse12 AdyenAVSResponse = "12 Address matches, postal code not checked" - AdyenAVSResponse13 AdyenAVSResponse = "13 Address doesn't match, postal code not checked" - AdyenAVSResponse14 AdyenAVSResponse = "14 Postal code matches, address unknown" - AdyenAVSResponse15 AdyenAVSResponse = "15 Postal code matches, address not checked" - AdyenAVSResponse16 AdyenAVSResponse = "16 Postal code doesn't match, address unknown" - AdyenAVSResponse17 AdyenAVSResponse = "17 Postal code doesn't match, address not checked." - AdyenAVSResponse18 AdyenAVSResponse = "18 Neither postal code nor address were checked" - AdyenAVSResponse19 AdyenAVSResponse = "19 Name and postal code matches" - AdyenAVSResponse20 AdyenAVSResponse = "20 Name, address and postal code matches" - AdyenAVSResponse21 AdyenAVSResponse = "21 Name and address matches" - AdyenAVSResponse22 AdyenAVSResponse = "22 Name matches" - AdyenAVSResponse23 AdyenAVSResponse = "23 Postal code matches, name doesn't match" - AdyenAVSResponse24 AdyenAVSResponse = "24 Both postal code and address matches, name doesn't match" - AdyenAVSResponse25 AdyenAVSResponse = "25 Address matches, name doesn't match" - AdyenAVSResponse26 AdyenAVSResponse = "26 Neither postal code, address nor name matches" + AVSResponse0 AVSResponse = "0 Unknown" + AVSResponse1 AVSResponse = "1 Address matches, but the postal code does not match" + AVSResponse2 AVSResponse = "2 Neither postal code nor address match" + AVSResponse3 AVSResponse = "3 AVS unavailable" + AVSResponse4 AVSResponse = "4 AVS not supported for this card type" + AVSResponse5 AVSResponse = "5 No AVS data provided" + AVSResponse6 AVSResponse = "6 Postal code matches, but the address does not match" + AVSResponse7 AVSResponse = "7 Both postal code and address match" + AVSResponse8 AVSResponse = "8 Address not checked, postal code unknown" + AVSResponse9 AVSResponse = "9 Address matches, postal code unknown" + AVSResponse10 AVSResponse = "10 Address doesn't match, postal code unknown" + AVSResponse11 AVSResponse = "11 Postal code not checked, address unknown" + AVSResponse12 AVSResponse = "12 Address matches, postal code not checked" + AVSResponse13 AVSResponse = "13 Address doesn't match, postal code not checked" + AVSResponse14 AVSResponse = "14 Postal code matches, address unknown" + AVSResponse15 AVSResponse = "15 Postal code matches, address not checked" + AVSResponse16 AVSResponse = "16 Postal code doesn't match, address unknown" + AVSResponse17 AVSResponse = "17 Postal code doesn't match, address not checked." + AVSResponse18 AVSResponse = "18 Neither postal code nor address were checked" + AVSResponse19 AVSResponse = "19 Name and postal code matches" + AVSResponse20 AVSResponse = "20 Name, address and postal code matches" + AVSResponse21 AVSResponse = "21 Name and address matches" + AVSResponse22 AVSResponse = "22 Name matches" + AVSResponse23 AVSResponse = "23 Postal code matches, name doesn't match" + AVSResponse24 AVSResponse = "24 Both postal code and address matches, name doesn't match" + AVSResponse25 AVSResponse = "25 Address matches, name doesn't match" + AVSResponse26 AVSResponse = "26 Neither postal code, address nor name matches" ) From 529d5d0a06f87cdecb59578af4ff0b252b8c1df8 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Fri, 24 Apr 2020 13:00:19 -0700 Subject: [PATCH 07/11] Using new name --- payment.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/payment.go b/payment.go index baf30b8..e18ab94 100644 --- a/payment.go +++ b/payment.go @@ -78,25 +78,25 @@ type AuthoriseResponse struct { // AdditionalData stores encrypted information about customer's credit card type AdditionalData struct { - Content string `json:"card.encrypted.json,omitempty"` - AliasType string `json:"aliasType,omitempty"` - Alias string `json:"alias,omitempty"` - ExpiryDate string `json:"expiryDate,omitempty"` - CardBin string `json:"cardBin,omitempty"` - CardSummary string `json:"cardSummary,omitempty"` - CardHolderName string `json:"cardHolderName,omitempty"` - PaymentMethod string `json:"paymentMethod,omitempty"` - CardPaymentMethod string `json:"cardPaymentMethod,omitempty"` - CardIssuingCountry string `json:"cardIssuingCountry,omitempty"` - RecurringDetailReference string `json:"recurring.recurringDetailReference,omitempty"` - ExecuteThreeD *StringBool `json:"executeThreeD,omitempty"` - FundingSource string `json:"fundingSource,omitempty"` - CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` - RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen - CVCResult string `json:"cvcResult,omitempty"` - CVCResultRaw string `json:"cvcResultRaw,omitempty"` - AVSResult AdyenAVSResponse `json:"avsResult,omitempty"` - AVSResultRaw string `json:"avsResultRaw,omitempty"` + Content string `json:"card.encrypted.json,omitempty"` + AliasType string `json:"aliasType,omitempty"` + Alias string `json:"alias,omitempty"` + ExpiryDate string `json:"expiryDate,omitempty"` + CardBin string `json:"cardBin,omitempty"` + CardSummary string `json:"cardSummary,omitempty"` + CardHolderName string `json:"cardHolderName,omitempty"` + PaymentMethod string `json:"paymentMethod,omitempty"` + CardPaymentMethod string `json:"cardPaymentMethod,omitempty"` + CardIssuingCountry string `json:"cardIssuingCountry,omitempty"` + RecurringDetailReference string `json:"recurring.recurringDetailReference,omitempty"` + ExecuteThreeD *StringBool `json:"executeThreeD,omitempty"` + FundingSource string `json:"fundingSource,omitempty"` + CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` + RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen + CVCResult string `json:"cvcResult,omitempty"` + CVCResultRaw string `json:"cvcResultRaw,omitempty"` + AVSResult AVSResponse `json:"avsResult,omitempty"` + AVSResultRaw string `json:"avsResultRaw,omitempty"` } // BrowserInfo hold information on the user browser From 5d1d40bcce404e838cf4639dd479992f241db256 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Sat, 25 Apr 2020 18:47:17 -0700 Subject: [PATCH 08/11] Supporting well typed cvc results --- cvv.go | 17 +++++++++++++++++ payment.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 cvv.go diff --git a/cvv.go b/cvv.go new file mode 100644 index 0000000..00a3f6f --- /dev/null +++ b/cvv.go @@ -0,0 +1,17 @@ +package adyen + +// CVCResult represents the Adyen translation of CVC codes from issuer +// https://docs.adyen.com/development-resources/test-cards/cvc-cvv-result-testing +type CVCResult string +// Constants represented by numerical code they are assigned +const ( + CVCResult0 CVCResult = "0 Unknown" + CVCResult1 CVCResult = "1 Matches" + CVCResult2 CVCResult = "2 Doesn't Match" + CVCResult3 CVCResult = "3 Not Checked" + CVCResult4 CVCResult = "4 No CVC/CVV provided, but was required" + CVCResult5 CVCResult = "5 Issuer not certified for CVC/CVV" + CVCResult6 CVCResult = "6 No CVC/CVV provided" +) + + diff --git a/payment.go b/payment.go index e18ab94..87b6702 100644 --- a/payment.go +++ b/payment.go @@ -93,7 +93,7 @@ type AdditionalData struct { FundingSource string `json:"fundingSource,omitempty"` CustomRoutingFlag string `json:"customRoutingFlag,omitempty"` RequestedTestAcquirerResponseCode int `json:"RequestedTestAcquirerResponseCode,omitempty"` //Used for trigger error from adyen - CVCResult string `json:"cvcResult,omitempty"` + CVCResult CVCResult `json:"cvcResult,omitempty"` CVCResultRaw string `json:"cvcResultRaw,omitempty"` AVSResult AVSResponse `json:"avsResult,omitempty"` AVSResultRaw string `json:"avsResultRaw,omitempty"` From d60958b1d31eee4f8ee09a5f8414eaecaf3409a0 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Mon, 27 Apr 2020 13:23:02 -0700 Subject: [PATCH 09/11] Updating AVS Code 1 --- avs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avs.go b/avs.go index 034d6a1..cf6e802 100644 --- a/avs.go +++ b/avs.go @@ -8,7 +8,7 @@ type AVSResponse string // AVSResponse hard-coded for easy comparison checking later const ( AVSResponse0 AVSResponse = "0 Unknown" - AVSResponse1 AVSResponse = "1 Address matches, but the postal code does not match" + AVSResponse1 AVSResponse = "1 Address matches, postal code doesn't" AVSResponse2 AVSResponse = "2 Neither postal code nor address match" AVSResponse3 AVSResponse = "3 AVS unavailable" AVSResponse4 AVSResponse = "4 AVS not supported for this card type" From 937d8ecc365ff5d020af0e1acfab2e61cedcc4e9 Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Tue, 5 May 2020 11:56:22 -0700 Subject: [PATCH 10/11] go fmt --- cvv.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cvv.go b/cvv.go index 00a3f6f..bd487f1 100644 --- a/cvv.go +++ b/cvv.go @@ -3,6 +3,7 @@ package adyen // CVCResult represents the Adyen translation of CVC codes from issuer // https://docs.adyen.com/development-resources/test-cards/cvc-cvv-result-testing type CVCResult string + // Constants represented by numerical code they are assigned const ( CVCResult0 CVCResult = "0 Unknown" @@ -13,5 +14,3 @@ const ( CVCResult5 CVCResult = "5 Issuer not certified for CVC/CVV" CVCResult6 CVCResult = "6 No CVC/CVV provided" ) - - From e7a5332562182607ed4e8c718b39179267debc2e Mon Sep 17 00:00:00 2001 From: Niraj Jayant Date: Thu, 7 May 2020 11:52:41 -0700 Subject: [PATCH 11/11] More additional data --- notification.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/notification.go b/notification.go index 49506c8..b1371b5 100644 --- a/notification.go +++ b/notification.go @@ -30,6 +30,13 @@ type NotificationRequestItemData struct { AuthorisedAmountValue string `json:"authorisedAmountValue,omitempty"` AuthorisedAmountCurrency string `json:"authorisedAmountCurrency,omitempty"` HmacSignature string `json:"hmacSignature,omitempty"` + NOFReasonCode string `json:"nofReasonCode,omitempty"` + NOFSchemeCode string `json:"nofSchemeCode,omitempty"` + RFIReasonCode string `json:"rfiReasonCode,omitempty"` + RFISchemeCode string `json:"rfiSchemeCode,omitempty"` + ChargebackReasonCode string `json:"chargebackReasonCode,omitempty"` + ChargebackSchemeCode string `json:"chargebackSchemeCode,omitempty"` + ARN string `json:"arn,omitempty"` } `json:"additionalData,omitempty"` Amount Amount `json:"amount"` PspReference string `json:"pspReference"`