Skip to content

Commit

Permalink
Add Mollie Recurring
Browse files Browse the repository at this point in the history
  • Loading branch information
Daan van Marsbergen committed May 10, 2016
1 parent 4affa24 commit 754f2ea
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

All notable changes to this project will be documented in this file.


#### v1.3.0 - 2016-04-14
- Added Mandates API.
- Added `recurringType` and `mandateId` to Payments API.

#### v1.2.2 - 2016-03-21
- The members `customers` and `customers_payments` weren't made public within `attr_reader` ([#21](https://github.com/mollie/mollie-api-ruby/pull/21)).
- Updated the bundled CA's cacert.pem file to date `Jan 20, 2016`.
5 changes: 4 additions & 1 deletion lib/Mollie/API/Client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
"Resource/Base",
"Resource/Customers",
"Resource/Customers/Payments",
"Resource/Customers/Mandates",
"Resource/Payments",
"Resource/Payments/Refunds",
"Resource/Issuers",
"Resource/Methods",
"Object/Base",
"Object/List",
"Object/Customer",
"Object/Mandate",
"Object/Payment",
"Object/Payment/Refund",
"Object/Issuer",
Expand All @@ -24,7 +26,7 @@ class Client
API_ENDPOINT = "https://api.mollie.nl"
API_VERSION = "v1"

attr_reader :payments, :issuers, :methods, :payments_refunds, :customers, :customers_payments
attr_reader :payments, :issuers, :methods, :payments_refunds, :customers, :customers_payments, :customers_mandates

def initialize
@payments = Mollie::API::Resource::Payments.new self
Expand All @@ -33,6 +35,7 @@ def initialize
@payments_refunds = Mollie::API::Resource::Payments::Refunds.new self
@customers = Mollie::API::Resource::Customers.new self
@customers_payments = Mollie::API::Resource::Customers::Payments.new self
@customers_mandates = Mollie::API::Resource::Customers::Mandates.new self

@api_endpoint = API_ENDPOINT
@api_key = ""
Expand Down
2 changes: 1 addition & 1 deletion lib/Mollie/API/Client/Version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Mollie
module API
class Client
CLIENT_VERSION = "1.2.2"
CLIENT_VERSION = "1.3.0"
end
end
end
22 changes: 22 additions & 0 deletions lib/Mollie/API/Object/Mandate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Mollie
module API
module Object
class Mandate < Base
STATUS_VALID = "valid"
STATUS_INVALID = "invalid"

attr_accessor :resource,
:id,
:status,
:method,
:customerId,
:details,
:createdDatetime

def valid?
@status == STATUS_VALID
end
end
end
end
end
9 changes: 9 additions & 0 deletions lib/Mollie/API/Object/Payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class Payment < Base
STATUS_EXPIRED = "expired"
STATUS_PAID = "paid"
STATUS_PAIDOUT = "paidout"
STATUS_FAILED = "failed"

RECURRINGTYPE_NONE = nil
RECURRINGTYPE_FIRST = "first"
RECURRINGTYPE_RECURRING = "recurring"

attr_accessor :id,
:status,
Expand All @@ -18,6 +23,10 @@ class Payment < Base
:paidDatetime,
:expiredDatetime,
:cancelledDatetime,
:customerId,
:recurringType,
:mandateId,
:settlementId,
:metadata,
:details,
:links
Expand Down
27 changes: 27 additions & 0 deletions lib/Mollie/API/Resource/Customers/Mandates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'open-uri'

module Mollie
module API
module Resource
class Customers
class Mandates < Base
@customer_id = nil

def getResourceObject
Mollie::API::Object::Mandate
end

def getResourceName
customer_id = URI::encode(@customer_id)
"customers/#{customer_id}/mandates"
end

def with(customer)
@customer_id = customer.id
self
end
end
end
end
end
end

0 comments on commit 754f2ea

Please sign in to comment.