properties, TenantContext context)
145 | throws PaymentPluginApiException;
146 |
147 | /**
148 | * Search payments.
149 | *
150 | * The search is plugin specific, there is no constraint on how the searchKey should be interpreted.
151 | *
152 | * @param offset the offset of the first result
153 | * @param limit the maximum number of results to retrieve
154 | * @param properties custom properties for the gateway
155 | * @param context call context
156 | * @return payments matching the search key
157 | * @throws PaymentPluginApiException If any unexpected error occurs
158 | */
159 | public Pagination searchPayments(String searchKey, Long offset, Long limit, Iterable properties, TenantContext context)
160 | throws PaymentPluginApiException;
161 |
162 | /**
163 | * Add a payment method for a Killbill account in the gateway.
164 | *
165 | * Note: the payment method doesn't exist yet in Killbill when receiving the call in
166 | * the plugin (kbPaymentMethodId is a placeholder).
167 | *
168 | * @param kbAccountId killbill accountId
169 | * @param paymentMethodProps payment method details
170 | * @param setDefault set it as the default payment method in the gateway
171 | * @param properties custom properties for the gateway
172 | * @param context call context
173 | * @throws PaymentPluginApiException If any unexpected error occurs
174 | */
175 | public void addPaymentMethod(UUID kbAccountId, UUID kbPaymentMethodId, PaymentMethodPlugin paymentMethodProps, boolean setDefault, Iterable properties, CallContext context)
176 | throws PaymentPluginApiException;
177 |
178 | /**
179 | * Delete a payment method in the gateway.
180 | *
181 | * @param kbAccountId killbill accountId
182 | * @param kbPaymentMethodId killbill payment method id
183 | * @param properties custom properties for the gateway
184 | * @param context call context
185 | * @throws PaymentPluginApiException If any unexpected error occurs
186 | */
187 | public void deletePaymentMethod(UUID kbAccountId, UUID kbPaymentMethodId, Iterable properties, CallContext context)
188 | throws PaymentPluginApiException;
189 |
190 | /**
191 | * Get payment method details for a given payment method.
192 | *
193 | * @param kbAccountId killbill account id
194 | * @param kbPaymentMethodId killbill payment method id
195 | * @param properties custom properties for the gateway
196 | * @param context call context
197 | * @return PaymentMethodPlugin info for the payment method
198 | * @throws PaymentPluginApiException If any unexpected error occurs
199 | */
200 | public PaymentMethodPlugin getPaymentMethodDetail(UUID kbAccountId, UUID kbPaymentMethodId, Iterable properties, TenantContext context)
201 | throws PaymentPluginApiException;
202 |
203 | /**
204 | * Set a payment method as default in the gateway.
205 | *
206 | * @param kbAccountId killbill accountId
207 | * @param kbPaymentMethodId killbill payment method id
208 | * @param properties custom properties for the gateway
209 | * @param context call context
210 | * @throws PaymentPluginApiException If any unexpected error occurs
211 | */
212 | public void setDefaultPaymentMethod(UUID kbAccountId, UUID kbPaymentMethodId, Iterable properties, CallContext context)
213 | throws PaymentPluginApiException;
214 |
215 | /**
216 | * This is used to see the view of paymentMethods kept by the plugin or the view of
217 | * existing payment method on the gateway.
218 | *
219 | * Sometimes payment methods have to be added directly to the gateway for PCI compliance issues
220 | * and so Kill Bill needs to refresh its state.
221 | *
222 | * @param kbAccountId killbill accountId
223 | * @param refreshFromGateway fetch the list of existing payment methods from gateway -- if supported
224 | * @param properties custom properties for the gateway
225 | * @param context call context
226 | * @return all payment methods for that account
227 | * @throws PaymentPluginApiException If any unexpected error occurs
228 | */
229 | public List getPaymentMethods(UUID kbAccountId, boolean refreshFromGateway, Iterable properties, CallContext context)
230 | throws PaymentPluginApiException;
231 |
232 | /**
233 | * Search payment methods
234 | *
235 | * The search is plugin specific, there is no constraint on how the searchKey should be interpreted.
236 | *
237 | * @param offset the offset of the first result
238 | * @param limit the maximum number of results to retrieve
239 | * @param properties custom properties for the gateway
240 | * @param context call context
241 | * @return payment methods matching the search key
242 | * @throws PaymentPluginApiException If any unexpected error occurs
243 | */
244 | public Pagination searchPaymentMethods(String searchKey, Long offset, Long limit, Iterable properties, TenantContext context)
245 | throws PaymentPluginApiException;
246 |
247 | /**
248 | * This is used after Killbill decided to refresh its state from the gateway
249 | *
250 | * @param kbAccountId killbill accountId
251 | * @param paymentMethods the list of payment methods
252 | * @param properties custom properties for the gateway
253 | * @param context call context
254 | * @throws PaymentPluginApiException If any unexpected error occurs
255 | */
256 | public void resetPaymentMethods(UUID kbAccountId, List paymentMethods, Iterable properties, CallContext context)
257 | throws PaymentPluginApiException;
258 |
259 | /**
260 | * Build metadata for the client to create a redirect form
261 | *
262 | * @param kbAccountId killbill accountId
263 | * @param customFields form fields
264 | * @param properties custom properties for the gateway
265 | * @param context call context
266 | * @return redirect form metadata
267 | * @throws PaymentPluginApiException If any unexpected error occurs
268 | */
269 | public HostedPaymentPageFormDescriptor buildFormDescriptor(UUID kbAccountId, Iterable customFields, Iterable properties, CallContext context)
270 | throws PaymentPluginApiException;
271 |
272 | /**
273 | * Process a notification from the gateway
274 | *
275 | * This potentially does more than just deserialize the payload. The plugin may have to acknowledge it
276 | * with the gateway.
277 | *
278 | * @param notification serialized notification object
279 | * @param properties custom properties for the gateway
280 | * @param context call context
281 | * @return gateway notification object used to build the response to the gateway
282 | * @throws PaymentPluginApiException If any unexpected error occurs
283 | */
284 | public GatewayNotification processNotification(String notification, Iterable properties, CallContext context)
285 | throws PaymentPluginApiException;
286 | }
287 |
--------------------------------------------------------------------------------
/payment/src/main/java/org/killbill/billing/payment/plugin/api/PaymentPluginApiException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010-2013 Ning, Inc.
3 | *
4 | * Ning licenses this file to you under the Apache License, version 2.0
5 | * (the "License"); you may not use this file except in compliance with the
6 | * License. You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package org.killbill.billing.payment.plugin.api;
18 |
19 | import org.killbill.billing.BillingExceptionBase;
20 |
21 | public class PaymentPluginApiException extends Exception {
22 |
23 | private static final long serialVersionUID = 15642965L;
24 |
25 | private final String errorType;
26 | private final String errorMessage;
27 |
28 | public PaymentPluginApiException(final String msg, final Throwable e) {
29 | super(msg, e);
30 | errorMessage = msg;
31 | errorType = e.getMessage();
32 | }
33 |
34 | public PaymentPluginApiException(final String errorType, final String errorMessage) {
35 | this.errorMessage = errorMessage;
36 | this.errorType = errorType;
37 | }
38 |
39 | public PaymentPluginApiException(final String errorType, BillingExceptionBase billingExceptionBase) {
40 | this.errorMessage = billingExceptionBase.getMessage();
41 | this.errorType = errorType;
42 | }
43 |
44 | public String getErrorType() {
45 | return errorType;
46 | }
47 |
48 | public String getErrorMessage() {
49 | return errorMessage;
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | final StringBuilder sb = new StringBuilder();
55 | sb.append("PaymentPluginApiException");
56 | if (errorMessage != null) {
57 | sb.append("{errorMessage='").append(errorMessage).append('\'');
58 | }
59 | if (errorType != null) {
60 | sb.append(", errorType='").append(errorType).append('\'');
61 | }
62 | sb.append('}');
63 | return sb.toString();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | 4.0.0
21 |
22 | org.kill-bill.billing
23 | killbill-oss-parent
24 | 0.146.27
25 |
26 | org.kill-bill.billing.plugin
27 | killbill-plugin-api
28 | 0.27.4-SNAPSHOT
29 | pom
30 | Kill Bill plugin apis
31 | Kill Bill plugin apis
32 | http://github.com/killbill/killbill-plugin-api
33 |
34 |
35 | notification
36 | payment
37 | currency
38 | control
39 | invoice
40 | catalog
41 | entitlement
42 | usage
43 |
44 |
45 | scm:git:git://github.com/killbill/killbill-plugin-api.git
46 | scm:git:git@github.com:killbill/killbill-plugin-api.git
47 | HEAD
48 | http://github.com/killbill/killbill-plugin-api/tree/master
49 |
50 |
51 | Github
52 | https://github.com/killbill/killbill-plugin-api/issues
53 |
54 |
55 | true
56 |
57 |
58 |
--------------------------------------------------------------------------------
/release.sh:
--------------------------------------------------------------------------------
1 | ###################################################################################
2 | # #
3 | # Copyright 2010-2014 Ning, Inc. #
4 | # #
5 | # Ning licenses this file to you under the Apache License, version 2.0 #
6 | # (the "License"); you may not use this file except in compliance with the #
7 | # License. You may obtain a copy of the License at: #
8 | # #
9 | # http://www.apache.org/licenses/LICENSE-2.0 #
10 | # #
11 | # Unless required by applicable law or agreed to in writing, software #
12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
14 | # License for the specific language governing permissions and limitations #
15 | # under the License. #
16 | # #
17 | ###################################################################################
18 | # Prepare a release:
19 | # * Update the NEWS file
20 | # * Commit all pending changes
21 | # * Do the release
22 | set -e
23 |
24 | # Make sure we're up-to-date
25 | git pull
26 |
27 | LAST_NEWS_VERSION=$(head -1 NEWS)
28 | NEXT_VERSION=`grep -E '([0-9]+\.[0-9]+(\.[0-9]+)?)-SNAPSHOT' pom.xml | sed 's/[\t \n]*\(.*\)-SNAPSHOT<\/version>[\t \n]*/\1/'`
29 |
30 | echo "Enter the NEWS changelog for version $NEXT_VERSION and hit ctrl-d when done (ctrl-c to abort)"
31 | original_news_message=$(cat)
32 |
33 | # Indent it
34 | news_message=$(echo "$original_news_message" | sed 's/^/ /g')
35 |
36 | if [ "$LAST_NEWS_VERSION" = "$NEXT_VERSION" ]; then
37 | previous_news=$(cat NEWS | sed '1d')
38 | echo -e "$NEXT_VERSION\n$news_message\n$previous_news" > NEWS
39 | else
40 | previous_news=$(cat NEWS)
41 | echo -e "$NEXT_VERSION\n$news_message\n\n$previous_news" > NEWS
42 | fi
43 |
44 | # Add to git
45 | git add -p
46 | git commit -s -m "pom.xml: updates for release $NEXT_VERSION
47 |
48 | $original_news_message"
49 |
50 | # Make sure we can push before the release
51 | git push
52 |
53 | # Do the release
54 | echo "Running: mvn release:clean" && \
55 | mvn release:clean && \
56 | echo "Running: mvn release:prepare" && \
57 | mvn release:prepare && \
58 | echo "Running: mvn release:perform" && \
59 | mvn release:perform
60 |
--------------------------------------------------------------------------------
/usage/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 | 4.0.0
20 |
21 | org.kill-bill.billing.plugin
22 | killbill-plugin-api
23 | 0.27.4-SNAPSHOT
24 |
25 | killbill-plugin-api-usage
26 | Kill Bill usage plugin apis
27 |
28 |
29 | joda-time
30 | joda-time
31 |
32 |
33 | org.kill-bill.billing
34 | killbill-api
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/usage/src/main/java/org/killbill/billing/usage/plugin/api/UsageContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020-2022 Equinix, Inc
3 | * Copyright 2014-2022 The Billing Project, LLC
4 | *
5 | * The Billing Project licenses this file to you under the Apache License, version 2.0
6 | * (the "License"); you may not use this file except in compliance with the
7 | * License. You may obtain a copy of the License at:
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 | * License for the specific language governing permissions and limitations
15 | * under the License.
16 | */
17 |
18 | package org.killbill.billing.usage.plugin.api;
19 |
20 | import org.joda.time.LocalDate;
21 | import org.killbill.billing.invoice.api.DryRunType;
22 | import org.killbill.billing.util.callcontext.TenantContext;
23 |
24 | public interface UsageContext extends TenantContext {
25 |
26 | // Specify the type of dry-run operation or null otherwise
27 | DryRunType getDryRunType();
28 | // Specify targetDate Associated with the invoice run
29 | LocalDate getInputTargetDate();
30 | }
31 |
--------------------------------------------------------------------------------
/usage/src/main/java/org/killbill/billing/usage/plugin/api/UsagePluginApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2019 Groupon, Inc
3 | * Copyright 2014-2019 The Billing Project, LLC
4 | *
5 | * The Billing Project licenses this file to you under the Apache License, version 2.0
6 | * (the "License"); you may not use this file except in compliance with the
7 | * License. You may obtain a copy of the License at:
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 | * License for the specific language governing permissions and limitations
15 | * under the License.
16 | */
17 |
18 | package org.killbill.billing.usage.plugin.api;
19 |
20 | import java.util.List;
21 | import java.util.UUID;
22 |
23 | import org.joda.time.DateTime;
24 | import org.killbill.billing.payment.api.PluginProperty;
25 | import org.killbill.billing.usage.api.RawUsageRecord;
26 |
27 | public interface UsagePluginApi {
28 |
29 | List getUsageForAccount(DateTime startDate, DateTime endDate, UsageContext context, Iterable properties);
30 |
31 | List getUsageForSubscription(UUID subscriptionId, DateTime startDate, DateTime endDate, UsageContext context, Iterable properties);
32 | }
33 |
--------------------------------------------------------------------------------