mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 06:03:18 +01:00
Implement start of backups payment integration work.
This commit is contained in:
committed by
Greyson Parrelli
parent
680223c4b6
commit
6b50be78c0
@@ -80,7 +80,7 @@ public class DonationsService {
|
||||
* @param visible Whether the badge will be visible on the user's profile immediately after redemption
|
||||
* @param primary Whether the badge will be made primary immediately after redemption
|
||||
*/
|
||||
public ServiceResponse<EmptyResponse> redeemReceipt(ReceiptCredentialPresentation receiptCredentialPresentation, boolean visible, boolean primary) {
|
||||
public ServiceResponse<EmptyResponse> redeemDonationReceipt(ReceiptCredentialPresentation receiptCredentialPresentation, boolean visible, boolean primary) {
|
||||
try {
|
||||
pushServiceSocket.redeemDonationReceipt(receiptCredentialPresentation, visible, primary);
|
||||
return ServiceResponse.forResult(EmptyResponse.INSTANCE, 200, null);
|
||||
@@ -89,6 +89,20 @@ public class DonationsService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a user to redeem a given receipt they were given after submitting a donation successfully.
|
||||
*
|
||||
* @param receiptCredentialPresentation Receipt
|
||||
*/
|
||||
public ServiceResponse<EmptyResponse> redeemArchivesReceipt(ReceiptCredentialPresentation receiptCredentialPresentation) {
|
||||
try {
|
||||
pushServiceSocket.redeemArchivesReceipt(receiptCredentialPresentation);
|
||||
return ServiceResponse.forResult(EmptyResponse.INSTANCE, 200, null);
|
||||
} catch (Exception e) {
|
||||
return ServiceResponse.<EmptyResponse>forUnknownError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits price information to the server to generate a payment intent via the payment gateway.
|
||||
*
|
||||
|
||||
@@ -288,6 +288,7 @@ public class PushServiceSocket {
|
||||
private static final String REQUEST_RATE_LIMIT_PUSH_CHALLENGE = "/v1/challenge/push";
|
||||
|
||||
private static final String DONATION_REDEEM_RECEIPT = "/v1/donation/redeem-receipt";
|
||||
private static final String ARCHIVES_REDEEM_RECEIPT = "/v1/archives/redeem-receipt";
|
||||
|
||||
private static final String UPDATE_SUBSCRIPTION_LEVEL = "/v1/subscription/%s/level/%s/%s/%s";
|
||||
private static final String SUBSCRIPTION = "/v1/subscription/%s";
|
||||
@@ -1312,10 +1313,15 @@ public class PushServiceSocket {
|
||||
}
|
||||
|
||||
public void redeemDonationReceipt(ReceiptCredentialPresentation receiptCredentialPresentation, boolean visible, boolean primary) throws IOException {
|
||||
String payload = JsonUtil.toJson(new RedeemReceiptRequest(Base64.encodeWithPadding(receiptCredentialPresentation.serialize()), visible, primary));
|
||||
String payload = JsonUtil.toJson(new RedeemDonationReceiptRequest(Base64.encodeWithPadding(receiptCredentialPresentation.serialize()), visible, primary));
|
||||
makeServiceRequest(DONATION_REDEEM_RECEIPT, "POST", payload);
|
||||
}
|
||||
|
||||
public void redeemArchivesReceipt(ReceiptCredentialPresentation receiptCredentialPresentation) throws IOException {
|
||||
String payload = JsonUtil.toJson(new RedeemArchivesReceiptRequest(Base64.encodeWithPadding(receiptCredentialPresentation.serialize())));
|
||||
makeServiceRequest(ARCHIVES_REDEEM_RECEIPT, "POST", payload);
|
||||
}
|
||||
|
||||
public StripeClientSecret createStripeOneTimePaymentIntent(String currencyCode, String paymentMethod, long amount, long level) throws IOException {
|
||||
String payload = JsonUtil.toJson(new StripeOneTimePaymentIntentPayload(amount, currencyCode, level, paymentMethod));
|
||||
String result = makeServiceRequestWithoutAuthentication(CREATE_STRIPE_ONE_TIME_PAYMENT_INTENT, "POST", payload);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.whispersystems.signalservice.internal.push
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
||||
/**
|
||||
* POST /v1/archives/redeem-receipt
|
||||
*
|
||||
* Request object for redeeming a receipt from a donation transaction.
|
||||
*
|
||||
* @param receiptCredentialPresentation base64-encoded no-newlines standard-character-set with-padding of the bytes of a [ReceiptCredentialPresentation] object
|
||||
*/
|
||||
internal class RedeemArchivesReceiptRequest @JsonCreator constructor(@param:JsonProperty("receiptCredentialPresentation") val receiptCredentialPresentation: String)
|
||||
@@ -10,7 +10,7 @@ import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialPresentation;
|
||||
*
|
||||
* Request object for redeeming a receipt from a donation transaction.
|
||||
*/
|
||||
class RedeemReceiptRequest {
|
||||
class RedeemDonationReceiptRequest {
|
||||
|
||||
private final String receiptCredentialPresentation;
|
||||
private final boolean visible;
|
||||
@@ -21,8 +21,7 @@ class RedeemReceiptRequest {
|
||||
* @param visible boolean indicating if the new badge should be visible or not on the profile
|
||||
* @param primary boolean indicating if the new badge should be primary or not on the profile; is always treated as false if `visible` is false
|
||||
*/
|
||||
@JsonCreator
|
||||
RedeemReceiptRequest(
|
||||
@JsonCreator RedeemDonationReceiptRequest(
|
||||
@JsonProperty("receiptCredentialPresentation") String receiptCredentialPresentation,
|
||||
@JsonProperty("visible") boolean visible,
|
||||
@JsonProperty("primary") boolean primary) {
|
||||
@@ -23,6 +23,7 @@ public class SubscriptionsConfiguration {
|
||||
|
||||
public static final int BOOST_LEVEL = 1;
|
||||
public static final int GIFT_LEVEL = 100;
|
||||
public static final int BACKUPS_LEVEL = 201;
|
||||
public static final HashSet<Integer> SUBSCRIPTION_LEVELS = new HashSet<>(Arrays.asList(500, 1000, 2000));
|
||||
|
||||
@JsonProperty("currencies")
|
||||
|
||||
Reference in New Issue
Block a user