diff --git a/ChangeLog.md b/ChangeLog.md index 23ea666..66572db 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ## +## [0.5.0] - 2024-12-16 ## + +### Added ### + +- PayPal support ([#37](https://github.com/AdGoji/mollie/issues/37)). +- Bank transfers support ([#39](https://github.com/AdGoji/mollie/issues/39)). + ## [0.4.4] - 2024-11-14 ## ### Fixed ### @@ -118,7 +125,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.4..HEAD +[unreleased]: https://github.com/AdGoji/mollie/compare/0.5.0..HEAD +[0.5.0]: https://github.com/AdGoji/mollie/compare/0.4.4..0.5.0 [0.4.4]: https://github.com/AdGoji/mollie/compare/0.4.3..0.4.4 [0.4.3]: https://github.com/AdGoji/mollie/compare/0.4.2..0.4.3 [0.4.2]: https://github.com/AdGoji/mollie/compare/0.4.1..0.4.2 diff --git a/build.clj b/build.clj index 74153f9..25d0575 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.4") +(def version "0.5.0") (def class-dir "target/classes") (def basis (b/create-basis {:project "deps.edn"})) (def jar-file (format "target/%s-%s.jar" (name lib) version)) @@ -22,8 +22,8 @@ :basis basis :src-dirs ["src" "spec"] :scm {:tag version - :connection (str "scm:git:git://github.com/adgoji/mollie") - :developerConnection (str "scm:git:ssh://git@github.com:adgoji/mollie.git") + :connection "scm:git:git://github.com/adgoji/mollie" + :developerConnection "scm:git:ssh://git@github.com:adgoji/mollie.git" :url "https://github.com/adgoji/mollie"} :pom-data [[:licenses [:license diff --git a/deps.edn b/deps.edn index acffbda..c6dc253 100644 --- a/deps.edn +++ b/deps.edn @@ -1,7 +1,7 @@ {:paths ["src" "spec"] :deps {org.clojure/clojure {:mvn/version "1.12.0"} - org.clojure/data.json {:mvn/version "2.5.0"} + org.clojure/data.json {:mvn/version "2.5.1"} org.clojure/spec.alpha {:mvn/version "0.5.238"} camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} hato/hato {:mvn/version "1.0.0"} @@ -23,6 +23,6 @@ "--codecov"]} :build - {:deps {io.github.clojure/tools.build {:mvn/version "0.10.5"} + {:deps {io.github.clojure/tools.build {:mvn/version "0.10.6"} slipset/deps-deploy {:mvn/version "0.2.2"}} :ns-default build}}} diff --git a/spec/com/adgoji/mollie.clj b/spec/com/adgoji/mollie.clj index 154efdc..f763952 100644 --- a/spec/com/adgoji/mollie.clj +++ b/spec/com/adgoji/mollie.clj @@ -13,7 +13,8 @@ [com.adgoji.common :as common] [com.adgoji.mollie.ideal :as ideal] [com.adgoji.mollie.refund :as refund] - [com.adgoji.mollie.chargeback :as chargeback])) + [com.adgoji.mollie.chargeback :as chargeback] + [com.adgoji.mollie.banktransfer :as banktransfer])) ;;; Customer @@ -294,6 +295,118 @@ ::link/subscription ::link/customer])) +(defmethod payment-spec :paypal + [_] + (common/only-keys :req [::payment/resource + ::payment/id + ::payment/mode + ::payment/created-at + ::payment/status + ::payment/amount + ::payment/description + ::payment/redirect-url + ::payment/method + ::payment/profile-id + ::link/self + ::link/dashboard + ::link/documentation] + :opt [::payment/is-cancelable + ::payment/authorized-at + ::payment/paid-at + ::payment/canceled-at + ::payment/expires-at + ::payment/expired-at + ::payment/failed-at + ::payment/amount-refunded + ::payment/amount-remaining + ::payment/amount-captured + ::payment/amount-charged-back + ::payment/settlement-amount + ::payment/cancel-url + ::payment/webhook-url + ::payment/locale + ::payment/country-code + ::payment/restrict-payment-methods-to-country + ::payment/metadata + ::payment/settlement-id + ::payment/order-id + ::payment/sequence-type + ::payment/customer-id + ::payment/mandate-id + ::payment/subscription-id + ::embedded + ::paypal/paypal-reference + ::paypal/paypal-payer-id + ::paypal/seller-protection + ::paypal/paypal-fee + ::link/checkout + ::link/mobile-app-checkout + ::link/refunds + ::link/chargebacks + ::link/captures + ::link/settlement + ::link/order + ::link/change-payment-state + ::link/mandate + ::link/subscription + ::link/customer])) + +(defmethod payment-spec :banktransfer + [_] + (common/only-keys :req [::payment/resource + ::payment/id + ::payment/mode + ::payment/created-at + ::payment/status + ::payment/amount + ::payment/description + ::payment/redirect-url + ::payment/method + ::payment/profile-id + ::link/self + ::link/dashboard + ::link/documentation] + :opt [::payment/is-cancelable + ::payment/authorized-at + ::payment/paid-at + ::payment/canceled-at + ::payment/expires-at + ::payment/expired-at + ::payment/failed-at + ::payment/amount-refunded + ::payment/amount-remaining + ::payment/amount-captured + ::payment/amount-charged-back + ::payment/settlement-amount + ::payment/cancel-url + ::payment/webhook-url + ::payment/locale + ::payment/country-code + ::payment/restrict-payment-methods-to-country + ::payment/metadata + ::payment/settlement-id + ::payment/order-id + ::payment/sequence-type + ::payment/customer-id + ::payment/mandate-id + ::payment/subscription-id + ::embedded + ::banktransfer/bank-account + ::banktransfer/bank-bic + ::banktransfer/bank-name + ::banktransfer/transfer-reference + ::link/checkout + ::link/mobile-app-checkout + ::link/refunds + ::link/chargebacks + ::link/captures + ::link/settlement + ::link/order + ::link/change-payment-state + ::link/mandate + ::link/subscription + ::link/customer])) + (defmethod payment-spec nil [_] (common/only-keys :req [::payment/resource diff --git a/spec/com/adgoji/mollie/banktransfer.clj b/spec/com/adgoji/mollie/banktransfer.clj new file mode 100644 index 0000000..58a95a0 --- /dev/null +++ b/spec/com/adgoji/mollie/banktransfer.clj @@ -0,0 +1,8 @@ +(ns com.adgoji.mollie.banktransfer + (:require + [clojure.spec.alpha :as s])) + +(s/def ::bank-name string?) +(s/def ::bank-account string?) +(s/def ::bank-bic string?) +(s/def ::transfer-reference string?) diff --git a/spec/com/adgoji/mollie/payment/request.clj b/spec/com/adgoji/mollie/payment/request.clj index 0585139..7bb9fec 100644 --- a/spec/com/adgoji/mollie/payment/request.clj +++ b/spec/com/adgoji/mollie/payment/request.clj @@ -4,7 +4,8 @@ [com.adgoji.common :as common] [com.adgoji.mollie.amount :as amount] [com.adgoji.mollie.customer :as customer] - [com.adgoji.mollie.mandate :as mandate]) + [com.adgoji.mollie.mandate :as mandate] + [com.adgoji.mollie.paypal :as paypal]) (:import (java.time LocalDate))) @@ -53,7 +54,9 @@ ::issuer ::billing-email ::due-date - ::profile-id])) + ::profile-id + ::paypal/session-id + ::paypal/digital-goods])) (defmulti create-spec :sequence-type) @@ -81,7 +84,9 @@ ::issuer ::billing-email ::due-date - ::profile-id])) + ::profile-id + ::paypal/session-id + ::paypal/digital-goods])) (defmethod create-spec :recurring [_] @@ -100,7 +105,9 @@ ::issuer ::billing-email ::due-date - ::profile-id])) + ::profile-id + ::paypal/session-id + ::paypal/digital-goods])) (s/def ::create (s/multi-spec create-spec :sequence-type)) diff --git a/spec/com/adgoji/mollie/paypal.clj b/spec/com/adgoji/mollie/paypal.clj index 00f6e05..aebfefc 100644 --- a/spec/com/adgoji/mollie/paypal.clj +++ b/spec/com/adgoji/mollie/paypal.clj @@ -1,6 +1,13 @@ (ns com.adgoji.mollie.paypal (:require - [clojure.spec.alpha :as s])) + [clojure.spec.alpha :as s] + [com.adgoji.mollie.amount :as amount])) (s/def ::consumer-name string?) (s/def ::consumer-account string?) +(s/def ::session-id string?) +(s/def ::digital-goods boolean?) +(s/def ::paypal-reference string?) +(s/def ::paypal-payer-id string?) +(s/def ::seller-protection string?) +(s/def ::paypal-fee (s/keys :req [::amount/currency ::amount/value])) diff --git a/src/com/adgoji/mollie/api/payments.clj b/src/com/adgoji/mollie/api/payments.clj index 22e9e0b..e08064e 100644 --- a/src/com/adgoji/mollie/api/payments.clj +++ b/src/com/adgoji/mollie/api/payments.clj @@ -16,7 +16,9 @@ [com.adgoji.mollie.refund :as refund] [clojure.string :as str] [com.adgoji.mollie.chargeback :as chargeback] - [camel-snake-kebab.core :as csk]) + [camel-snake-kebab.core :as csk] + [com.adgoji.mollie.paypal :as paypal] + [com.adgoji.mollie.banktransfer :as banktransfer]) (:import (java.time Instant LocalDate))) @@ -86,6 +88,28 @@ consumer-account (assoc ::ideal/consumer-account consumer-account) consumer-bic (assoc ::ideal/consumer-bic consumer-bic))) +(defmethod get-details :paypal + [{{:keys [paypal-reference + paypal-payer-id + seller-protection + paypal-fee]} :details}] + (cond-> {} + paypal-reference (assoc ::paypal/paypal-reference paypal-reference) + paypal-payer-id (assoc ::paypal/paypal-payer-id paypal-payer-id) + seller-protection (assoc ::paypal/seller-protection seller-protection) + paypal-fee (assoc ::paypal/paypal-fee (spec/qualify-amount paypal-fee)))) + +(defmethod get-details :banktransfer + [{{:keys [bank-account + bank-bic + bank-name + transfer-reference]} :details}] + (cond-> {} + bank-account (assoc ::banktransfer/bank-account bank-account) + bank-bic (assoc ::banktransfer/bank-bic bank-bic) + bank-name (assoc ::banktransfer/bank-name bank-name) + transfer-reference (assoc ::banktransfer/transfer-reference transfer-reference))) + (defmethod get-details ::default [{:keys [method]}] (throw (ex-info "Payment method is not supported"