You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/07 07:39:24 UTC
[09/17] removing billing,
payment and sso-mgt components since they are not going to use Apache
Stratos
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java b/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
deleted file mode 100644
index 261f705..0000000
--- a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
-* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. licenses this file to you 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 org.wso2.carbon.billing.mgt.services;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.billing.core.BillingConstants;
-import org.wso2.carbon.billing.core.BillingEngine;
-import org.wso2.carbon.billing.core.BillingEngineContext;
-import org.wso2.carbon.billing.core.BillingManager;
-import org.wso2.carbon.billing.core.beans.OutstandingBalanceInfoBean;
-import org.wso2.carbon.billing.core.beans.PaginatedBalanceInfoBean;
-import org.wso2.carbon.billing.core.dataobjects.*;
-import org.wso2.carbon.billing.mgt.beans.*;
-import org.wso2.carbon.billing.mgt.util.Util;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.util.ClaimsMgtUtil;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-import org.wso2.carbon.utils.DataPaginator;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class BillingService extends AbstractAdmin {
-
- private static final Log log = LogFactory.getLog(BillingService.class);
-
- /**
- * Gets the available billing periods of the available invoices for the
- * current customer. Tenant id is taken from registry
- * @return an array of BillingPeriod objects
- * @throws Exception Exception
- */
- public BillingPeriod[] getAvailableBillingPeriods() throws Exception {
- UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
- return getAvailableBillingPeriods(registry);
- }
-
- /**
- * Gets the available billigs dates of a given tenant
- * @param tenantDomain is the tenant domain
- * @return an array of BillingPeriods
- * @throws Exception if an error occurs during the process
- */
- public BillingPeriod[] getAvailableBillingPeriodsBySuperTenant(String tenantDomain) throws Exception{
-
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
- List<Customer> customers = billingEngine.getCustomersWithName(tenantDomain);
- if(customers.size()>0){
- return getBillingPeriodsFromInvoices(billingEngine.getInvoices(customers.get(0)));
- }else{
- return new BillingPeriod[0];
- }
- }
-
- /**
- * Gets the invoice with a given invoice id
- * @param invoiceId is the id of the invoice expected
- * @return a MultitenancyInvoice object
- * @throws Exception Exception
- */
- public MultitenancyInvoice getPastInvoice(int invoiceId) throws Exception {
- UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
- return getPastInvoiceById(registry, invoiceId);
- }
-
- /**
- * Gets the current invoice (interim invoice) of the current customer.
- * Tenant id is taken from the registry
- * @return a MultitenancyInvoice object
- * @throws Exception Exception
- */
- public MultitenancyInvoice getCurrentInvoice() throws Exception {
- UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
- return getCurrentInvoiceOfCustomer(registry);
- }
-
- /**
- * Adds a payment record to the BC_PAYMENT table. Sends a notification email
- * after adding the record
- * @param payment is the Payment object which contains the payment record details
- * @param amount is the paid amount (had to pass this as a string)
- * @return the payment id for the added record
- * @throws Exception if an error occurs during the operation
- */
- public int addPayment(Payment payment, String amount) throws Exception {
- int paymentId = addPaymentRecord(payment, amount);
- if(paymentId>0){
- payment.setId(paymentId);
- sendPaymentReceivedEmail(payment);
- }
- return paymentId;
- }
-
- /**
- * Adds a payment record to the BC_REGISTRATION_PAYMENT table. Sends a notification email
- * after adding the record
- *
- * @param payment the Payment object which contains the payment record details
- * @param amount the registration fee paid
- * @param usagePlan the registered usage plan
- * @return the payment id for the added record
- * @throws Exception thrown if an error occurs while adding the record
- */
- public int addRegistrationPayment(Payment payment, String amount, String usagePlan)
- throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- Cash cashAmount = new Cash(amount);
- payment.setAmount(cashAmount);
- int paymentId = billingEngine.addRegistrationPayment(payment, usagePlan);
- if (paymentId > 0) {
- payment.setId(paymentId);
- sendRegistrationPaymentReceivedEmail(payment);
- }
- return paymentId;
- }
-
- /**
- * Adds a payment record for invoice adjustment purposes
- * @param payment is the Payment object which contains the adjustment details
- * @param amount is the adjustment amount (had to pass this as a string)
- * @return the payment id for the added adjustment record
- * @throws Exception if an error occurs during the operation
- */
- public int makeAdjustment(Payment payment, String amount) throws Exception {
- return addPaymentRecord(payment, amount);
- }
-
- private int addPaymentRecord(Payment payment, String amount) throws Exception{
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- Cash cashAmount = new Cash(amount);
- payment.setAmount(cashAmount);
- if(payment.getInvoice()!=null){
- payment.setSubscriptions(billingEngine.getInvoiceSubscriptions(payment.getInvoice().getId()));
- }
- int paymentId = billingEngine.addPayment(payment);
- return paymentId;
- }
-
- /**
- * Gets the paginated BalanceInfoBean to be shown for the super tenant in the paginated mode
- * @param pageNumber is the expected page number
- * @return a PaginatedBalanceInfoBean object
- * @throws Exception Exception
- */
- public PaginatedBalanceInfoBean getPaginatedBalances(int pageNumber) throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- List<OutstandingBalanceInfoBean> balanceBeans = billingEngine.getAllOutstandingBalances(null); //no tenant domain
- PaginatedBalanceInfoBean paginatedBalanceBean = new PaginatedBalanceInfoBean();
- DataPaginator.doPaging(pageNumber, balanceBeans, paginatedBalanceBean);
-
- return paginatedBalanceBean;
- }
-
- /**
- * Gets OutstandingBalanceInfo bean(s).
- * @param tenantDomain is the domain of the expected tenant which the super-tenant
- * wants to view the balance. If this is null, balance info of all the tenants will be shown
- * @return an array of OutstandingBalanceInfoBeans
- * @throws Exception Exception
- */
- public OutstandingBalanceInfoBean[] getOutstandingBalance(String tenantDomain) throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- List<OutstandingBalanceInfoBean> balanceBeans = billingEngine.getAllOutstandingBalanceInfoBeans(tenantDomain);
- return balanceBeans.toArray(new OutstandingBalanceInfoBean[balanceBeans.size()]);
- }
-
- /**
- * Adds a discount entry
- * @param discount is the discount object which contains discount information
- * @param tenantDomain is passed to get the tenant id and set to the discount object
- * @return true or false based on the result of the operation
- * @throws Exception if an error occurs during the operation
- */
- public boolean addDiscount (Discount discount, String tenantDomain) throws Exception {
- TenantManager tenantManager = Util.getRealmService().getTenantManager();
- int tenantId = tenantManager.getTenantId(tenantDomain);
- if(tenantId== MultitenantConstants.INVALID_TENANT_ID){
- throw new Exception("Invalid tenant domain submitted for a discount");
- }
- discount.setTenantId(tenantId);
-
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
- boolean added = billingEngine.addDiscount(discount);
- if(added){
- log.info("Discount entry added for tenant: " + discount.getTenantId());
- }
- return added;
- }
-
- /**
- * Gets the past invoice for a given invoice id
- * @param registry is the GovernanceUserRegistry
- * @param invoiceId is the expected invoice id
- * @return a MultitenancyInvoice object
- * @throws Exception Exception
- */
- private MultitenancyInvoice getPastInvoiceById(UserRegistry registry,
- int invoiceId) throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
- Invoice invoice = billingEngine.getInvoice(invoiceId);
- if (invoice == null) {
- return null;
- }
-
- Customer customer = getCurrentCustomer(registry, billingEngine);
- if (customer == null || customer.getId() != invoice.getCustomer().getId()) {
- String msg = "Trying to looking at an invoice of another customer, customer: " +
- (customer == null ? "unknown" : customer.getId()) + ", invoice: " +
- invoice.getId() + ".";
- log.error(msg);
- throw new Exception(msg);
- }
-
- MultitenancyInvoice multitenancyInvoice = new MultitenancyInvoice();
- multitenancyInvoice.setInvoiceId(invoice.getId());
- multitenancyInvoice.setBillingDate(invoice.getDate());
- multitenancyInvoice.setBoughtForward(invoice.getBoughtForward().serializeToString());
- multitenancyInvoice.setCarriedForward(invoice.getCarriedForward().serializeToString());
- multitenancyInvoice.setStartDate(invoice.getStartDate());
- multitenancyInvoice.setEndDate(invoice.getEndDate());
- multitenancyInvoice.setTotalCost(invoice.getTotalCost().serializeToString());
- multitenancyInvoice.setTotalPayments(invoice.getTotalPayment().serializeToString());
-
- List<Subscription> subscriptions = invoice.getSubscriptions();
- MultitenancySubscription[] multitenancySubscriptions =
- new MultitenancySubscription[subscriptions.size()];
- for (int i = 0; i < subscriptions.size(); i++) {
- Subscription subscription = subscriptions.get(i);
- MultitenancySubscription multitenancySubscription = new MultitenancySubscription();
- multitenancySubscription.setSubscribedPackage(subscription.getItem().getName());
- multitenancySubscription.setActiveSince(subscription.getActiveSince());
- multitenancySubscription.setActiveUntil(subscription.getActiveUntil());
- multitenancySubscription.setActive(subscription.isActive());
-
- // now iterating the items
- List<Item> billedItems = billingEngine.getBilledItems(subscription);
- BilledEntry[] itemEntries = new BilledEntry[billedItems.size()];
- for (int j = 0; j < billedItems.size(); j++) {
- Item billedItem = billedItems.get(j);
- if (billedItem.getName().equals(multitenancySubscription.getSubscribedPackage())) {
- // ignoring the parent item..
- continue;
- }
- BilledEntry itemEntry = new BilledEntry();
- itemEntry.setName(billedItem.getDescription());
- itemEntry.setCost(billedItem.getCost().serializeToString());
- itemEntries[j] = itemEntry;
- }
- multitenancySubscription.setBilledEntries(itemEntries);
- multitenancySubscriptions[i] = multitenancySubscription;
- }
-
- multitenancyInvoice.setSubscriptions(multitenancySubscriptions);
-
- // getting the purchase orders
- List<Payment> payments = invoice.getPayments();
- if (payments != null) {
- MultitenancyPurchaseOrder[] multitenancyPurchaseOrders =
- new MultitenancyPurchaseOrder[payments.size()];
-
- for (int i = 0; i < payments.size(); i++) {
- Payment payment = payments.get(i);
- MultitenancyPurchaseOrder multitenancyPurchaseOrder =
- new MultitenancyPurchaseOrder();
-
- multitenancyPurchaseOrder.setId(payment.getId());
- multitenancyPurchaseOrder.setPaymentDate(payment.getDate());
- multitenancyPurchaseOrder.setPayment(payment.getAmount().serializeToString());
- multitenancyPurchaseOrder.setTransactionId(payment.getDescription());
- multitenancyPurchaseOrders[i] = multitenancyPurchaseOrder;
- }
- multitenancyInvoice.setPurchaseOrders(multitenancyPurchaseOrders);
- }
-
- return multitenancyInvoice;
- }
-
- /**
- * Gets the interim invoice of the current customer
- * @param registry is the GovernanceUserRegistry
- * @return an MultiTenancyInvoice object
- * @throws Exception Exception
- */
- private MultitenancyInvoice getCurrentInvoiceOfCustomer(UserRegistry registry) throws Exception {
- // we have to generate the invoice for this.
-
-
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngineViewer =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- Customer customer = getCurrentCustomer(registry, billingEngineViewer);
- if (customer == null) {
- // no customer => no invoices
- return null;
- }
-
- BillingEngineContext billingEngineContext = new BillingEngineContext();
- billingEngineContext.setCustomer(customer);
- billingEngineViewer.generateBill(billingEngineContext);
-
- // reloading the customer with new updates
- customer = billingEngineContext.getCustomer();
- Invoice invoice = customer.getActiveInvoice();
-
- // convert it and return
- if (invoice == null) {
- return null;
- }
-
- if (customer.getId() != invoice.getCustomer().getId()) {
- String msg = "Trying to looking at an invoice of another customer, customer: " +
- customer.getId() + ", invoice: " + invoice.getId() + ".";
- log.error(msg);
- throw new Exception(msg);
- }
-
- MultitenancyInvoice multitenancyInvoice = new MultitenancyInvoice();
- multitenancyInvoice.setBillingDate(invoice.getDate());
- multitenancyInvoice.setBoughtForward(invoice.getBoughtForward().serializeToString());
- multitenancyInvoice.setCarriedForward(invoice.getCarriedForward().serializeToString());
- multitenancyInvoice.setEndDate(invoice.getEndDate());
- multitenancyInvoice.setInvoiceId(invoice.getId());
- multitenancyInvoice.setStartDate(invoice.getStartDate());
-
- // getting the purchase orders
- List<Payment> payments = invoice.getPayments();
- MultitenancyPurchaseOrder[] multitenancyPurchaseOrders =
- new MultitenancyPurchaseOrder[payments.size()];
- for (int i = 0; i < payments.size(); i++) {
- Payment payment = payments.get(i);
- MultitenancyPurchaseOrder multitenancyPurchaseOrder = new MultitenancyPurchaseOrder();
- multitenancyPurchaseOrder.setId(payment.getId());
- multitenancyPurchaseOrder.setPaymentDate(payment.getDate());
- multitenancyPurchaseOrder.setPayment(payment.getAmount().serializeToString());
- multitenancyPurchaseOrder.setTransactionId(payment.getDescription());
- multitenancyPurchaseOrders[i] = multitenancyPurchaseOrder;
- }
- multitenancyInvoice.setPurchaseOrders(multitenancyPurchaseOrders);
-
- List<Subscription> subscriptions = invoice.getSubscriptions();
- MultitenancySubscription[] multitenancySubscriptions =
- new MultitenancySubscription[subscriptions.size()];
- for (int i = 0; i < subscriptions.size(); i++) {
- Subscription subscription = subscriptions.get(i);
- MultitenancySubscription multitenancySubscription = new MultitenancySubscription();
- multitenancySubscription.setSubscribedPackage(subscription.getItem().getName());
- multitenancySubscription.setActiveSince(subscription.getActiveSince());
- multitenancySubscription.setActiveUntil(subscription.getActiveUntil());
- multitenancySubscription.setActive(subscription.isActive());
-
- BilledEntry[] itemEntries;
- List<? extends Item> subItems = subscription.getItem().getChildren();
- if(subItems!=null){
- itemEntries = new BilledEntry[subItems.size()];
- for(int j=0; j<subItems.size(); j++){
- BilledEntry billedEntry = new BilledEntry();
- Item billedItem = subItems.get(j);
- billedEntry.setName(billedItem.getDescription()); //description
- if(billedItem.getCost()!=null){
- billedEntry.setCost(billedItem.getCost().toString()); //cost
- }else{
- billedEntry.setCost(new Cash("$0").toString());
- }
- itemEntries[j] = billedEntry;
- }
- }else{
- itemEntries = new BilledEntry[0];
- }
-
-
- multitenancySubscription.setBilledEntries(itemEntries);
- multitenancySubscriptions[i] = multitenancySubscription;
- }
- multitenancyInvoice.setSubscriptions(multitenancySubscriptions);
-
- Cash totalCost = invoice.getTotalCost();
- if (totalCost == null) {
- totalCost = new Cash("$0");
- }
- multitenancyInvoice.setTotalCost(totalCost.serializeToString());
-
- Cash totalPaymentCash = invoice.getTotalPayment();
- if (totalPaymentCash == null) {
- totalPaymentCash = new Cash("$0");
- }
- multitenancyInvoice.setTotalPayments(totalPaymentCash.serializeToString());
-
- return multitenancyInvoice;
- }
-
- /**
- * Gets the tenant is and then fills the customer details
- * @param userRegistry to get the tenant id
- * @param billingEngine to fill the customer details
- * @return a customer object
- * @throws Exception Exception
- */
- private Customer getCurrentCustomer(UserRegistry userRegistry,
- BillingEngine billingEngine) throws Exception {
- int currentTenantId = userRegistry.getTenantId();
- TenantManager tenantManger = Util.getRealmService().getTenantManager();
- Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
-
- List<Customer> customers = billingEngine.getCustomersWithName(currentTenant.getDomain());
- if (customers == null || customers.isEmpty()) {
- return null;
- }
- return customers.get(0);
- }
-
- private BillingPeriod[] getAvailableBillingPeriods(UserRegistry registry) throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
- Customer customer = getCurrentCustomer(registry, billingEngine);
- if (customer == null) {
- return new BillingPeriod[0];
- }
-
- List<Invoice> invoices = billingEngine.getInvoices(customer);
- if (invoices == null || invoices.size() == 0) {
- return new BillingPeriod[0];
- }
-
- return getBillingPeriodsFromInvoices(invoices);
- }
-
- /**
- * Get the billing period details when given the invoices
- * @param invoices is list of invoices
- * @return an array of billing periods
- */
- private BillingPeriod[] getBillingPeriodsFromInvoices(List<Invoice> invoices){
- BillingPeriod[] billingPeriods = new BillingPeriod[invoices.size()];
- int index = 0;
- for (Invoice invoice : invoices) {
- BillingPeriod billingPeriod = new BillingPeriod();
- billingPeriod.setInvoiceId(invoice.getId());
- billingPeriod.setStartDate(invoice.getStartDate());
- billingPeriod.setEndDate(invoice.getEndDate());
- billingPeriod.setInvoiceDate(invoice.getDate());
- billingPeriods[index++] = billingPeriod;
- }
- return billingPeriods;
- }
-
- /**
- * Sends the payment received email to the customer
- * @param payment is the payment object with the payment details
- * @throws Exception Exception
- */
- private void sendPaymentReceivedEmail(Payment payment) throws Exception{
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
- if(payment.getInvoice()!=null){
- Invoice invoice = billingEngine.getInvoice(payment.getInvoice().getId());
- if(invoice!=null){
- Customer customer = invoice.getCustomer();
- if(customer!=null){
- Map<String, String> mailParameters = new HashMap<String, String>();
- mailParameters.put("date",
- new SimpleDateFormat("dd-MMM-yyyy").format(payment.getDate()));
- mailParameters.put("transaction-id", payment.getDescription());
- mailParameters.put("amount", payment.getAmount().toString());
- mailParameters.put("invoice-id", String.valueOf(payment.getInvoice().getId()));
-
- try{
- String customerName =
- ClaimsMgtUtil.getFirstName(Util.getRealmService(), customer.getId());
- if(customerName!=null){
- mailParameters.put("customer-name", customerName);
- }else{
- mailParameters.put("customer-name", "");
- }
-
- }catch(Exception e){
- log.error("Could not get tenant information for tenant: " +
- customer.getName() + "\n" + e.getMessage());
- mailParameters.put("customer-name", "");
- }
-
- //sending the mail to the customer
- billingEngine.sendPaymentReceivedEmail(
- customer.getEmail(),
- BillingConstants.PAYMENT_RECEIVED_EMAIL_CUSTOMER_FILE,
- mailParameters);
-
- String financeEmail = CommonUtil.getStratosConfig().getFinanceNotificationEmail();
- //customer's first name is not important to finance team. Therefore it is
- //being replace with the domain name
- mailParameters.put("customer-name", customer.getName());
- billingEngine.sendPaymentReceivedEmail(
- financeEmail,
- BillingConstants.PAYMENT_RECEIVED_EMAIL_WSO2_FILE,
- mailParameters
- );
- }else{
- String msg = "Cannot send email to customer. Customer details not available";
- log.error(msg);
- throw new Exception(msg);
- }
- }else{
- String msg = "Cannot send email to customer. Invoice details not available";
- log.error(msg);
- throw new Exception(msg);
- }
- }else{
- String msg = "Cannot send email to customer. Invoice Id is not available";
- log.error(msg);
- throw new Exception(msg);
- }
- }
-
-
- private void sendRegistrationPaymentReceivedEmail(Payment payment) throws Exception {
- BillingManager billingManager = Util.getBillingManager();
- BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
- String tenantDomain = payment.getDescription().split(" ")[0];
- int tenantId = Util.getTenantManager().getTenantId(tenantDomain);
- Tenant tenant = (Tenant) Util.getTenantManager().getTenant(tenantId);
-
- Map<String, String> mailParameters = new HashMap<String, String>();
- mailParameters.put("date", new SimpleDateFormat("dd-MMM-yyyy").format(payment.getDate()));
- mailParameters.put("transaction-id", payment.getDescription().split(" ")[1]);
- mailParameters.put("amount", payment.getAmount().toString());
- mailParameters.put("invoice-id", "Registration - " + tenantDomain);
- mailParameters.put("tenant-domain", tenantDomain);
-
- String customerName = null;
- String customerEmail = tenant.getEmail();
- try {
- customerName = ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenantId);
- if (customerName != null) {
- mailParameters.put("customer-name", customerName);
- } else {
- mailParameters.put("customer-name", "");
- }
-
- } catch (Exception e) {
- log.error("Could not get tenant information for tenant: " +
- customerName + "\n" + e.getMessage());
- mailParameters.put("customer-name", "");
- }
-
- //sending the mail to the customer
- billingEngine.sendPaymentReceivedEmail(
- customerEmail,
- BillingConstants.REGISTRATION_PAYMENT_RECEIVED_EMAIL_CUSTOMER_FILE,
- mailParameters);
-
- String financeEmail = CommonUtil.getStratosConfig().getFinanceNotificationEmail();
- //customer's first name is not important to finance team. Therefore it is
- //being replace with the domain name
- mailParameters.put("customer-name", customerName);
- billingEngine.sendPaymentReceivedEmail(
- financeEmail,
- BillingConstants.PAYMENT_RECEIVED_EMAIL_WSO2_FILE,
- mailParameters
- );
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java b/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
deleted file mode 100644
index 7c354e4..0000000
--- a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. licenses this file to you 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 org.wso2.carbon.billing.mgt.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-import org.wso2.carbon.billing.core.*;
-import org.wso2.carbon.billing.mgt.api.DefaultTenantBilling;
-import org.wso2.carbon.billing.mgt.api.MultitenancyBillingInfo;
-import org.wso2.carbon.billing.mgt.handlers.MultitenancySubscriptionFeedingHandler;
-import org.wso2.carbon.stratos.common.TenantBillingService;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-import org.wso2.carbon.throttling.agent.ThrottlingAgent;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-public class Util {
- private static BillingManager billingManager = null;
- private static DataAccessManager dataAccessManager = null;
- private static RegistryService registryService;
- private static RealmService realmService;
- private static TenantUsageRetriever tenantUsageRetriever;
- private static MultitenancyBillingInfo billingInfo;
-
- public static ConfigurationContextService getContextService() {
- return contextService;
- }
-
- public static void setContextService(ConfigurationContextService contextService) {
- Util.contextService = contextService;
- }
-
- private static ServiceTracker throttlingRuleInvokerTracker = null;
- private static BundleContext bundleContext;
- private static Log log = LogFactory.getLog(Util.class);
- private static ConfigurationContextService contextService;
-
- public static synchronized void setRegistryService(RegistryService service) {
- if (registryService == null) {
- registryService = service;
- }
- }
-
- public static synchronized void setRealmService(RealmService service) {
- if (realmService == null) {
- realmService = service;
- }
- }
-
- public static void setTenantUsageRetriever(TenantUsageRetriever tenantUsageRetriever) {
- Util.tenantUsageRetriever = tenantUsageRetriever;
- }
-
- public static RealmService getRealmService() {
- return realmService;
- }
-
- public static RegistryService getRegistryService() {
- return registryService;
- }
-
- public static TenantUsageRetriever getTenantUsageRetriever() {
- return tenantUsageRetriever;
- }
-
- public static TenantManager getTenantManager() {
- if (realmService == null) {
- return null;
- }
- return realmService.getTenantManager();
- }
-
- public static BillingManager getBillingManager() {
- return billingManager;
- }
-
- public static void setBillingManager(BillingManager billingManager) {
- Util.billingManager = billingManager;
- }
-
- public static void registerSubscriptionFeedingHandlers(BundleContext bundleContext) {
- bundleContext.registerService(BillingHandler.class.getName(),
- new MultitenancySubscriptionFeedingHandler(), null);
- }
-
- public static void registerTenantBillingService(BundleContext bundleContext) {
- bundleContext.registerService(TenantBillingService.class.getName(),
- new DefaultTenantBilling(), null);
- }
-
- public static void scheduleBilling() throws BillingException {
- BillingEngine billingEngine =
- billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
- if (billingEngine != null) {
- billingEngine.scheduleBilling();
- } else {
- log.info("No billing engine for scheduled tasks");
- }
-
- }
-
- public static void registerBillingInfo(BundleContext bundleContext) throws Exception {
- billingInfo = new MultitenancyBillingInfo();
- bundleContext.registerService(MultitenancyBillingInfo.class.getName(), billingInfo, null);
- }
-
- public static MultitenancyBillingInfo getMultitenancyBillingInfo() {
- return billingInfo;
- }
-
- public static DataAccessManager getDataAccessManager() {
- return dataAccessManager;
- }
-
- public static void setDataAccessManager(DataAccessManager dataAccessManager) {
- Util.dataAccessManager = dataAccessManager;
- }
-
- public static void initDataAccessManager() {
- DataAccessManager dataAccessManager = new DataAccessManager(
- billingManager.getBillingConfiguration().getDataSource());
- Util.dataAccessManager = dataAccessManager;
- }
-
- /**
- * This method used to create service tracker that tracks throttlingAgent service which
- * registered when throttling agent starts
- *
- * @param bundleContext bundle context that belongs to component
- */
- public static void initializeThrottling(BundleContext bundleContext) {
- throttlingRuleInvokerTracker = new ServiceTracker(bundleContext, ThrottlingAgent.class.getName(),
- null);
- throttlingRuleInvokerTracker.open();
- }
-
- /**
- * This method updates the throttling rules for given tenant and update the cache at manager
- *
- * @param tenantId Tenant Id of the tenant that need to update throttling rules at manager
- */
- public static void executeThrottlingRules(int tenantId) {
- try {
- ThrottlingAgent embeddedRuleInvoker =
- (ThrottlingAgent) throttlingRuleInvokerTracker.getService();
- if (embeddedRuleInvoker != null) {
- embeddedRuleInvoker.executeThrottlingRules(tenantId);
- }
- } catch (Exception e) {
- log.error("Error in executing throttling rules in manager" + e.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/component.xml b/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 71e6e35..0000000
--- a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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.
- -->
-
-<component xmlns="http://products.wso2.org/carbon">
- <ManagementPermissions>
- <ManagementPermission>
- <DisplayName>Billing</DisplayName>
- <ResourceId>/permission/admin/billing</ResourceId>
- </ManagementPermission>
- <ManagementPermission>
- <DisplayName>View Invoice</DisplayName>
- <ResourceId>/permission/admin/billing/invoice</ResourceId>
- </ManagementPermission>
- </ManagementPermissions>
-</component>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/services.xml b/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 3aaf3de..0000000
--- a/components/stratos/billing/org.apache.stratos.billing.mgt/2.1.3/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
- <!--
- ! ! Copyright 2006 The Apache Software Foundation. ! ! 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. !
- -->
-<serviceGroup>
-
- <service name="MultitenancyBillingService" scope="transportsession">
- <transports>
- <transport>https</transport>
- </transports>
-
- <parameter name="ServiceClass" locked="false">
- org.wso2.carbon.billing.mgt.services.BillingService
- </parameter>
-
- <parameter name="adminService" locked="true">true</parameter>
-
- <parameter name="AuthorizationAction" locked="true">/permission/admin/billing/invoice</parameter>
-
- <operation name="getPaginatedBalances">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="getOutstandingBalance">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="getAvailableBillingPeriodsBySuperTenant">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="makeAdjustment">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="addRegistrationPayment">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
- </service>
-
- <service name="BillingDataAccessService" scope="transportsession">
- <parameter name="AuthorizationAction" locked="true">/permission/admin/billing/invoice</parameter>
-
- <transports>
- <transport>https</transport>
- </transports>
-
- <parameter name="ServiceClass" locked="false">
- org.wso2.carbon.billing.mgt.services.BillingDataAccessService
- </parameter>
-
- <parameter name="adminService" locked="true">true</parameter>
-
- <operation name="changeSubscriptionBySuperTenant">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="deactivateActiveSubscriptionBySuperTenant">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="getActiveSubscriptionOfCustomerBySuperTenant">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="addSubscription">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="getSubscription">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="getInactiveSubscriptionsOfCustomer">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="activateSubscription">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
-
- <operation name="changeSubscriptionForTenant">
- <parameter name="superTenantService" locked="true">true</parameter>
- </operation>
- </service>
-
- <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/billing/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/pom.xml b/components/stratos/billing/pom.xml
deleted file mode 100644
index ade5567..0000000
--- a/components/stratos/billing/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (c) 2009-2010, WSO2 Inc. (http://www.wso2.org) 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>stratos-components</artifactId>
- <version>2.1.0</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>billing-parent</artifactId>
- <packaging>pom</packaging>
- <name>WSO2 Stratos - Billing Parent Module</name>
- <description>WSO2 Stratos Billing Parent Module</description>
- <url>http://wso2.org</url>
-
- <modules>
- <module>org.wso2.carbon.billing.core/2.1.0</module>
- <module>org.wso2.carbon.billing.mgt/2.1.0</module>
- <module>org.wso2.carbon.billing.mgt.ui/2.1.0</module>
- </modules>
-
-</project>
-
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/pom.xml b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/pom.xml
deleted file mode 100644
index 46d241a..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>stratos-components</artifactId>
- <version>2.1.0</version>
- <relativePath>../../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.payment.paypal</artifactId>
- <version>2.1.0</version>
- <packaging>bundle</packaging>
- <name>WSO2 Stratos - Payment (PayPal)</name>
-
- <dependencies>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.business.messaging.paypal.integration.core</artifactId>
- <version>4.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.stratos.common</artifactId>
- <version>2.1.0</version>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
-
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Export-Package>
- org.wso2.carbon.payment.paypal.*,
- </Export-Package>
- <Import-Package>
- com.paypal.sdk.*; version="0.0.0",
- org.apache.commons.logging.*; version="1.0.4",
- org.wso2.carbon.business.messaging.paypal.integration.*; version="0.0.0",
- com.paypal.soap.api.*; version="0.0.0",
- org.apache.axis.*,
- javax.xml.soap.*; version="1.2.0",
- *;resolution:=optional
- </Import-Package>
- <DynamicImport-Package>*</DynamicImport-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Address.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Address.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Address.java
deleted file mode 100644
index 739eec9..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Address.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-
-public class Address {
-
- private String name;
-
- private String street1;
-
- private String street2;
-
- private String city;
-
- private String state;
-
- private String country;
-
- private String phone;
-
- private String postalCode;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getStreet1() {
- return street1;
- }
-
- public void setStreet1(String street1) {
- this.street1 = street1;
- }
-
- public String getStreet2() {
- return street2;
- }
-
- public void setStreet2(String street2) {
- this.street2 = street2;
- }
-
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public void setPhone(String phone) {
- this.phone = phone;
- }
-
- public String getPostalCode() {
- return postalCode;
- }
-
- public void setPostalCode(String postalCode) {
- this.postalCode = postalCode;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECDetailResponse.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECDetailResponse.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECDetailResponse.java
deleted file mode 100644
index 20b2e4e..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECDetailResponse.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-
-public class ECDetailResponse extends ECResponse {
-
- private Payer payer;
-
- private Address address;
-
- private String orderTotal;
-
- public Payer getPayer() {
- return payer;
- }
-
- public void setPayer(Payer payer) {
- this.payer = payer;
- }
-
- public Address getAddress() {
- return address;
- }
-
- public void setAddress(Address address) {
- this.address = address;
- }
-
- public String getOrderTotal() {
- return orderTotal;
- }
-
- public void setOrderTotal(String orderTotal) {
- this.orderTotal = orderTotal;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECResponse.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECResponse.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECResponse.java
deleted file mode 100644
index 799cfe1..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/ECResponse.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-/**
- * Class to hold the response coming after initiating an
- * Express Checkout scenario
- */
-
-public class ECResponse {
-
- //Timestamp which the payment scenario initiated
- private String timestamp;
-
- //Ack received for the SetEC request
- private String ack;
-
- //Token received with the response. This is necessary in the future steps
- private String token;
-
- //PaypalError details if an error occurs
- private PaypalError error;
-
- public String getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(String timestamp) {
- this.timestamp = timestamp;
- }
-
- public String getAck() {
- return ack;
- }
-
- public void setAck(String ack) {
- this.ack = ack;
- }
-
- public String getToken() {
- return token;
- }
-
- public void setToken(String token) {
- this.token = token;
- }
-
- public PaypalError getError() {
- return error;
- }
-
- public void setError(PaypalError error) {
- this.error = error;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Payer.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Payer.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Payer.java
deleted file mode 100644
index dc98076..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/Payer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-
-public class Payer {
-
- private String email;
-
- private String payerId;
-
- private String payerStatus;
-
- private String firstName;
-
- private String lastName;
-
- private String address;
-
- private String business;
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getPayerId() {
- return payerId;
- }
-
- public void setPayerId(String payerId) {
- this.payerId = payerId;
- }
-
- public String getPayerStatus() {
- return payerStatus;
- }
-
- public void setPayerStatus(String payerStatus) {
- this.payerStatus = payerStatus;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getBusiness() {
- return business;
- }
-
- public void setBusiness(String business) {
- this.business = business;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/PaypalError.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/PaypalError.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/PaypalError.java
deleted file mode 100644
index 809a8b4..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/PaypalError.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-/**
- * Class to hold details if an error ocuurs
- */
-public class PaypalError {
-
- private String shortMessage;
-
- private String longMessage;
-
- private String errorCode;
-
- public String getShortMessage() {
- return shortMessage;
- }
-
- public void setShortMessage(String shortMessage) {
- this.shortMessage = shortMessage;
- }
-
- public String getLongMessage() {
- return longMessage;
- }
-
- public void setLongMessage(String longMessage) {
- this.longMessage = longMessage;
- }
-
- public String getErrorCode() {
- return errorCode;
- }
-
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/TransactionResponse.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/TransactionResponse.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/TransactionResponse.java
deleted file mode 100644
index df916df..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/dto/TransactionResponse.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.dto;
-
-
-public class TransactionResponse extends ECResponse{
-
- private String transactionId;
-
- private String amount;
-
- private String paymentStatus;
-
- private String pendingReason;
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getAmount() {
- return amount;
- }
-
- public void setAmount(String amount) {
- this.amount = amount;
- }
-
- public String getPaymentStatus() {
- return paymentStatus;
- }
-
- public void setPaymentStatus(String paymentStatus) {
- this.paymentStatus = paymentStatus;
- }
-
- public String getPendingReason() {
- return pendingReason;
- }
-
- public void setPendingReason(String pendingReason) {
- this.pendingReason = pendingReason;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/internal/PaymentServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/internal/PaymentServiceComponent.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/internal/PaymentServiceComponent.java
deleted file mode 100644
index a1d7f2b..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/internal/PaymentServiceComponent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.internal;
-
-import com.paypal.sdk.profiles.APIProfile;
-import com.paypal.sdk.profiles.ProfileFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.business.messaging.paypal.integration.PaypalSOAPProxy;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.payment.paypal.services.PaypalService;
-
-/**
- * @scr.component name="org.wso2.carbon.payment.paypal" immediate="true"
- */
-public class PaymentServiceComponent {
-
- private static Log log = LogFactory.getLog(PaymentServiceComponent.class);
-
- protected void activate(ComponentContext ctxt){
- log.debug("Activating PaymentService Bundle");
- try{
- if(CommonUtil.getStratosConfig()==null){
- StratosConfiguration stratosConfig = CommonUtil.loadStratosConfiguration();
- CommonUtil.setStratosConfig(stratosConfig);
- }
-
- //create the APIProfile
- APIProfile profile = ProfileFactory.createSignatureAPIProfile();
- profile.setAPIUsername(CommonUtil.getStratosConfig().getPaypalAPIUsername());
- profile.setAPIPassword(CommonUtil.getStratosConfig().getPaypalAPIPassword());
- profile.setSignature(CommonUtil.getStratosConfig().getPaypalAPISignature());
- profile.setEnvironment(CommonUtil.getStratosConfig().getPaypalEnvironment());
-
- PaypalService.proxy = PaypalSOAPProxy.createPaypalSOAPProxy(profile);
- log.info("PaymentService Bundle activated");
- }catch(Throwable e){
- log.error("Error occurred while creating PayPalProxy: " + e.getMessage(), e);
- }
- }
-
- protected void deactivate(ComponentContext ctxt){
- //TODO: Do I have to null the soapproxy object?
- log.debug("PayPalService Bundle deactivated");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/services/PaypalService.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/services/PaypalService.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/services/PaypalService.java
deleted file mode 100644
index bfe0579..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/services/PaypalService.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.services;
-
-import com.paypal.sdk.exceptions.PayPalException;
-import com.paypal.soap.api.BasicAmountType;
-import com.paypal.soap.api.CurrencyCodeType;
-import com.paypal.soap.api.DoExpressCheckoutPaymentRequestDetailsType;
-import com.paypal.soap.api.DoExpressCheckoutPaymentRequestType;
-import com.paypal.soap.api.DoExpressCheckoutPaymentResponseType;
-import com.paypal.soap.api.GetExpressCheckoutDetailsRequestType;
-import com.paypal.soap.api.GetExpressCheckoutDetailsResponseType;
-import com.paypal.soap.api.PaymentActionCodeType;
-import com.paypal.soap.api.PaymentDetailsType;
-import com.paypal.soap.api.SetExpressCheckoutRequestDetailsType;
-import com.paypal.soap.api.SetExpressCheckoutRequestType;
-import com.paypal.soap.api.SetExpressCheckoutResponseType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.business.messaging.paypal.integration.PaypalSOAPProxy;
-import org.wso2.carbon.payment.paypal.dto.ECDetailResponse;
-import org.wso2.carbon.payment.paypal.dto.ECResponse;
-import org.wso2.carbon.payment.paypal.dto.TransactionResponse;
-import org.wso2.carbon.payment.paypal.util.PaymentConstants;
-import org.wso2.carbon.payment.paypal.util.ResponsePopulator;
-
-/**
- * The <code>PaypalService</code> class provides the methods required to access Paypal web service
- */
-
-public class PaypalService {
-
- //NOTE: EC stands for ExpressCheckout
- //PayPal soap proxy object
- public static PaypalSOAPProxy proxy;
-
- private static Log log = LogFactory.getLog(PaypalService.class);
-
- private ResponsePopulator populator = new ResponsePopulator();
-
- /**
- * This method initiates an express checkout
- * @param amount amount to be paid
- * @param successReturnUrl url of the page to be redirected from paypal site
- * after a successful scenario
- * @param cancelReturnUrl url of the page to be redirected if the user cancels the transaction
- * @return returns the response object
- */
- public ECResponse initExpressCheckout(String amount, String successReturnUrl,
- String cancelReturnUrl) throws PayPalException{
-
- SetExpressCheckoutRequestType ecRequest = new SetExpressCheckoutRequestType();
-
- //Adding details to the request
- SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();
- details.setReturnURL(successReturnUrl);
- details.setCancelURL(cancelReturnUrl);
- details.setNoShipping("1");
-
- BasicAmountType orderTotal = new BasicAmountType();
- orderTotal.set_value(amount);
- orderTotal.setCurrencyID(CurrencyCodeType.USD);
- details.setOrderTotal(orderTotal);
- details.setPaymentAction(PaymentActionCodeType.Sale);
-
- ecRequest.setSetExpressCheckoutRequestDetails(details);
-
- SetExpressCheckoutResponseType ecResponse =
- (SetExpressCheckoutResponseType) proxy.call(PaymentConstants.SET_EXPRESSCHECKOUT_OPERATION, ecRequest);
-
- return populator.populateSetECResponse(ecResponse);
- }
-
- /**
- * Get the details of an express checkout
- * @param token this is the token received at setting the express checkout
- * @return returns the response object
- */
- public ECDetailResponse getExpressCheckoutDetails(String token) throws PayPalException {
- GetExpressCheckoutDetailsRequestType detailRequest = new GetExpressCheckoutDetailsRequestType();
- detailRequest.setToken(token);
-
- GetExpressCheckoutDetailsResponseType detailResponse =
- (GetExpressCheckoutDetailsResponseType) proxy.call(PaymentConstants.GET_EXPRESSCHECKOUT_OPERATION, detailRequest);
-
- return populator.populateECDetailResponse(detailResponse);
- }
-
- /**
- *
- * @param token token received at beginning the transaction
- * @param payerId
- * @param amount amount to be paid (this has to be taken after payer has confirmed in the paypal site)
- * @param tenantDetails tenant domain and tenant id
- * @return returns the response object
- */
- public TransactionResponse doExpressCheckout(String token, String payerId, String amount,
- String tenantDetails) throws PayPalException {
- DoExpressCheckoutPaymentRequestType doECRequest = new DoExpressCheckoutPaymentRequestType();
-
- DoExpressCheckoutPaymentRequestDetailsType paymentRequestDetails =
- new DoExpressCheckoutPaymentRequestDetailsType();
- paymentRequestDetails.setToken(token);
- paymentRequestDetails.setPayerID(payerId);
-
- log.debug("PayerId: " + payerId);
- //I am setting payment action as sale.
- paymentRequestDetails.setPaymentAction(PaymentActionCodeType.Sale);
-
- PaymentDetailsType [] paymentDetailsArr = new PaymentDetailsType[1];
- PaymentDetailsType paymentDetails = new PaymentDetailsType();
- BasicAmountType orderTotal = new BasicAmountType();
- orderTotal.set_value(amount);
- orderTotal.setCurrencyID(CurrencyCodeType.USD);
- paymentDetails.setOrderTotal(orderTotal);
-
- //setting custom info - setting the tenant domain
- paymentDetails.setCustom(tenantDetails);
- paymentDetailsArr[0] = paymentDetails;
- paymentRequestDetails.setPaymentDetails(paymentDetailsArr);
-
- doECRequest.setDoExpressCheckoutPaymentRequestDetails(paymentRequestDetails);
-
- //Calling the caller service and returning the response
- DoExpressCheckoutPaymentResponseType doECResponse =
- (DoExpressCheckoutPaymentResponseType) proxy.call(PaymentConstants.DO_EXPRESSCHECKOUT_OPERATION, doECRequest);
- log.debug("DoEC Ack:" + doECResponse.getAck().toString());
-
- //this is a retry to do the payment. There is no reason mentioned for the error 10001
- if(PaymentConstants.RESPONSE_FAILURE.equals(doECResponse.getAck().toString()) &&
- "10001".equals(doECResponse.getErrors(0).getErrorCode().toString())){
- log.debug("Errors: " + doECResponse.getErrors().length);
- doECResponse = (DoExpressCheckoutPaymentResponseType)
- proxy.call(PaymentConstants.DO_EXPRESSCHECKOUT_OPERATION, doECRequest);
- }
-
- //log.debug("Error code: " + doECResponse.getErrors(0).getErrorCode().toString());
- //log.debug("Long message: " + doECResponse.getErrors(0).getLongMessage());
- if(PaymentConstants.RESPONSE_SUCCESS.equals(doECResponse.getAck().toString()) &&
- doECResponse.getDoExpressCheckoutPaymentResponseDetails()!=null){
- log.debug("DoEC Token: " + doECResponse.getDoExpressCheckoutPaymentResponseDetails().getToken().toString());
- }
-
- TransactionResponse tr = populator.populateDoECResponse(doECResponse);
-
- return tr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/PaymentConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/PaymentConstants.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/PaymentConstants.java
deleted file mode 100644
index dd6fdff..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/PaymentConstants.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.util;
-
-/**
- * This class contains the constants used.
- */
-public class PaymentConstants {
-
- public static String DO_EXPRESSCHECKOUT_OPERATION = "DoExpressCheckoutPayment";
- public static String SET_EXPRESSCHECKOUT_OPERATION = "SetExpressCheckout";
- public static String GET_EXPRESSCHECKOUT_OPERATION = "GetExpressCheckoutDetails";
-
- public static String RESPONSE_SUCCESS = "Success";
- public static String RESPONSE_FAILURE = "Failure";
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/ResponsePopulator.java
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/ResponsePopulator.java b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/ResponsePopulator.java
deleted file mode 100644
index ce0c11a..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/java/org/wso2/carbon/payment/paypal/util/ResponsePopulator.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.payment.paypal.util;
-
-import com.paypal.soap.api.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.payment.paypal.dto.*;
-
-/**
- * Populates the response received from paypal to simple objects
- */
-public class ResponsePopulator {
-
- private static Log log = LogFactory.getLog(ResponsePopulator.class);
-
- //Populates the response received after initiating an EC scenario
- public ECResponse populateSetECResponse(SetExpressCheckoutResponseType response){
- ECResponse ecr = new ECResponse();
- //if the response is null, return an empty object
- if(response==null){
- return ecr;
- }else{
- ecr.setTimestamp(response.getTimestamp().toString());
- ecr.setAck(response.getAck().toString());
- //if ack is success, set the token
- if(PaymentConstants.RESPONSE_SUCCESS.equals(ecr.getAck())){
- ecr.setToken(response.getToken());
- }
- //if ack is failure, then set error
- if(PaymentConstants.RESPONSE_FAILURE.equals(ecr.getAck())){
- PaypalError error = new PaypalError();
- ErrorType et = response.getErrors(0);
- if(et!=null){
- error.setErrorCode(et.getErrorCode().toString());
- error.setShortMessage(et.getShortMessage());
- error.setLongMessage(et.getLongMessage());
- }
- ecr.setError(error);
- }
- }
- return ecr;
- }
-
- //Populating the response received when getting EC details
- public ECDetailResponse populateECDetailResponse (GetExpressCheckoutDetailsResponseType response){
- ECDetailResponse ecdr = new ECDetailResponse();
- //if the response is null, return empty object
- if(response==null){
- return ecdr;
- }else{
- ecdr.setTimestamp(response.getTimestamp().toString());
- ecdr.setAck(response.getAck().toString());
- if(PaymentConstants.RESPONSE_SUCCESS.equals(ecdr.getAck())){
- GetExpressCheckoutDetailsResponseDetailsType responseDetails =
- response.getGetExpressCheckoutDetailsResponseDetails();
-
- ecdr.setToken(responseDetails.getToken().toString());
-
- PayerInfoType payerInfo = responseDetails.getPayerInfo();
- Payer payer = new Payer();
- if(payerInfo!=null){
- payer.setBusiness(payerInfo.getPayerBusiness());
- payer.setPayerId(payerInfo.getPayerID());
- PersonNameType personName = payerInfo.getPayerName();
- if(personName!=null){
- payer.setFirstName(personName.getFirstName());
- payer.setLastName(personName.getLastName());
- }
- ecdr.setPayer(payer);
- }
-
- AddressType addressType = responseDetails.getBillingAddress();
- Address address = new Address();
- if(addressType!=null){
- address.setName(addressType.getName());
- address.setStreet1(addressType.getStreet1());
- address.setStreet2(addressType.getStreet2());
- address.setCity(addressType.getCityName());
- address.setCountry(addressType.getCountryName());
- address.setPostalCode(addressType.getPostalCode());
- address.setState(addressType.getStateOrProvince());
- address.setPhone(addressType.getPhone());
- }
- ecdr.setAddress(address);
- PaymentDetailsType [] paymentDetailsArr = responseDetails.getPaymentDetails();
- PaymentDetailsType paymentDetails = paymentDetailsArr[0];
- if(paymentDetails!=null){
- BasicAmountType bat = paymentDetails.getOrderTotal();
- if(bat!=null){
- ecdr.setOrderTotal(bat.get_value());
- }
-
- }
-
- }else{
- PaypalError error = new PaypalError();
- ErrorType et = response.getErrors(0);
- if(et!=null){
- error.setErrorCode(et.getErrorCode().toString());
- error.setShortMessage(et.getShortMessage());
- error.setLongMessage(et.getLongMessage());
- }
- ecdr.setError(error);
- }
-
- }
-
- return ecdr;
- }
-
- //Populate the response received after doing the transaction
- public TransactionResponse populateDoECResponse (DoExpressCheckoutPaymentResponseType response){
- TransactionResponse tr = new TransactionResponse();
-
- tr.setTimestamp(response.getTimestamp().toString());
- tr.setAck(response.getAck().toString());
-
- if(PaymentConstants.RESPONSE_SUCCESS.equals(tr.getAck())){
- DoExpressCheckoutPaymentResponseDetailsType responseDetails =
- response.getDoExpressCheckoutPaymentResponseDetails();
- tr.setToken(responseDetails.getToken());
- tr.setTransactionId(responseDetails.getPaymentInfo()[0].getTransactionID());
- PaymentInfoType [] paymentInfoArr = responseDetails.getPaymentInfo();
- PaymentInfoType paymentInfo = paymentInfoArr[0];
- //TODO: I am not sure whether this is the correct amount value
- tr.setAmount(paymentInfo.getGrossAmount().get_value());
- tr.setPaymentStatus(paymentInfo.getPaymentStatus().toString());
- log.debug("Payment Status: " + paymentInfo.getPaymentStatus().toString());
- }else{
- ErrorType et = response.getErrors(0);
- PaypalError error = new PaypalError();
- error.setErrorCode(et.getErrorCode().toString());
- error.setShortMessage(et.getShortMessage());
- error.setLongMessage(et.getLongMessage());
-
- tr.setError(error);
- }
-
- //Return the transaction response object
- return tr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/META-INF/services.xml b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 3ccfc4f..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<serviceGroup>
- <service name="StratosPayment" scope="transportsession">
- <transports>
- <transport>https</transport>
- </transports>
- <parameter name="ServiceClass">org.wso2.carbon.payment.paypal.services.PaypalService</parameter>
- </service>
-
- <parameter name="hiddenService" locked="true">true</parameter>
- <!--parameter name="adminService" locked="true">true</parameter>
- <parameter name="AuthorizationAction" locked="true">/permission/admin/protected</parameter-->
-</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45ae532f/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/paypal.properties
----------------------------------------------------------------------
diff --git a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/paypal.properties b/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/paypal.properties
deleted file mode 100644
index 0b2ac96..0000000
--- a/components/stratos/payment/org.wso2.carbon.payment.paypal/2.1.0/src/main/resources/paypal.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-paypal.apiusername=
-paypal.apipassword=
-paypal.apisignature=
-paypal.environment=
-paypal.version=
\ No newline at end of file