Accommodate PayPal with SEPA changes
This commit is contained in:
parent
a00c2fcfdb
commit
7821a3cd61
|
@ -614,6 +614,10 @@ public class SubscriptionController {
|
||||||
public String returnUrl;
|
public String returnUrl;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String cancelUrl;
|
public String cancelUrl;
|
||||||
|
|
||||||
|
public CreatePayPalBoostRequest() {
|
||||||
|
super.paymentMethod = PaymentMethod.PAYPAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record CreatePayPalBoostResponse(String approvalUrl, String paymentId) {
|
record CreatePayPalBoostResponse(String approvalUrl, String paymentId) {
|
||||||
|
|
|
@ -67,6 +67,7 @@ import org.whispersystems.textsecuregcm.mappers.SubscriptionProcessorExceptionMa
|
||||||
import org.whispersystems.textsecuregcm.storage.IssuedReceiptsManager;
|
import org.whispersystems.textsecuregcm.storage.IssuedReceiptsManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.SubscriptionManager;
|
import org.whispersystems.textsecuregcm.storage.SubscriptionManager;
|
||||||
import org.whispersystems.textsecuregcm.subscriptions.BraintreeManager;
|
import org.whispersystems.textsecuregcm.subscriptions.BraintreeManager;
|
||||||
|
import org.whispersystems.textsecuregcm.subscriptions.BraintreeManager.PayPalOneTimePaymentApprovalDetails;
|
||||||
import org.whispersystems.textsecuregcm.subscriptions.ChargeFailure;
|
import org.whispersystems.textsecuregcm.subscriptions.ChargeFailure;
|
||||||
import org.whispersystems.textsecuregcm.subscriptions.PaymentMethod;
|
import org.whispersystems.textsecuregcm.subscriptions.PaymentMethod;
|
||||||
import org.whispersystems.textsecuregcm.subscriptions.ProcessorCustomer;
|
import org.whispersystems.textsecuregcm.subscriptions.ProcessorCustomer;
|
||||||
|
@ -231,6 +232,30 @@ class SubscriptionControllerTest {
|
||||||
assertThat(response.getStatus()).isEqualTo(200);
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCreateBoostPayPal() {
|
||||||
|
final PayPalOneTimePaymentApprovalDetails payPalOneTimePaymentApprovalDetails = mock(PayPalOneTimePaymentApprovalDetails.class);
|
||||||
|
when(BRAINTREE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.PAYPAL))
|
||||||
|
.thenReturn(Set.of("usd", "jpy", "bif", "eur"));
|
||||||
|
when(BRAINTREE_MANAGER.createOneTimePayment(anyString(), anyLong(), anyString(), anyString(), anyString()))
|
||||||
|
.thenReturn(CompletableFuture.completedFuture(payPalOneTimePaymentApprovalDetails));
|
||||||
|
when(payPalOneTimePaymentApprovalDetails.approvalUrl()).thenReturn("approvalUrl");
|
||||||
|
when(payPalOneTimePaymentApprovalDetails.paymentId()).thenReturn("someId");
|
||||||
|
|
||||||
|
final Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/paypal/create")
|
||||||
|
.request()
|
||||||
|
.post(Entity.json("""
|
||||||
|
{
|
||||||
|
"currency": "USD",
|
||||||
|
"amount": 300,
|
||||||
|
"cancelUrl": "cancelUrl",
|
||||||
|
"returnUrl": "returnUrl"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
));
|
||||||
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createBoostReceiptInvalid() {
|
void createBoostReceiptInvalid() {
|
||||||
final Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/receipt_credentials")
|
final Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/receipt_credentials")
|
||||||
|
|
Loading…
Reference in New Issue