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,138 @@
|
|
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 Plan object.
|
33
|
+
#
|
34
|
+
class Plan < 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 Plan object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>amount</code> Amount of payment for the plan in minor units. Example: 1000 = 10.00 <b>required </b>
|
48
|
+
# * <code>currency</code> Currency code (ISO-4217) for the plan. Must match the currency associated with your account. <b>required </b><b>default:USD</b>
|
49
|
+
# * <code>frequency</code> Frequency of payment for the plan. Example: Monthly <b>required </b>
|
50
|
+
# * <code>name</code> Name of the plan <b>required </b>
|
51
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
52
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
53
|
+
# Returns a Plan object.
|
54
|
+
def self.create(parms, public_key = nil, private_key = nil)
|
55
|
+
if public_key == nil then
|
56
|
+
public_key = Simplify::public_key
|
57
|
+
end
|
58
|
+
if private_key == nil then
|
59
|
+
private_key = Simplify::private_key
|
60
|
+
end
|
61
|
+
|
62
|
+
h = Simplify::PaymentsApi.execute("plan", 'create', parms, public_key, private_key)
|
63
|
+
obj = Plan.new()
|
64
|
+
obj.public_key = public_key
|
65
|
+
obj.private_key = private_key
|
66
|
+
obj = obj.merge(h)
|
67
|
+
obj
|
68
|
+
end
|
69
|
+
|
70
|
+
# Delete this object
|
71
|
+
def delete()
|
72
|
+
h = Simplify::PaymentsApi.execute("plan", 'delete', self, self.public_key, self.private_key)
|
73
|
+
self.merge!(h)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
# Retrieve Plan objects.
|
78
|
+
# criteria:: a hash of parameters; valid keys are:
|
79
|
+
# * <code>filter</code> Filters to apply to the list.
|
80
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
81
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
82
|
+
# * <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> amount</code><code> frequency</code><code> name</code><code> id</code>.
|
83
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
84
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
85
|
+
# Returns an object where the <code>list</code> property contains the list of Plan objects and the <code>total</code>
|
86
|
+
# property contains the total number of Plan objects available for the given criteria.
|
87
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
88
|
+
|
89
|
+
if public_key == nil then
|
90
|
+
public_key = Simplify::public_key
|
91
|
+
end
|
92
|
+
if private_key == nil then
|
93
|
+
private_key = Simplify::private_key
|
94
|
+
end
|
95
|
+
|
96
|
+
h = Simplify::PaymentsApi.execute("plan", 'list', criteria, public_key, private_key)
|
97
|
+
obj = Plan.new()
|
98
|
+
obj.public_key = public_key
|
99
|
+
obj.private_key = private_key
|
100
|
+
obj = obj.merge(h)
|
101
|
+
obj
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# Retrieve a Plan object from the API
|
106
|
+
#
|
107
|
+
# id:: ID of object to retrieve
|
108
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
109
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
110
|
+
# Returns a Plan object.
|
111
|
+
def self.find(id, public_key = nil, private_key = nil)
|
112
|
+
if public_key == nil then
|
113
|
+
public_key = Simplify::public_key
|
114
|
+
end
|
115
|
+
if private_key == nil then
|
116
|
+
private_key = Simplify::private_key
|
117
|
+
end
|
118
|
+
|
119
|
+
h = Simplify::PaymentsApi.execute("plan", 'show', {"id" => id}, public_key, private_key)
|
120
|
+
obj = Plan.new()
|
121
|
+
obj.public_key = public_key
|
122
|
+
obj.private_key = private_key
|
123
|
+
obj = obj.merge(h)
|
124
|
+
obj
|
125
|
+
end
|
126
|
+
|
127
|
+
# Updates this object
|
128
|
+
#
|
129
|
+
# The properties that can be updated:
|
130
|
+
# * <code>name</code> Name of the plan. <b>(required)</b>
|
131
|
+
def update()
|
132
|
+
h = Simplify::PaymentsApi.execute("plan", 'update', self, self.public_key, self.private_key)
|
133
|
+
self.merge!(h)
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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 Refund object.
|
33
|
+
#
|
34
|
+
class Refund < 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 Refund object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>amount</code> Amount of the refund in minor units. Example: 1000 = 10.00 <b>required </b>
|
48
|
+
# * <code>payment</code> ID of the payment for the refund <b>required </b>
|
49
|
+
# * <code>reason</code> Reason for the refund
|
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 a Refund object.
|
53
|
+
def self.create(parms, public_key = nil, private_key = nil)
|
54
|
+
if public_key == nil then
|
55
|
+
public_key = Simplify::public_key
|
56
|
+
end
|
57
|
+
if private_key == nil then
|
58
|
+
private_key = Simplify::private_key
|
59
|
+
end
|
60
|
+
|
61
|
+
h = Simplify::PaymentsApi.execute("refund", 'create', parms, public_key, private_key)
|
62
|
+
obj = Refund.new()
|
63
|
+
obj.public_key = public_key
|
64
|
+
obj.private_key = private_key
|
65
|
+
obj = obj.merge(h)
|
66
|
+
obj
|
67
|
+
end
|
68
|
+
|
69
|
+
# Retrieve Refund objects.
|
70
|
+
# criteria:: a hash of parameters; valid keys are:
|
71
|
+
# * <code>filter</code> Filters to apply to the list.
|
72
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
73
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
74
|
+
# * <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> id</code><code> amount</code><code> description</code><code> dateCreated</code><code> paymentDate</code>.
|
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 an object where the <code>list</code> property contains the list of Refund objects and the <code>total</code>
|
78
|
+
# property contains the total number of Refund objects available for the given criteria.
|
79
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
80
|
+
|
81
|
+
if public_key == nil then
|
82
|
+
public_key = Simplify::public_key
|
83
|
+
end
|
84
|
+
if private_key == nil then
|
85
|
+
private_key = Simplify::private_key
|
86
|
+
end
|
87
|
+
|
88
|
+
h = Simplify::PaymentsApi.execute("refund", 'list', criteria, public_key, private_key)
|
89
|
+
obj = Refund.new()
|
90
|
+
obj.public_key = public_key
|
91
|
+
obj.private_key = private_key
|
92
|
+
obj = obj.merge(h)
|
93
|
+
obj
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
# Retrieve a Refund object from the API
|
98
|
+
#
|
99
|
+
# id:: ID of object to retrieve
|
100
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
101
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
102
|
+
# Returns a Refund object.
|
103
|
+
def self.find(id, public_key = nil, private_key = nil)
|
104
|
+
if public_key == nil then
|
105
|
+
public_key = Simplify::public_key
|
106
|
+
end
|
107
|
+
if private_key == nil then
|
108
|
+
private_key = Simplify::private_key
|
109
|
+
end
|
110
|
+
|
111
|
+
h = Simplify::PaymentsApi.execute("refund", 'show', {"id" => id}, public_key, private_key)
|
112
|
+
obj = Refund.new()
|
113
|
+
obj.public_key = public_key
|
114
|
+
obj.private_key = private_key
|
115
|
+
obj = obj.merge(h)
|
116
|
+
obj
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,149 @@
|
|
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 Subscription object.
|
33
|
+
#
|
34
|
+
class Subscription < 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 Subscription object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>amount</code> Amount of the payment (minor units). Example: 1000 = 10.00
|
48
|
+
# * <code>coupon</code> Coupon ID associated with the subscription
|
49
|
+
# * <code>currency</code> Currency code (ISO-4217). Must match the currency associated with your account. <b>default:USD</b>
|
50
|
+
# * <code>customer</code> Customer that is enrolling in the subscription.
|
51
|
+
# * <code>frequency</code> Frequency of payment for the plan. Example: Monthly
|
52
|
+
# * <code>name</code> Name describing subscription
|
53
|
+
# * <code>plan</code> The ID of the plan that should be used for the subscription.
|
54
|
+
# * <code>quantity</code> Quantity of the plan for the subscription.
|
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 Subscription 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("subscription", 'create', parms, public_key, private_key)
|
67
|
+
obj = Subscription.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("subscription", 'delete', self, self.public_key, self.private_key)
|
77
|
+
self.merge!(h)
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
# Retrieve Subscription 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> id</code><code> plan</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 Subscription objects and the <code>total</code>
|
90
|
+
# property contains the total number of Subscription 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("subscription", 'list', criteria, public_key, private_key)
|
101
|
+
obj = Subscription.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 Subscription 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 Subscription 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("subscription", 'show', {"id" => id}, public_key, private_key)
|
124
|
+
obj = Subscription.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>amount</code> Amount of the payment (minor units). Example: 1000 = 10.00
|
135
|
+
# * <code>coupon</code> Coupon being assigned to this subscription
|
136
|
+
# * <code>currency</code> Currency code (ISO-4217). Must match the currency associated with your account.
|
137
|
+
# * <code>frequency</code> Frequency of payment for the plan. Example: Monthly
|
138
|
+
# * <code>name</code> Name describing subscription
|
139
|
+
# * <code>plan</code> Plan that should be used for the subscription.
|
140
|
+
# * <code>prorate</code> Whether to prorate existing subscription. <b>(required)</b>
|
141
|
+
# * <code>quantity</code> Quantity of the plan for the subscription.
|
142
|
+
def update()
|
143
|
+
h = Simplify::PaymentsApi.execute("subscription", 'update', self, self.public_key, self.private_key)
|
144
|
+
self.merge!(h)
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,135 @@
|
|
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 Webhook object.
|
33
|
+
#
|
34
|
+
class Webhook < 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 Webhook object
|
45
|
+
#
|
46
|
+
# parms:: a hash of parameters; valid keys are:
|
47
|
+
# * <code>url</code> Endpoint URL <b>required </b>
|
48
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
49
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
50
|
+
# Returns a Webhook object.
|
51
|
+
def self.create(parms, public_key = nil, private_key = nil)
|
52
|
+
if public_key == nil then
|
53
|
+
public_key = Simplify::public_key
|
54
|
+
end
|
55
|
+
if private_key == nil then
|
56
|
+
private_key = Simplify::private_key
|
57
|
+
end
|
58
|
+
|
59
|
+
h = Simplify::PaymentsApi.execute("webhook", 'create', parms, public_key, private_key)
|
60
|
+
obj = Webhook.new()
|
61
|
+
obj.public_key = public_key
|
62
|
+
obj.private_key = private_key
|
63
|
+
obj = obj.merge(h)
|
64
|
+
obj
|
65
|
+
end
|
66
|
+
|
67
|
+
# Delete this object
|
68
|
+
def delete()
|
69
|
+
h = Simplify::PaymentsApi.execute("webhook", 'delete', self, self.public_key, self.private_key)
|
70
|
+
self.merge!(h)
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieve Webhook objects.
|
75
|
+
# criteria:: a hash of parameters; valid keys are:
|
76
|
+
# * <code>filter</code> Filters to apply to the list.
|
77
|
+
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
78
|
+
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
79
|
+
# * <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>.
|
80
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
81
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
82
|
+
# Returns an object where the <code>list</code> property contains the list of Webhook objects and the <code>total</code>
|
83
|
+
# property contains the total number of Webhook objects available for the given criteria.
|
84
|
+
def self.list(criteria = nil, public_key = nil, private_key = nil)
|
85
|
+
|
86
|
+
if public_key == nil then
|
87
|
+
public_key = Simplify::public_key
|
88
|
+
end
|
89
|
+
if private_key == nil then
|
90
|
+
private_key = Simplify::private_key
|
91
|
+
end
|
92
|
+
|
93
|
+
h = Simplify::PaymentsApi.execute("webhook", 'list', criteria, public_key, private_key)
|
94
|
+
obj = Webhook.new()
|
95
|
+
obj.public_key = public_key
|
96
|
+
obj.private_key = private_key
|
97
|
+
obj = obj.merge(h)
|
98
|
+
obj
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# Retrieve a Webhook object from the API
|
103
|
+
#
|
104
|
+
# id:: ID of object to retrieve
|
105
|
+
# public_key:: Public to use for the API call. If nil, the value of Simplify::public_key will be used.
|
106
|
+
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
107
|
+
# Returns a Webhook object.
|
108
|
+
def self.find(id, public_key = nil, private_key = nil)
|
109
|
+
if public_key == nil then
|
110
|
+
public_key = Simplify::public_key
|
111
|
+
end
|
112
|
+
if private_key == nil then
|
113
|
+
private_key = Simplify::private_key
|
114
|
+
end
|
115
|
+
|
116
|
+
h = Simplify::PaymentsApi.execute("webhook", 'show', {"id" => id}, public_key, private_key)
|
117
|
+
obj = Webhook.new()
|
118
|
+
obj.public_key = public_key
|
119
|
+
obj.private_key = private_key
|
120
|
+
obj = obj.merge(h)
|
121
|
+
obj
|
122
|
+
end
|
123
|
+
|
124
|
+
# Updates this object
|
125
|
+
#
|
126
|
+
# The properties that can be updated:
|
127
|
+
# * <code>url</code> Endpoint URL <b>(required)</b>
|
128
|
+
def update()
|
129
|
+
h = Simplify::PaymentsApi.execute("webhook", 'update', self, self.public_key, self.private_key)
|
130
|
+
self.merge!(h)
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|