Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 11eba8f

Browse files
author
i.rybakov
committedMar 27, 2025
update logic
1 parent 2977506 commit 11eba8f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed
 

‎README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Pressing the 'getPurchases()' buttion triggers retrieving and displaying the [pu
102102

103103
#### Product purchase
104104
Pressing an item with a product name triggers the [product purchase](https://www.rustore.ru/help/en/sdk/payments/kotlin-java/6-0-0#purchaseproduct) scenario with the payment method screen display.
105-
Then, if PaymentResult.Success -> is returned, [purchase confirmation](https://www.rustore.ru/help/en/sdk/payments/kotlin-java/6-0-0#confirm) is triggered, otherwise, if PaymentResult.Failure -> is returned, [purchase cancellation](https://www.rustore.ru/help/en/sdk/payments/kotlin-java/6-0-0#deletepurchase) is triggered.
105+
Then, if PaymentResult.Success -> is returned, [purchase confirmation](https://www.rustore.ru/help/en/sdk/payments/kotlin-java/6-0-0#confirm) is triggered.
106106

107107

108108
### Deeplink handling

‎app/src/main/java/ru/rustore/example/rustorebillingsample/StartFragment.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.Arrays;
1818
import java.util.List;
1919

20+
import kotlin.Suppress;
2021
import ru.rustore.example.rustorebillingsample.di.PaymentsModule;
2122
import ru.rustore.sdk.billingclient.RuStoreBillingClient;
2223
import ru.rustore.sdk.billingclient.model.purchase.PaymentResult;
@@ -133,12 +134,10 @@ public void proceedUnfinishedPurchases(List<Purchase> purchases) {
133134
return;
134135
}
135136

136-
boolean needDeletePurchase = purchaseState == PurchaseState.CREATED || purchaseState == PurchaseState.INVOICE_CREATED;
137-
boolean needConfirmPurchase = purchaseState == PurchaseState.PAID;
137+
if (purchaseState == PurchaseState.PAID) {
138+
// If you can not give product to the customer use
139+
// deletePurchase(purchaseId)
138140

139-
if (needDeletePurchase) {
140-
deletePurchase(purchaseId);
141-
} else if (needConfirmPurchase) {
142141
confirmPurchase(purchaseId);
143142
}
144143
});
@@ -159,8 +158,6 @@ public void purchaseProduct(String productId) {
159158
private void handlePaymentResult(PaymentResult paymentResult) {
160159
if (paymentResult instanceof PaymentResult.Success) {
161160
confirmPurchase(((PaymentResult.Success) paymentResult).getPurchaseId());
162-
} else if (paymentResult instanceof PaymentResult.Failure) {
163-
deletePurchase(((PaymentResult.Failure) paymentResult).getPurchaseId());
164161
}
165162
}
166163

@@ -175,7 +172,7 @@ public void confirmPurchase(String purchaseId) {
175172
});
176173
}
177174

178-
175+
@SuppressWarnings("unused")
179176
public void deletePurchase(String purchaseId) {
180177
PurchasesUseCase purchasesUseCase = billingClient.getPurchases();
181178

0 commit comments

Comments
 (0)
Please sign in to comment.