mirror of
https://github.com/google/nomulus
synced 2026-09-13 11:34:31 +00:00
Sync registrar to Braintree customer record automatically
In order to set the customerId field on a payment, the customer entry must exist in Braintree's database. This CL causes it to be created or updated before processing the payment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=118530040
This commit is contained in:
@@ -14,6 +14,7 @@ java_library(
|
||||
"//java/com/google/common/collect",
|
||||
"//java/com/google/common/io",
|
||||
"//java/com/google/common/net",
|
||||
"//java/com/google/domain/registry/braintree",
|
||||
"//java/com/google/domain/registry/config",
|
||||
"//java/com/google/domain/registry/export/sheet",
|
||||
"//java/com/google/domain/registry/flows",
|
||||
|
||||
@@ -21,6 +21,7 @@ import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.domain.registry.braintree.BraintreeRegistrarSyncer;
|
||||
import com.google.domain.registry.config.ConfigModule.Config;
|
||||
import com.google.domain.registry.config.RegistryEnvironment;
|
||||
import com.google.domain.registry.model.registrar.Registrar;
|
||||
@@ -76,6 +77,7 @@ import javax.inject.Inject;
|
||||
public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
|
||||
|
||||
@Inject BraintreeGateway braintreeGateway;
|
||||
@Inject BraintreeRegistrarSyncer customerSyncer;
|
||||
@Inject JsonActionRunner jsonActionRunner;
|
||||
@Inject Registrar registrar;
|
||||
@Inject RegistryEnvironment environment;
|
||||
@@ -93,6 +95,7 @@ public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
|
||||
if (!json.isEmpty()) {
|
||||
return JsonResponseHelper.create(ERROR, "JSON request object must be empty");
|
||||
}
|
||||
|
||||
// payment.js is hard-coded to display a specific SOY error template when encountering the
|
||||
// following error messages.
|
||||
if (environment == RegistryEnvironment.SANDBOX) {
|
||||
@@ -102,6 +105,10 @@ public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
|
||||
// Registrar needs to contact support to have their billing bit flipped.
|
||||
return JsonResponseHelper.create(ERROR, "not-using-cc-billing");
|
||||
}
|
||||
|
||||
// In order to set the customerId field on the payment, the customer must exist.
|
||||
customerSyncer.sync(registrar);
|
||||
|
||||
return JsonResponseHelper
|
||||
.create(SUCCESS, "Success", asList(
|
||||
ImmutableMap.of(
|
||||
|
||||
Reference in New Issue
Block a user