Skip to content

Commit f588eb8

Browse files
author
90K2
committed
subscriptions
1 parent 935af7b commit f588eb8

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class SuccessfulPayment implements Serializable {
1616
private OrderInfo order_info;
1717
private String telegram_payment_charge_id;
1818
private String provider_payment_charge_id;
19+
private Integer subscription_expiration_date;
20+
private Boolean is_recurring;
21+
private Boolean is_first_recurring;
1922

2023
public String currency() {
2124
return currency;
@@ -41,6 +44,18 @@ public String telegramPaymentChargeId() {
4144
return telegram_payment_charge_id;
4245
}
4346

47+
public Integer subscriptionExpirationDate() {
48+
return subscription_expiration_date;
49+
}
50+
51+
public Boolean isRecurring() {
52+
return is_recurring;
53+
}
54+
55+
public Boolean isFirstRecurring() {
56+
return is_first_recurring;
57+
}
58+
4459
public String providerPaymentChargeId() {
4560
return provider_payment_charge_id;
4661
}
@@ -61,6 +76,13 @@ public boolean equals(Object o) {
6176
if (order_info != null ? !order_info.equals(that.order_info) : that.order_info != null) return false;
6277
if (telegram_payment_charge_id != null ? !telegram_payment_charge_id.equals(that.telegram_payment_charge_id) : that.telegram_payment_charge_id != null)
6378
return false;
79+
if (subscription_expiration_date != null ? !subscription_expiration_date.equals(that.subscription_expiration_date) : that.subscription_expiration_date != null)
80+
return false;
81+
if (is_recurring != null ? !is_recurring.equals(that.is_recurring) : that.is_recurring != null)
82+
return false;
83+
if (is_first_recurring != null ? !is_first_recurring.equals(that.is_first_recurring) : that.is_first_recurring != null)
84+
return false;
85+
6486
return provider_payment_charge_id != null ? provider_payment_charge_id.equals(that.provider_payment_charge_id) : that.provider_payment_charge_id == null;
6587

6688
}
@@ -74,6 +96,9 @@ public int hashCode() {
7496
result = 31 * result + (order_info != null ? order_info.hashCode() : 0);
7597
result = 31 * result + (telegram_payment_charge_id != null ? telegram_payment_charge_id.hashCode() : 0);
7698
result = 31 * result + (provider_payment_charge_id != null ? provider_payment_charge_id.hashCode() : 0);
99+
result = 31 * result + (subscription_expiration_date != null ? subscription_expiration_date.hashCode() : 0);
100+
result = 31 * result + (is_recurring != null ? is_recurring.hashCode() : 0);
101+
result = 31 * result + (is_first_recurring != null ? is_first_recurring.hashCode() : 0);
77102
return result;
78103
}
79104

@@ -87,6 +112,9 @@ public String toString() {
87112
", order_info=" + order_info +
88113
", telegram_payment_charge_id='" + telegram_payment_charge_id + '\'' +
89114
", provider_payment_charge_id='" + provider_payment_charge_id + '\'' +
115+
", subscription_expiration_date='" + subscription_expiration_date + '\'' +
116+
", is_recurring='" + is_recurring + '\'' +
117+
", is_first_recurring='" + is_first_recurring + '\'' +
90118
'}';
91119
}
92120
}

library/src/main/java/com/pengrad/telegrambot/request/CreateInvoiceLink.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public CreateInvoiceLink suggestedTipAmounts(Integer[] suggestedTipAmounts) {
4646
return add("suggested_tip_amounts", suggestedTipAmounts);
4747
}
4848

49+
public CreateInvoiceLink subscriptionPeriod(int subscriptionPeriod) {
50+
return add("subscription_period", subscriptionPeriod);
51+
}
52+
4953
public CreateInvoiceLink providerData(String providerData) {
5054
return add("provider_data", providerData);
5155
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.pengrad.telegrambot.request;
2+
3+
import com.pengrad.telegrambot.response.BaseResponse;
4+
5+
6+
public class EditUserStarSubscription extends BaseRequest<EditUserStarSubscription, BaseResponse> {
7+
8+
/**
9+
*
10+
* @param userId Identifier of the user whose subscription will be edited
11+
* @param telegramPaymentChargeId Telegram payment identifier for the subscription
12+
* @param isCanceled Pass True to cancel extension of the user subscription;
13+
* the subscription must be active up to the end of the current subscription period.
14+
* Pass False to allow the user to re-enable a subscription
15+
* that was previously canceled by the bot.
16+
*/
17+
public EditUserStarSubscription(Long userId, String telegramPaymentChargeId, boolean isCanceled) {
18+
super(BaseResponse.class);
19+
add("user_id", userId).add("telegram_payment_charge_id", telegramPaymentChargeId).add("is_canceled", isCanceled);
20+
}
21+
}

0 commit comments

Comments
 (0)