com.braintreegateway.util.PaymentMethodParser Maven / Gradle / Ivy
package com.braintreegateway.util;
import com.braintreegateway.AmexExpressCheckoutCard;
import com.braintreegateway.AndroidPayCard;
import com.braintreegateway.ApplePayCard;
import com.braintreegateway.CreditCard;
import com.braintreegateway.CustomActionsPaymentMethod;
import com.braintreegateway.MasterpassCard;
import com.braintreegateway.PayPalAccount;
import com.braintreegateway.PaymentMethod;
import com.braintreegateway.Result;
import com.braintreegateway.SamsungPayCard;
import com.braintreegateway.UnknownPaymentMethod;
import com.braintreegateway.UsBankAccount;
import com.braintreegateway.VenmoAccount;
import com.braintreegateway.VisaCheckoutCard;
public class PaymentMethodParser {
public static Result extends PaymentMethod> parsePaymentMethod(NodeWrapper node) {
if (node.getElementName() == "paypal-account") {
return new Result(node, PayPalAccount.class);
} else if (node.getElementName() == "credit-card") {
return new Result(node, CreditCard.class);
} else if (node.getElementName() == "apple-pay-card") {
return new Result(node, ApplePayCard.class);
} else if (node.getElementName() == "android-pay-card") {
return new Result(node, AndroidPayCard.class);
} else if (node.getElementName() == "amex-express-checkout-card") {
return new Result(node, AmexExpressCheckoutCard.class);
} else if (node.getElementName() == "us-bank-account") {
return new Result(node, UsBankAccount.class);
} else if (node.getElementName() == "venmo-account") {
return new Result(node, VenmoAccount.class);
} else if (node.getElementName() == "visa-checkout-card") {
return new Result(node, VisaCheckoutCard.class);
} else if (node.getElementName() == "masterpass-card") {
return new Result(node, MasterpassCard.class);
} else if (node.getElementName() == "samsung-pay-card") {
return new Result(node, SamsungPayCard.class);
} else if (node.getElementName() == "custom-actions-payment-method") {
return new Result(node, CustomActionsPaymentMethod.class);
} else {
return new Result(node, UnknownPaymentMethod.class);
}
}
}