I am creating a subscription with billing_cycle_anchor
set to first day of next month. Below is the params passed when creating subscription
{
"metadata": {
"tenant_id": "2cf19732-0c7b-42e4-a0a2-90fd9c0e7111"
},
"collection_method": "send_invoice",
"days_until_due": "30",
"backdate_start_date": "1645171200",
"items": {
"0": {
"quantity": "1",
"price": "price_1KVX9cBuQq6cUmE7iODbojye",
"tax_rates": {
"0": "txr_1KVKHvBuQq6cUmE7lvmOUWU2"
}
}
},
"billing_cycle_anchor": "1646121600",
"customer": "cus_LBwT8BBsUSTO3S"
}
// Invoke subscription API as
Subscription.create(params)
I am creating coupon by passing below params
{
"duration": "once",
"metadata": {
"credit_id": "f3fef2ab-c8a5-442b-964c-2fd4f3156eb6"
},
"max_redemptions": "1",
"name": "Startup_credit",
"currency": "usd",
"amount_off": "1000"
}
com.stripe.model.Coupon.create(params)
On invoice.created
, I am trying to set discounts from above coupon on the initial invoice by invoking update. Below is the params based to update invoice
{
"expand": {
"0": "discounts",
"1": "total_discount_amounts.discount",
"2": "lines.data.tax_amounts.tax_rate",
"3": "lines.data.price.product"
},
"discounts": {
"0": {
"coupon": "3j4TRKK2"
},
"1": {
"coupon": "XLw6c1Jv"
}
}
}
// code to update stripe invoice
final ArrayList<Object> expandList = new ArrayList<>();
expandList.add("discounts");
expandList.add("total_discount_amounts.discount");
expandList.add("lines.data.tax_amounts.tax_rate");
expandList.add("lines.data.price.product");
params.put("expand", expandList);
return invoice.update(params);