From 89fa3caaba0636632f1091b6a92269c341e792fa Mon Sep 17 00:00:00 2001 From: jart Date: Wed, 23 Mar 2016 16:49:56 -0700 Subject: [PATCH] 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 --- .../registry/ui/js/registrar/payment.js | 6 ++++- .../ui/server/registrar/ConsoleUiAction.java | 1 + .../RegistrarPaymentSetupAction.java | 11 +++++--- .../registry/ui/soy/registrar/Console.soy | 8 +++++- .../registry/ui/soy/registrar/Payment.soy | 12 +++++++++ .../domain/registry/server/Fixture.java | 1 + .../registry/ui/js/registrar/console_test.js | 3 ++- .../ui/js/registrar/contact_settings_test.js | 3 ++- .../registry/ui/js/registrar/contact_test.js | 3 ++- .../registry/ui/js/registrar/domain_test.js | 3 ++- .../registry/ui/js/registrar/host_test.js | 3 ++- .../ui/js/registrar/security_settings_test.js | 3 ++- .../ui/js/registrar/whois_settings_test.js | 3 ++- .../RegistrarPaymentSetupActionTest.java | 25 +++++++++++++++++++ 14 files changed, 73 insertions(+), 12 deletions(-) diff --git a/java/com/google/domain/registry/ui/js/registrar/payment.js b/java/com/google/domain/registry/ui/js/registrar/payment.js index 9e6d81788..846c5ec24 100644 --- a/java/com/google/domain/registry/ui/js/registrar/payment.js +++ b/java/com/google/domain/registry/ui/js/registrar/payment.js @@ -189,9 +189,13 @@ registry.registrar.Payment.prototype.bindToDom = function(id) { */ registry.registrar.Payment.prototype.onSetup_ = function(response) { if (response.status != 'SUCCESS') { - if (response.message == 'sandbox') { // XXX: Hard-coded from backend. + // Check for hard-coded error message codes from backend. + if (response.message == 'sandbox') { goog.soy.renderElement(this.content_, registry.soy.registrar.payment.sandbox); + } else if (response.message == 'not-using-cc-billing') { + goog.soy.renderElement(this.content_, + registry.soy.registrar.payment.notUsingCcBilling); } else { registry.forms.displayError(response.message); } diff --git a/java/com/google/domain/registry/ui/server/registrar/ConsoleUiAction.java b/java/com/google/domain/registry/ui/server/registrar/ConsoleUiAction.java index 341c0ce95..c20f0f838 100644 --- a/java/com/google/domain/registry/ui/server/registrar/ConsoleUiAction.java +++ b/java/com/google/domain/registry/ui/server/registrar/ConsoleUiAction.java @@ -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) diff --git a/java/com/google/domain/registry/ui/server/registrar/RegistrarPaymentSetupAction.java b/java/com/google/domain/registry/ui/server/registrar/RegistrarPaymentSetupAction.java index 0d97e8cb4..ada75ca62 100644 --- a/java/com/google/domain/registry/ui/server/registrar/RegistrarPaymentSetupAction.java +++ b/java/com/google/domain/registry/ui/server/registrar/RegistrarPaymentSetupAction.java @@ -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 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( diff --git a/java/com/google/domain/registry/ui/soy/registrar/Console.soy b/java/com/google/domain/registry/ui/soy/registrar/Console.soy index 495612521..8fc5df8e0 100644 --- a/java/com/google/domain/registry/ui/soy/registrar/Console.soy +++ b/java/com/google/domain/registry/ui/soy/registrar/Console.soy @@ -12,6 +12,7 @@ {@param username: string} /** Arbitrary username to display. */ {@param isAdmin: bool} /** Is this user an App Engine account admin? */ {@param logoutUrl: string} /** Generated URL for logging out of Google. */ + {@param showPaymentLink: bool} {call registry.soy.console.header} {param app: 'registrar' /} {param subtitle: 'Registrar Console' /} @@ -19,7 +20,7 @@ {call registry.soy.console.googlebar data="all" /}
- {call .navbar_ /} + {call .navbar_ data="all" /}