java.lang.Object |
↳ |
com.wsl.modules.stripe.client.StripeCouponClient |
Class Overview
Encapsulates Coupon-related Stripe API calls.
Summary
Public Methods |
Coupon
|
createCoupon(String id, String duration, int amountOff, String currency, int durationInMonths, int maxRedemptions, int percentOff, String redeemBy, Map<String, Object> metadata)
Create a Coupon
|
Object
|
deleteCoupon(String id)
Delete a Coupon
|
CouponCollection
|
listAllCoupons(String createdTimestamp, TimeRange created, String endingBefore, int limit, String startingAfter)
List all Coupons
|
Coupon
|
retrieveCoupon(String id)
Retrieve a Coupon
|
Coupon
|
updateCoupon(String id, Map<String, Object> metadata)
Update a Coupon
Updates the metadata of a coupon.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
Public Constructors
public
StripeCouponClient
()
Public Methods
public
Coupon
createCoupon
(String id, String duration, int amountOff, String currency, int durationInMonths, int maxRedemptions, int percentOff, String redeemBy, Map<String, Object> metadata)
Parameters
id
| Unique string of your choice that will be used to identify this coupon when applying it a customer. This is often a specific code you’ll give to your customer to use when signing up (e.g. FALL25OFF). If you don’t want to specify a particular code, you can leave the ID blank and we’ll generate a random code for you. |
duration
| Specifies how long the discount will be in effect. Can be forever, once, or repeating. |
amountOff
| A positive integer representing the amount to subtract from an invoice total (required if percent_off is not passed) |
currency
| Currency of the amount_off parameter (required if amount_off is passed) |
durationInMonths
| Required only if duration is repeating If duration is repeating, a positive integer that specifies the number of months the discount will be in effect |
maxRedemptions
| A positive integer specifying the number of times the coupon can be redeemed before it’s no longer valid. For example, you might have a 50% off coupon that the first 20 readers of your blog can use. |
percentOff
| A positive integer between 1 and 100 that represents the discount the coupon will apply (required if amount_off is not passed) |
redeemBy
| Unix timestamp specifying the last time at which the coupon can be redeemed. After the redeem_by date, the coupon can no longer be applied to new customers. |
metadata
| A set of key/value pairs that you can attach to a coupon object. It can be useful for storing additional information about the coupon in a structured format. |
public
Object
deleteCoupon
(String id)
Parameters
id
| The ID of the coupon to be deleted. |
Returns
- An object with the deleted coupon's ID and a deleted flag upon success. Otherwise, this call throws an error, such as if the coupon has already been deleted.
public
CouponCollection
listAllCoupons
(String createdTimestamp, TimeRange created, String endingBefore, int limit, String startingAfter)
Parameters
createdTimestamp
| A filter on the list based on the object created field. The value can be a string with an integer Unix timestamp,... |
created
| ... or it can be a dictionary with the following options: gt, gte, lt, lte |
endingBefore
| A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_bar, your subsequent call can include ending_before=obj_bar in order to fetch the previous page of the list. |
limit
| A limit on the number of objects to be returned. Limit can range between 1 and 100 items. |
startingAfter
| A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch the next page of the list. |
Returns
- A Map with a data property that contains an array of up to limit coupons, starting after coupon starting_after. Each entry in the array is a separate coupon object. If no more coupons are available, the resulting array will be empty. This request should never throw an error.
public
Coupon
retrieveCoupon
(String id)
Parameters
id
| The ID of the desired coupon. |
public
Coupon
updateCoupon
(String id, Map<String, Object> metadata)
Update a Coupon
Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
Parameters
id
| The ID of the coupon to be updated. |
metadata
| A set of key/value pairs that you can attach to a coupon object. It can be useful for storing additional information about the coupon in a structured format. |