simplify 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simplify.rb +41 -0
- data/lib/simplify/apiexception.rb +160 -0
- data/lib/simplify/cardtoken.rb +102 -0
- data/lib/simplify/chargeback.rb +95 -0
- data/lib/simplify/constants.rb +56 -0
- data/lib/simplify/coupon.rb +143 -0
- data/lib/simplify/customer.rb +169 -0
- data/lib/simplify/deposit.rb +95 -0
- data/lib/simplify/event.rb +65 -0
- data/lib/simplify/invoice.rb +105 -0
- data/lib/simplify/invoiceitem.rb +140 -0
- data/lib/simplify/payment.rb +133 -0
- data/lib/simplify/paymentsapi.rb +411 -0
- data/lib/simplify/plan.rb +138 -0
- data/lib/simplify/refund.rb +120 -0
- data/lib/simplify/subscription.rb +149 -0
- data/lib/simplify/webhook.rb +135 -0
- metadata +113 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, MasterCard International Incorporated
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification, are
|
6
|
+
# permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice, this list of
|
9
|
+
# conditions and the following disclaimer.
|
10
|
+
# Redistributions in binary form must reproduce the above copyright notice, this list of
|
11
|
+
# conditions and the following disclaimer in the documentation and/or other materials
|
12
|
+
# provided with the distribution.
|
13
|
+
# Neither the name of the MasterCard International Incorporated nor the names of its
|
14
|
+
# contributors may be used to endorse or promote products derived from this software
|
15
|
+
# without specific prior written permission.
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
17
|
+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
19
|
+
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
22
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
23
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
24
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
+
# SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'simplify/paymentsapi'
|
29
|
+
|
30
|
+
module Simplify
|
31
|
+
|
32
|
+
# A Coupon object.
|
33
|
+
#
|
34
|
+
class Coupon < Hash
|
35
|
+
|
36
|
+
# Public key used to access the API.
|
37
|
+
attr_accessor :public_key
|
38
|
+
|
39
|
+
# Private key used to access the API.
|
40
|
+
attr_accessor :private_key
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
# Creates an Coupon object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>amountOff</code> Amount off of the price of the product in minor units in the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 1000 = 10.00
|
48
|
+
# * <code>couponCode</code> Code that identifies the coupon to be used. <b>required </b>
|
49
|
+
# * <code>description</code> A brief section that describes the coupon.
|
50
|
+
# * <code>durationInMonths</code> Duration in months that the coupon will be applied after it has first been selected.
|
51
|
+
# * <code>endDate</code> Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
|
52
|
+
# * <code>maxRedemptions</code> Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
|
53
|
+
# * <code>percentOff</code> Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number.
|
54
|
+
# * <code>startDate</code> First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. <b>required </b>
|
55
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
56
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
57
|
+
# Returns a Coupon object.
|
58
|
+
def self.create(parms, public_key = nil, private_key = nil)
|
59
|
+
if public_key == nil then
|
60
|
+
public_key = Simplify::public_key
|
61
|
+
end
|
62
|
+
if private_key == nil then
|
63
|
+
private_key = Simplify::private_key
|
64
|
+
end
|
65
|
+
|
66
|
+
h = Simplify::PaymentsApi.execute("coupon", 'create', parms, public_key, private_key)
|
67
|
+
obj = Coupon.new()
|
68
|
+
obj.public_key = public_key
|
69
|
+
obj.private_key = private_key
|
70
|
+
obj = obj.merge(h)
|
71
|
+
obj
|
72
|
+
end
|
73
|
+
|
74
|
+
# Delete this object
|
75
|
+
def delete()
|
76
|
+
h = Simplify::PaymentsApi.execute("coupon", 'delete', self, self.public_key, self.private_key)
|
77
|
+
self.merge!(h)
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
# Retrieve Coupon objects.
|
82
|
+
# criteria:: a hash of parameters; valid keys are:
|
83
|
+
# * <code>filter</code> Filters to apply to the list.
|
84
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
85
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
86
|
+
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> dateCreated</code><code> maxRedemptions</code><code> timesRedeemed</code><code> id</code><code> startDate</code><code> endDate</code><code> percentOff</code><code> couponCode</code><code> durationInMonths</code><code> amountOff</code>.
|
87
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
88
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
89
|
+
# Returns an object where the <code>list</code> property contains the list of Coupon objects and the <code>total</code>
|
90
|
+
# property contains the total number of Coupon objects available for the given criteria.
|
91
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
92
|
+
|
93
|
+
if public_key == nil then
|
94
|
+
public_key = Simplify::public_key
|
95
|
+
end
|
96
|
+
if private_key == nil then
|
97
|
+
private_key = Simplify::private_key
|
98
|
+
end
|
99
|
+
|
100
|
+
h = Simplify::PaymentsApi.execute("coupon", 'list', criteria, public_key, private_key)
|
101
|
+
obj = Coupon.new()
|
102
|
+
obj.public_key = public_key
|
103
|
+
obj.private_key = private_key
|
104
|
+
obj = obj.merge(h)
|
105
|
+
obj
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
# Retrieve a Coupon object from the API
|
110
|
+
#
|
111
|
+
# id:: ID of object to retrieve
|
112
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
113
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
114
|
+
# Returns a Coupon object.
|
115
|
+
def self.find(id, public_key = nil, private_key = nil)
|
116
|
+
if public_key == nil then
|
117
|
+
public_key = Simplify::public_key
|
118
|
+
end
|
119
|
+
if private_key == nil then
|
120
|
+
private_key = Simplify::private_key
|
121
|
+
end
|
122
|
+
|
123
|
+
h = Simplify::PaymentsApi.execute("coupon", 'show', {"id" => id}, public_key, private_key)
|
124
|
+
obj = Coupon.new()
|
125
|
+
obj.public_key = public_key
|
126
|
+
obj.private_key = private_key
|
127
|
+
obj = obj.merge(h)
|
128
|
+
obj
|
129
|
+
end
|
130
|
+
|
131
|
+
# Updates this object
|
132
|
+
#
|
133
|
+
# The properties that can be updated:
|
134
|
+
# * <code>endDate</code> The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
|
135
|
+
# * <code>maxRedemptions</code> Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time.
|
136
|
+
def update()
|
137
|
+
h = Simplify::PaymentsApi.execute("coupon", 'update', self, self.public_key, self.private_key)
|
138
|
+
self.merge!(h)
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, MasterCard International Incorporated
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification, are
|
6
|
+
# permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice, this list of
|
9
|
+
# conditions and the following disclaimer.
|
10
|
+
# Redistributions in binary form must reproduce the above copyright notice, this list of
|
11
|
+
# conditions and the following disclaimer in the documentation and/or other materials
|
12
|
+
# provided with the distribution.
|
13
|
+
# Neither the name of the MasterCard International Incorporated nor the names of its
|
14
|
+
# contributors may be used to endorse or promote products derived from this software
|
15
|
+
# without specific prior written permission.
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
17
|
+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
19
|
+
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
22
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
23
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
24
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
+
# SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'simplify/paymentsapi'
|
29
|
+
|
30
|
+
module Simplify
|
31
|
+
|
32
|
+
# A Customer object.
|
33
|
+
#
|
34
|
+
class Customer < Hash
|
35
|
+
|
36
|
+
# Public key used to access the API.
|
37
|
+
attr_accessor :public_key
|
38
|
+
|
39
|
+
# Private key used to access the API.
|
40
|
+
attr_accessor :private_key
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
# Creates an Customer object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>card => addressCity</code> City of the cardholder.
|
48
|
+
# * <code>card => addressCountry</code> Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder.
|
49
|
+
# * <code>card => addressLine1</code> Address of the cardholder
|
50
|
+
# * <code>card => addressLine2</code> Address of the cardholder if needed.
|
51
|
+
# * <code>card => addressState</code> State code (USPS code) of residence of the cardholder.
|
52
|
+
# * <code>card => addressZip</code> Postal code of the cardholder.
|
53
|
+
# * <code>card => cvc</code> CVC security code of the card. This is the code on the back of the card. Example: 123
|
54
|
+
# * <code>card => expMonth</code> Expiration month of the card. Format is MM. Example: January = 01 <b>required </b>
|
55
|
+
# * <code>card => expYear</code> Expiration year of the card. Format is YY. Example: 2013 = 13 <b>required </b>
|
56
|
+
# * <code>card => name</code> Name as appears on the card.
|
57
|
+
# * <code>card => number</code> Card number as it appears on the card. <b>required </b>
|
58
|
+
# * <code>email</code> Email address of the customer <b>required </b>
|
59
|
+
# * <code>name</code> Customer name <b>required </b>
|
60
|
+
# * <code>reference</code> Reference field for external applications use.
|
61
|
+
# * <code>subscriptions => amount</code> Amount of payment in minor units. Example: 1000 = 10.00
|
62
|
+
# * <code>subscriptions => coupon</code> Coupon associated with the subscription for the customer.
|
63
|
+
# * <code>subscriptions => currency</code> Currency code (ISO-4217). Must match the currency associated with your account. <b>default:USD</b>
|
64
|
+
# * <code>subscriptions => customer</code> The customer ID to create the subscription for. Do not supply this when creating a customer.
|
65
|
+
# * <code>subscriptions => frequency</code> Frequency of payment for the plan. Example: Monthly
|
66
|
+
# * <code>subscriptions => name</code> Name describing subscription
|
67
|
+
# * <code>subscriptions => plan</code> The plan ID that the subscription should be created from.
|
68
|
+
# * <code>subscriptions => quantity</code> Quantity of the plan for the subscription.
|
69
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
70
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
71
|
+
# Returns a Customer object.
|
72
|
+
def self.create(parms, public_key = nil, private_key = nil)
|
73
|
+
if public_key == nil then
|
74
|
+
public_key = Simplify::public_key
|
75
|
+
end
|
76
|
+
if private_key == nil then
|
77
|
+
private_key = Simplify::private_key
|
78
|
+
end
|
79
|
+
|
80
|
+
h = Simplify::PaymentsApi.execute("customer", 'create', parms, public_key, private_key)
|
81
|
+
obj = Customer.new()
|
82
|
+
obj.public_key = public_key
|
83
|
+
obj.private_key = private_key
|
84
|
+
obj = obj.merge(h)
|
85
|
+
obj
|
86
|
+
end
|
87
|
+
|
88
|
+
# Delete this object
|
89
|
+
def delete()
|
90
|
+
h = Simplify::PaymentsApi.execute("customer", 'delete', self, self.public_key, self.private_key)
|
91
|
+
self.merge!(h)
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# Retrieve Customer objects.
|
96
|
+
# criteria:: a hash of parameters; valid keys are:
|
97
|
+
# * <code>filter</code> Filters to apply to the list.
|
98
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
99
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
100
|
+
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> dateCreated</code><code> id</code><code> name</code><code> email</code><code> reference</code>.
|
101
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
102
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
103
|
+
# Returns an object where the <code>list</code> property contains the list of Customer objects and the <code>total</code>
|
104
|
+
# property contains the total number of Customer objects available for the given criteria.
|
105
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
106
|
+
|
107
|
+
if public_key == nil then
|
108
|
+
public_key = Simplify::public_key
|
109
|
+
end
|
110
|
+
if private_key == nil then
|
111
|
+
private_key = Simplify::private_key
|
112
|
+
end
|
113
|
+
|
114
|
+
h = Simplify::PaymentsApi.execute("customer", 'list', criteria, public_key, private_key)
|
115
|
+
obj = Customer.new()
|
116
|
+
obj.public_key = public_key
|
117
|
+
obj.private_key = private_key
|
118
|
+
obj = obj.merge(h)
|
119
|
+
obj
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
# Retrieve a Customer object from the API
|
124
|
+
#
|
125
|
+
# id:: ID of object to retrieve
|
126
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
127
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
128
|
+
# Returns a Customer object.
|
129
|
+
def self.find(id, public_key = nil, private_key = nil)
|
130
|
+
if public_key == nil then
|
131
|
+
public_key = Simplify::public_key
|
132
|
+
end
|
133
|
+
if private_key == nil then
|
134
|
+
private_key = Simplify::private_key
|
135
|
+
end
|
136
|
+
|
137
|
+
h = Simplify::PaymentsApi.execute("customer", 'show', {"id" => id}, public_key, private_key)
|
138
|
+
obj = Customer.new()
|
139
|
+
obj.public_key = public_key
|
140
|
+
obj.private_key = private_key
|
141
|
+
obj = obj.merge(h)
|
142
|
+
obj
|
143
|
+
end
|
144
|
+
|
145
|
+
# Updates this object
|
146
|
+
#
|
147
|
+
# The properties that can be updated:
|
148
|
+
# * <code>card => addressCity</code> City of the cardholder.
|
149
|
+
# * <code>card => addressCountry</code> Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder.
|
150
|
+
# * <code>card => addressLine1</code> Address of the cardholder.
|
151
|
+
# * <code>card => addressLine2</code> Address of the cardholder if needed.
|
152
|
+
# * <code>card => addressState</code> State code (USPS code) of residence of the cardholder.
|
153
|
+
# * <code>card => addressZip</code> Postal code of the cardholder.
|
154
|
+
# * <code>card => cvc</code> CVC security code of the card. This is the code on the back of the card. Example: 123
|
155
|
+
# * <code>card => expMonth</code> Expiration month of the card. Format is MM. Example: January = 01 <b>(required)</b>
|
156
|
+
# * <code>card => expYear</code> Expiration year of the card. Format is YY. Example: 2013 = 13 <b>(required)</b>
|
157
|
+
# * <code>card => name</code> Name as appears on the card.
|
158
|
+
# * <code>card => number</code> Card number as it appears on the card. <b>(required)</b>
|
159
|
+
# * <code>email</code> Email address of the customer <b>(required)</b>
|
160
|
+
# * <code>name</code> Customer name <b>(required)</b>
|
161
|
+
# * <code>reference</code> Reference field for external applications use.
|
162
|
+
def update()
|
163
|
+
h = Simplify::PaymentsApi.execute("customer", 'update', self, self.public_key, self.private_key)
|
164
|
+
self.merge!(h)
|
165
|
+
self
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, MasterCard International Incorporated
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification, are
|
6
|
+
# permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice, this list of
|
9
|
+
# conditions and the following disclaimer.
|
10
|
+
# Redistributions in binary form must reproduce the above copyright notice, this list of
|
11
|
+
# conditions and the following disclaimer in the documentation and/or other materials
|
12
|
+
# provided with the distribution.
|
13
|
+
# Neither the name of the MasterCard International Incorporated nor the names of its
|
14
|
+
# contributors may be used to endorse or promote products derived from this software
|
15
|
+
# without specific prior written permission.
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
17
|
+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
19
|
+
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
22
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
23
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
24
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
+
# SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'simplify/paymentsapi'
|
29
|
+
|
30
|
+
module Simplify
|
31
|
+
|
32
|
+
# A Deposit object.
|
33
|
+
#
|
34
|
+
class Deposit < Hash
|
35
|
+
|
36
|
+
# Public key used to access the API.
|
37
|
+
attr_accessor :public_key
|
38
|
+
|
39
|
+
# Private key used to access the API.
|
40
|
+
attr_accessor :private_key
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
# Retrieve Deposit objects.
|
45
|
+
# criteria:: a hash of parameters; valid keys are:
|
46
|
+
# * <code>filter</code> Filters to apply to the list.
|
47
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
48
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
49
|
+
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> amount</code><code> dateCreated</code><code> depositDate</code>.
|
50
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
51
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
52
|
+
# Returns an object where the <code>list</code> property contains the list of Deposit objects and the <code>total</code>
|
53
|
+
# property contains the total number of Deposit objects available for the given criteria.
|
54
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
55
|
+
|
56
|
+
if public_key == nil then
|
57
|
+
public_key = Simplify::public_key
|
58
|
+
end
|
59
|
+
if private_key == nil then
|
60
|
+
private_key = Simplify::private_key
|
61
|
+
end
|
62
|
+
|
63
|
+
h = Simplify::PaymentsApi.execute("deposit", 'list', criteria, public_key, private_key)
|
64
|
+
obj = Deposit.new()
|
65
|
+
obj.public_key = public_key
|
66
|
+
obj.private_key = private_key
|
67
|
+
obj = obj.merge(h)
|
68
|
+
obj
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# Retrieve a Deposit object from the API
|
73
|
+
#
|
74
|
+
# id:: ID of object to retrieve
|
75
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
76
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
77
|
+
# Returns a Deposit object.
|
78
|
+
def self.find(id, public_key = nil, private_key = nil)
|
79
|
+
if public_key == nil then
|
80
|
+
public_key = Simplify::public_key
|
81
|
+
end
|
82
|
+
if private_key == nil then
|
83
|
+
private_key = Simplify::private_key
|
84
|
+
end
|
85
|
+
|
86
|
+
h = Simplify::PaymentsApi.execute("deposit", 'show', {"id" => id}, public_key, private_key)
|
87
|
+
obj = Deposit.new()
|
88
|
+
obj.public_key = public_key
|
89
|
+
obj.private_key = private_key
|
90
|
+
obj = obj.merge(h)
|
91
|
+
obj
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, MasterCard International Incorporated
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification, are
|
6
|
+
# permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice, this list of
|
9
|
+
# conditions and the following disclaimer.
|
10
|
+
# Redistributions in binary form must reproduce the above copyright notice, this list of
|
11
|
+
# conditions and the following disclaimer in the documentation and/or other materials
|
12
|
+
# provided with the distribution.
|
13
|
+
# Neither the name of the MasterCard International Incorporated nor the names of its
|
14
|
+
# contributors may be used to endorse or promote products derived from this software
|
15
|
+
# without specific prior written permission.
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
17
|
+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
19
|
+
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
22
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
23
|
+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
24
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
+
# SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'simplify/paymentsapi'
|
29
|
+
|
30
|
+
module Simplify
|
31
|
+
|
32
|
+
# An Event object
|
33
|
+
class Event < Hash
|
34
|
+
|
35
|
+
# Creates a webhook Event object
|
36
|
+
#
|
37
|
+
# params:: a hash of parameters; valid keys are:
|
38
|
+
# * <code>payload</code> The raw JWS message payload. <b>required</b>
|
39
|
+
# * <code>url</code> The URL for the webhook. If present it must match the URL registered for the webhook.
|
40
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
41
|
+
# private_key:: API key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
42
|
+
|
43
|
+
def self.create(params, public_key = nil, private_key = nil)
|
44
|
+
|
45
|
+
if public_key == nil then
|
46
|
+
public_key = Simplify::public_key
|
47
|
+
end
|
48
|
+
if private_key == nil then
|
49
|
+
private_key = Simplify::private_key
|
50
|
+
end
|
51
|
+
|
52
|
+
h = Simplify::PaymentsApi.jws_decode(params, public_key, private_key)
|
53
|
+
|
54
|
+
if !h['event']
|
55
|
+
raise ApiException.new("Incorrect data in webhook event", nil, nil)
|
56
|
+
end
|
57
|
+
|
58
|
+
obj = Event.new()
|
59
|
+
obj = obj.merge(h['event'])
|
60
|
+
|
61
|
+
obj
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|