@Test public void testSetPaymentIdentificationCreation() throws Exception { final String localOrgId = "orgForPSPIdTest2"; Organization org = initPlainOrgWithId(localOrgId); OrganizationRefToPaymentType orgPayType = addPaymentTypeToOrganization(org, CREDIT_CARD); PaymentInfo pi = getPaymentInfoForOrg(orgPayType); String id = "initialValueToSet"; String provider = "Platin Card"; String account = "0123456"; // Create a new PI (Registration) VOPaymentData pd = getData(0, id, provider, account, org.getKey(), pi.getPaymentType().getKey()); paymentMgmt.savePaymentIdentificationForOrganization(pd); PaymentInfo savedPi = findPaymentInfo(0); Assert.assertEquals( "Wrong external identifier for payment info stored", id, savedPi.getExternalIdentifier()); Assert.assertEquals( "Wrong payment info type stored", CREDIT_CARD, savedPi.getPaymentType().getPaymentTypeId()); Assert.assertEquals(provider, savedPi.getProviderName()); Assert.assertEquals(account, savedPi.getAccountNumber()); // Now update an existing PI (Reregistration) pd = getData(pi.getKey(), id, provider, account, org.getKey(), pi.getPaymentType().getKey()); pd.setPaymentInfoId(pd.getPaymentInfoId() + "2"); paymentMgmt.savePaymentIdentificationForOrganization(pd); savedPi = findPaymentInfo(pi.getKey()); Assert.assertEquals( "Wrong external identifier for payment info stored", id, savedPi.getExternalIdentifier()); Assert.assertEquals( "Wrong payment info type stored", CREDIT_CARD, savedPi.getPaymentType().getPaymentTypeId()); Assert.assertEquals(provider, savedPi.getProviderName()); Assert.assertEquals(account, savedPi.getAccountNumber()); }
private static VOPaymentData getData( long key, String id, String provider, String number, long organizationKey, long paymentTypeKey) { VOPaymentData pd = new VOPaymentData(); pd.setAccountNumber(number); pd.setIdentification(id); pd.setPaymentInfoKey(key); pd.setPaymentInfoId("12345"); pd.setProvider(provider); pd.setOrganizationKey(organizationKey); pd.setPaymentTypeKey(paymentTypeKey); return pd; }