mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 18:59:35 +02:00
Add Registrar client ID to Braintree payment info
The client ID is passed as the "customer ID" to Braintree. In order for this to work, someone needs to go into the Braintree website beforehand, click on "New Customer" link, and create the customer record with a matching ID. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=116769955
This commit is contained in:
parent
dd633c9e72
commit
3eef39126d
5 changed files with 52 additions and 0 deletions
|
@ -28,6 +28,7 @@ import com.google.domain.registry.request.RequestModule;
|
|||
import com.google.domain.registry.request.RequestScope;
|
||||
import com.google.domain.registry.ui.server.registrar.RegistrarPaymentAction;
|
||||
import com.google.domain.registry.ui.server.registrar.RegistrarPaymentSetupAction;
|
||||
import com.google.domain.registry.ui.server.registrar.RegistrarUserModule;
|
||||
import com.google.domain.registry.whois.WhoisHttpServer;
|
||||
import com.google.domain.registry.whois.WhoisModule;
|
||||
import com.google.domain.registry.whois.WhoisServer;
|
||||
|
@ -39,6 +40,7 @@ import dagger.Subcomponent;
|
|||
@Subcomponent(
|
||||
modules = {
|
||||
RdapModule.class,
|
||||
RegistrarUserModule.class,
|
||||
RequestModule.class,
|
||||
WhoisModule.class,
|
||||
})
|
||||
|
|
|
@ -24,6 +24,7 @@ import static java.util.Arrays.asList;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.domain.registry.config.ConfigModule.Config;
|
||||
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;
|
||||
|
@ -145,6 +146,7 @@ public final class RegistrarPaymentAction implements Runnable, JsonAction {
|
|||
|
||||
@Inject BraintreeGateway braintreeGateway;
|
||||
@Inject JsonActionRunner jsonActionRunner;
|
||||
@Inject Registrar registrar;
|
||||
@Inject @Config("braintreeMerchantAccountIds") ImmutableMap<CurrencyUnit, String> accountIds;
|
||||
@Inject RegistrarPaymentAction() {}
|
||||
|
||||
|
@ -183,6 +185,7 @@ public final class RegistrarPaymentAction implements Runnable, JsonAction {
|
|||
.amount(amount.getAmount())
|
||||
.paymentMethodNonce(paymentMethodNonce)
|
||||
.merchantAccountId(merchantAccountId)
|
||||
.customerId(registrar.getClientIdentifier())
|
||||
.options()
|
||||
.submitForSettlement(true)
|
||||
.done());
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.ui.server.registrar;
|
||||
|
||||
import com.google.domain.registry.model.registrar.Registrar;
|
||||
import com.google.domain.registry.request.HttpException.ForbiddenException;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/** Registrar Console module providing reference to logged-in {@link Registrar}. */
|
||||
@Module
|
||||
public final class RegistrarUserModule {
|
||||
|
||||
@Provides
|
||||
static Registrar provideRegistrarUser(SessionUtils sessionUtils, HttpServletRequest req) {
|
||||
if (!sessionUtils.checkRegistrarConsoleLogin(req)) {
|
||||
throw new ForbiddenException("Not authorized to access Registrar Console");
|
||||
}
|
||||
return Registrar.loadByClientId(sessionUtils.getRegistrarClientId(req));
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ import com.google.domain.registry.util.FormattingLogger;
|
|||
import javax.annotation.CheckReturnValue;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
@ -47,6 +48,7 @@ public class SessionUtils {
|
|||
|
||||
private final UserService userService;
|
||||
|
||||
@Inject
|
||||
public SessionUtils(UserService userService) {
|
||||
this.userService = checkNotNull(userService);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue