PromotionCodes
Creates, updates, and retrieves a promotion code that represents a customer-redeemable code for a coupon.
Table Specific Information
Select
The provider uses the Stripe API to filter the results by the following column and operator:
- Id supports the following operator: =.
- Active supports the following operator: =.
- Code supports the following operator: =.
- CouponId supports the following operator: =.
- Created supports the following operators: =,>,>=,<,<=.
- Customer supports the following operator: =.
- AccountId supports the following operator: =.
The rest of the filter is executed client-side within the provider.
You can select from the PromotionCodes table with the following queries:
SELECT * FROM PromotionCodes SELECT * FROM PromotionCodes WHERE Id = '123124'
Insert
To create a promotion code, the CouponId is required:
INSERT INTO PromotionCodes (Active, Code, CouponId, Customer, MaxRedemptions) values ('true', 'FIRST5', 'WN3VpE01', 'cus_NBs3z63zmfCJy1' ,4)
INSERT INTO PromotionCodes (Code, Active, Customer, CouponId, Metadata, Expiresat, MaxRedemptions, RestrictionsFirstTimeTransaction, RestrictionsMinimumAmount, RestrictionsMinimumAmountCurrency) values ('TestCode', true, 'cus_PE90A5xYP8TpeM', 'WG4hYi8e', '[{"A":"BCD","E":"FGH","I":"JKL"}]', '2023-12-30 12:40:20', 15, true, 25, 'eur')
Update
To modify a promotion code, specify the code Id:
UPDATE PromotionCodes SET Active='false' WHERE id='123124'
Delete
Delete is not supported.
Columns
Name | Type | ReadOnly | References | Description |
Id [KEY] | String | True |
The Id of the promotion code. | |
Active | Boolean | False |
Whether the promotion code is currently active. A promotion code is only active if the coupon is also valid. | |
Code | String | False |
The customer-facing code. | |
CouponAmountOff | Integer | True |
The amount (in the currency specified) that is taken off the subtotal of any invoices for this customer. | |
CouponCreated | Datetime | True |
The time at which the coupon was created. | |
CouponCurrency | String | True |
If amount_off has been set, the three-letter ISO code for the currency of the amount to take off. | |
CouponDuration | String | True |
One of forever, once, and repeating. | |
CouponDurationInMonths | Integer | True |
If duration is repeating, the number of months the coupon applies. The value is Null if coupon duration is forever or once. | |
CouponId | String | False |
The Id of the coupon. | |
CouponLivemode | Boolean | True |
true if the object is in live mode andfalse if in test mode. | |
CouponMaxRedemptions | Integer | True |
The maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid. | |
CouponMetadata | String | True |
The set of key-value pairs that you can attach to a coupon. | |
CouponName | String | True |
Name of the coupon displayed to customers. | |
CouponPercentOff | Double | True |
The percent to be taken off the subtotal of any invoices for this customer for the duration of the coupon. | |
CouponRedeemBy | Datetime | True |
The date after which the coupon can no longer be redeemed. | |
CouponTimesRedeemed | Integer | True |
The number of times this coupon has been applied to a customer. | |
CouponAppliesToProducts | Integer | True |
Contains information about what this coupon applies to. A list of product IDs this coupon applies to. | |
CouponValid | Boolean | True |
Whether this coupon can still be applied to a customer, taking the above properties into account . | |
Created | Datetime | True |
The time at which the object was created. Measured in seconds since the Unix epoch. | |
Customer | String | False |
The customer that this promotion code can be used by. | |
ExpiresAt | Datetime | False |
The date at which the promotion code can no longer be redeemed. | |
Livemode | Boolean | True |
true if the object is in live mode andfalse if in test mode. | |
MaxRedemptions | Integer | False |
The maximum number of times this promotion code can be redeemed. | |
Metadata | String | False |
The set of key/value pairs that you can attach to a value list object. | |
RestrictionsCurrencyOptions | String | False |
Promotion codes defined in each available currency option. Each key must be a three-letter ISO currency code and a supported currency. | |
RestrictionsFirstTimeTransaction | Boolean | False |
A Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices. | |
RestrictionsMinimumAmount | Integer | False |
The minimum amount required to redeem this Promotion Code into a Coupon. | |
RestrictionsMinimumAmountCurrency | String | False |
A three-letter ISO code for minimum_amount. | |
TimesRedeemed | Integer | True |
The number of times this promotion code has been used. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
Name | Type | Description |
AccountId | String |
The Id of the connected account to get promotion code for. |