From 3946aba3d26dbe0077ff4cf05f6ae54a72909e7f Mon Sep 17 00:00:00 2001 From: jchen293 Date: Wed, 10 Apr 2024 13:06:19 -0400 Subject: [PATCH] remove prefix check for PaymentId --- .../easypost/model/PaymentMethodObject.java | 4 +-- src/test/java/com/easypost/BillingTest.java | 26 ------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/easypost/model/PaymentMethodObject.java b/src/main/java/com/easypost/model/PaymentMethodObject.java index f8cfbfa07..a4f924e4a 100644 --- a/src/main/java/com/easypost/model/PaymentMethodObject.java +++ b/src/main/java/com/easypost/model/PaymentMethodObject.java @@ -60,9 +60,9 @@ public PaymentMethodType getType() { return null; } String objectType = getObject(); - if (getId().startsWith("card_") || (objectType != null && objectType.equals("CreditCard"))) { + if (objectType != null && objectType.equals("CreditCard")) { type = PaymentMethodType.CREDIT_CARD; - } else if (getId().startsWith("bank_") || (objectType != null && objectType.equals("BankAccount"))) { + } else if (objectType != null && objectType.equals("BankAccount")) { type = PaymentMethodType.BANK_ACCOUNT; } return type; diff --git a/src/test/java/com/easypost/BillingTest.java b/src/test/java/com/easypost/BillingTest.java index 762264b7c..16fd6ef39 100644 --- a/src/test/java/com/easypost/BillingTest.java +++ b/src/test/java/com/easypost/BillingTest.java @@ -139,30 +139,4 @@ public void testDeterminePaymentMethodTypeByObjectType() throws EasyPostExceptio assertEquals("BankAccount", bankAccount.getObject()); assertEquals(PaymentMethodObject.PaymentMethodType.BANK_ACCOUNT, bankAccount.getType()); } - - /** - * Test determining a payment method type by its legacy prefix. - * - * @throws EasyPostException when the request fails. - */ - @Test - public void testDeterminePaymentMethodTypeByLegacyPrefix() throws EasyPostException { - requestMock.when(() -> Requestor.request( - RequestMethod.GET, "payment_methods", null, PaymentMethod.class, vcr.client)) - .thenReturn(paymentMethodLegacyPrefixes); - - // Should be a credit card with null object type and "card_" prefix - PaymentMethodObject creditCard = - vcr.client.billing.retrievePaymentMethods().getPrimaryPaymentMethod(); - assertTrue(creditCard.getId().startsWith("card_")); - assertNull(creditCard.getObject()); - assertEquals(PaymentMethodObject.PaymentMethodType.CREDIT_CARD, creditCard.getType()); - - // Should be a bank account with null object type and "bank_" prefix - PaymentMethodObject bankAccount = - vcr.client.billing.retrievePaymentMethods().getSecondaryPaymentMethod(); - assertTrue(bankAccount.getId().startsWith("bank_")); - assertNull(bankAccount.getObject()); - assertEquals(PaymentMethodObject.PaymentMethodType.BANK_ACCOUNT, bankAccount.getType()); - } }