Add payment page link to Registrar Console

The payment page has also been updated to refuse to show itself if
the registrar is not set to credit card billing terms.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117983313
This commit is contained in:
jart 2016-03-23 16:49:56 -07:00 committed by Justine Tunney
parent b6b13333dd
commit 89fa3caaba
14 changed files with 73 additions and 12 deletions

View file

@ -96,6 +96,7 @@ public final class ConsoleUiAction implements Runnable {
data.put("username", userService.getCurrentUser().getNickname());
data.put("isAdmin", userService.isUserAdmin());
data.put("logoutUrl", userService.createLogoutURL(PATH));
data.put("showPaymentLink", registrar.getBillingMethod() == Registrar.BillingMethod.BRAINTREE);
response.setPayload(
TOFU_SUPPLIER.get()
.newRenderer(ConsoleSoyInfo.MAIN)

View file

@ -23,6 +23,7 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.config.ConfigModule.Config;
import com.google.domain.registry.config.RegistryEnvironment;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.request.Action;
import com.google.domain.registry.request.JsonActionRunner;
import com.google.domain.registry.request.JsonActionRunner.JsonAction;
@ -76,6 +77,7 @@ public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
@Inject BraintreeGateway braintreeGateway;
@Inject JsonActionRunner jsonActionRunner;
@Inject Registrar registrar;
@Inject RegistryEnvironment environment;
@Inject @Config("brainframe") String brainframe;
@Inject @Config("braintreeMerchantAccountIds") ImmutableMap<CurrencyUnit, String> accountIds;
@ -91,11 +93,14 @@ public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
if (!json.isEmpty()) {
return JsonResponseHelper.create(ERROR, "JSON request object must be empty");
}
// Prevent registrar customers from accidentally remitting payment via OT&E environment.
// payment.js is hard-coded to display a specific SOY error template when encountering the
// following error messages.
if (environment == RegistryEnvironment.SANDBOX) {
// XXX: payment.js is hard-coded to display a specific SOY error template when encountering
// an error message with this specific value.
// Prevent registrar customers from accidentally remitting payment via OT&E environment.
return JsonResponseHelper.create(ERROR, "sandbox");
} else if (registrar.getBillingMethod() != Registrar.BillingMethod.BRAINTREE) {
// Registrar needs to contact support to have their billing bit flipped.
return JsonResponseHelper.create(ERROR, "not-using-cc-billing");
}
return JsonResponseHelper
.create(SUCCESS, "Success", asList(