diff --git a/.gitignore b/.gitignore index 01113a4..8ba323f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ pom.xml.asc .cpcache/ # End of https://www.toptal.com/developers/gitignore/api/clojure +/.clj-kondo/.cache/ diff --git a/ChangeLog.md b/ChangeLog.md index 8e801a4..f44c051 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ## +## [0.4.1] - 2024-03-18 ## + +### Fixed ### + +- HTTP error code 429 is not handled properly ([#29](https://github.com/AdGoji/mollie/issues/29)). + ## [0.4.0] - 2024-02-28 ## ### Added ### @@ -94,7 +100,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Mandates management ([#1](https://github.com/AdGoji/mollie/issues/1)). - Subscriptions management ([#1](https://github.com/AdGoji/mollie/issues/1)). -[unreleased]: https://github.com/AdGoji/mollie/compare/0.4.0..HEAD +[unreleased]: https://github.com/AdGoji/mollie/compare/0.4.1..HEAD +[0.4.1]: https://github.com/AdGoji/mollie/compare/0.4.0..0.4.1 [0.4.0]: https://github.com/AdGoji/mollie/compare/0.3.6..0.4.0 [0.3.6]: https://github.com/AdGoji/mollie/compare/0.3.5..0.3.6 [0.3.5]: https://github.com/AdGoji/mollie/compare/0.3.4..0.3.5 diff --git a/build.clj b/build.clj index 2e598f7..ae8c290 100644 --- a/build.clj +++ b/build.clj @@ -4,7 +4,7 @@ [deps-deploy.deps-deploy :as dd])) (def lib 'com.adgoji/mollie) -(def version "0.4.0") +(def version "0.4.1") (def class-dir "target/classes") (def basis (b/create-basis {:project "deps.edn"})) (def jar-file (format "target/%s-%s.jar" (name lib) version)) diff --git a/deps.edn b/deps.edn index e0edb32..6d37a7f 100644 --- a/deps.edn +++ b/deps.edn @@ -1,6 +1,6 @@ {:paths ["src" "spec"] - :deps {org.clojure/clojure {:mvn/version "1.11.1"} + :deps {org.clojure/clojure {:mvn/version "1.11.2"} org.clojure/data.json {:mvn/version "2.5.0"} org.clojure/spec.alpha {:mvn/version "0.4.233"} camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} @@ -23,6 +23,6 @@ "--codecov"]} :build - {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"} + {:deps {io.github.clojure/tools.build {:mvn/version "0.10.0"} slipset/deps-deploy {:mvn/version "0.2.2"}} :ns-default build}}} diff --git a/src/com/adgoji/mollie/api/payments.clj b/src/com/adgoji/mollie/api/payments.clj index d17f670..22e9e0b 100644 --- a/src/com/adgoji/mollie/api/payments.clj +++ b/src/com/adgoji/mollie/api/payments.clj @@ -15,7 +15,8 @@ [com.adgoji.utils.spec :as spec] [com.adgoji.mollie.refund :as refund] [clojure.string :as str] - [com.adgoji.mollie.chargeback :as chargeback]) + [com.adgoji.mollie.chargeback :as chargeback] + [camel-snake-kebab.core :as csk]) (:import (java.time Instant LocalDate))) @@ -72,7 +73,7 @@ card-country-code (assoc ::creditcard/card-country-code card-country-code) card-security (assoc ::creditcard/card-security (keyword card-security)) fee-region (assoc ::creditcard/fee-region fee-region) - failure-reason (assoc ::creditcard/failure-reason (keyword failure-reason)) + failure-reason (assoc ::creditcard/failure-reason (csk/->kebab-case-keyword failure-reason)) failure-message (assoc ::creditcard/failure-message failure-message) wallet (assoc ::creditcard/wallet (keyword wallet)))) diff --git a/src/com/adgoji/mollie/client.clj b/src/com/adgoji/mollie/client.clj index 79f9cb3..0707ee0 100644 --- a/src/com/adgoji/mollie/client.clj +++ b/src/com/adgoji/mollie/client.clj @@ -89,7 +89,7 @@ (404 410) ::anomalies/not-found 405 ::anomalies/unsupported 500 ::anomalies/fault - 503 ::anomalies/busy) + (429 503) ::anomalies/busy) error {::anomalies/category anomaly :error body}] (if throw-exceptions? diff --git a/test/com/adgoji/mollie/api_test.clj b/test/com/adgoji/mollie/api_test.clj index 3f338f8..0f5d8a4 100644 --- a/test/com/adgoji/mollie/api_test.clj +++ b/test/com/adgoji/mollie/api_test.clj @@ -24,15 +24,18 @@ (if-let [customers (->> (sut/get-customers-list utils/*mollie-client* {:limit 50}) ::mollie/customers + (sequence utils/test-customer-xf) seq)] (rand-nth customers) - (sut/create-customer utils/*mollie-client* {:metadata utils/default-metadata}))) + (sut/create-customer utils/*mollie-client* + {:metadata utils/default-metadata}))) (defn- ensure-customer-without-mandate [] (if-let [customers (->> (sut/get-customers-list utils/*mollie-client* {:limit 50}) ::mollie/customers - (sequence (remove ::link/mandates)) + (sequence (comp (remove ::link/mandates) + utils/test-customer-xf)) seq)] (let [customer (rand-nth customers)] (if-not (->> (sut/get-mandates-list utils/*mollie-client* @@ -42,7 +45,8 @@ seq) customer (recur))) - (sut/create-customer utils/*mollie-client* {:metadata utils/default-metadata}))) + (sut/create-customer utils/*mollie-client* + {:metadata utils/default-metadata}))) (defn- ensure-mandate [customer-id] (if-let [mandates (->> (sut/get-mandates-list utils/*mollie-client* diff --git a/test/com/adgoji/mollie/utils.clj b/test/com/adgoji/mollie/utils.clj index d4a247e..e61eb05 100644 --- a/test/com/adgoji/mollie/utils.clj +++ b/test/com/adgoji/mollie/utils.clj @@ -25,9 +25,14 @@ (or (System/getenv "MOLLIE_PROFILE_ID") (:profile-id secrets))) -(def test-purpose "api-client-test") +(defonce test-execution-id (str (random-uuid))) -(def default-metadata {:purpose test-purpose}) +(def default-metadata {:execution-id test-execution-id}) + +(def test-customer-xf + (filter (fn [cus] + (= test-execution-id + (get-in cus [::customer/metadata :execution-id]))))) (def ^:dynamic *mollie-client* nil) @@ -60,8 +65,8 @@ (defn- customers-to-cleaunup [] (->> (mollie.api/get-customers-list *mollie-client* {}) (::mollie/customers) - (sequence (filter (fn [customer] - (= test-purpose (get-in customer [::customer/metadata :purpose]))))))) + (sequence test-customer-xf))) + (defn mollie-cleanup [] (doseq [{customer-id ::customer/id} (customers-to-cleaunup)] (cleanup-payments customer-id)