[Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web services

Functionality discussions and feature requests

Moderators: hugo, alexandre, rmvanarkel

Post Reply
stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

[Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web services

Post by stephendwolff » Wed Feb 05, 2014 6:25 pm

Hi there,

Is it possible to make a payment from one system account to another via the Payment webservice?

Ie something like this:

doPayment( amount = 10,
fromSystem = True,
toSystem = True,
currency= 'X',
transferTypeId=31)

Ie - with no fromMember or toMember set?

The transfer type is a transaction type in cyclos which is for a system to system account payment in the specified currency which has been set up to be shown in the list of transaction types for the webservice channel in question.

I have debugged the running cyclos 3.7.3 code and i cannot see any transfer types listed when the initial query for possible transfer types is made. Is this a conscious decision or something i'm missing?

Many thanks,

Stephen
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

luis
Posts: 179
Joined: Fri Feb 17, 2006 11:01 am

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by luis » Mon Feb 10, 2014 8:09 am

Hi.
It is possible, but there is a bug on web service client creation that doesn't lists transfer types from system to system.
So, you first have to save the web service client, then the transfer types which are available for the selected channel will show up.
Also, make sure that the service client is not restricted to a member.
Luis Fernando Planella Gonzalez
Cyclos development team

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by stephendwolff » Mon Feb 10, 2014 9:04 am

The system to system transfer type is being listed in the 'Perform payments' list, and i have it selected. That wasn't the issue i was asking about.

The problem i have is that when i try and use this transfer type to make a payment, I am getting an 'INVALID PARAMETERS' response. I'm not sure which parameter is invalid, as the error doesn't contain that information.

Which parameters are needed to make a system to system account transfer via webservices? is it just the following:

amount = 10.0
fromSystem = True
toSystem = True
currency = '<currency SYMBOL>'
transferTypeId = 31

[ where 31 is the id of the system to system transaction type, and <currency symbol> is X or Y or GBP etc? ]
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by stephendwolff » Mon Feb 10, 2014 9:29 am

ok - i've got the error message:

"INVALID_PARAMETERS. Reason: The service client doesn't have permission to the specified transfer type: 31 - ..."

I have the transfer type selected on the web services client screen - so should this work?
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

justas

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by justas » Mon Aug 04, 2014 10:20 am

Hi,

I have the same issue. Cyclos 3.7.3 web service does not support "Self payments" system-to-system.
I haven't found any easy solution for this, so I updated Cyclos itself.

Code: Select all

diff --git a/cyclos_3.7.3/src/nl/strohalm/cyclos/services/transactions/PaymentServiceImpl.java b/cyclos_3.7.3/src/nl/strohalm/cyclos/services/transactions/PaymentServiceImpl.java
index fe5af80..79f2b0f 100644
--- a/cyclos_3.7.3/src/nl/strohalm/cyclos/services/transactions/PaymentServiceImpl.java
+++ b/cyclos_3.7.3/src/nl/strohalm/cyclos/services/transactions/PaymentServiceImpl.java
@@ -1592,10 +1592,9 @@ public class PaymentServiceImpl implements PaymentServiceLocal {
         final Validator validator = new Validator("transfer");
         Collection<TransactionContext> possibleContexts = new ArrayList<TransactionContext>();
         possibleContexts.add(TransactionContext.PAYMENT);
+		possibleContexts.add(TransactionContext.SELF_PAYMENT);
         if (LoggedUser.isWebService() || LoggedUser.isSystem()) {
             possibleContexts.add(TransactionContext.AUTOMATIC);
-        } else {
-            possibleContexts.add(TransactionContext.SELF_PAYMENT);
         }
         validator.property("context").required().anyOf(possibleContexts);
         validator.property("to").required().key("payment.recipient");
and

Code: Select all

diff --git a/cyclos_3.7.3/src/nl/strohalm/cyclos/webservices/utils/PaymentHelper.java b/cyclos_3.7.3/src/nl/strohalm/cyclos/webservices/utils/PaymentHelper.java
index 851dc92..e0132b6 100644
--- a/cyclos_3.7.3/src/nl/strohalm/cyclos/webservices/utils/PaymentHelper.java
+++ b/cyclos_3.7.3/src/nl/strohalm/cyclos/webservices/utils/PaymentHelper.java
@@ -19,22 +19,11 @@
  */
 package nl.strohalm.cyclos.webservices.utils;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
 import nl.strohalm.cyclos.entities.access.Channel;
 import nl.strohalm.cyclos.entities.accounts.AccountOwner;
 import nl.strohalm.cyclos.entities.accounts.MemberAccount;
 import nl.strohalm.cyclos.entities.accounts.fees.transaction.TransactionFee;
-import nl.strohalm.cyclos.entities.accounts.transactions.PaymentRequestTicket;
-import nl.strohalm.cyclos.entities.accounts.transactions.Transfer;
-import nl.strohalm.cyclos.entities.accounts.transactions.TransferQuery;
-import nl.strohalm.cyclos.entities.accounts.transactions.TransferType;
-import nl.strohalm.cyclos.entities.accounts.transactions.TransferTypeQuery;
+import nl.strohalm.cyclos.entities.accounts.transactions.*;
 import nl.strohalm.cyclos.entities.customization.fields.PaymentCustomField;
 import nl.strohalm.cyclos.entities.customization.fields.PaymentCustomFieldValue;
 import nl.strohalm.cyclos.entities.exceptions.EntityNotFoundException;
@@ -65,17 +54,15 @@ import nl.strohalm.cyclos.utils.validation.ValidationException;
 import nl.strohalm.cyclos.webservices.WebServiceContext;
 import nl.strohalm.cyclos.webservices.model.FieldValueVO;
 import nl.strohalm.cyclos.webservices.model.TransactionFeeVO;
-import nl.strohalm.cyclos.webservices.payments.AbstractPaymentParameters;
-import nl.strohalm.cyclos.webservices.payments.AccountHistoryParams;
-import nl.strohalm.cyclos.webservices.payments.PaymentParameters;
-import nl.strohalm.cyclos.webservices.payments.PaymentStatus;
-import nl.strohalm.cyclos.webservices.payments.RequestPaymentParameters;
-
+import nl.strohalm.cyclos.webservices.payments.*;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.springframework.dao.DataIntegrityViolationException;
 
+import java.math.BigDecimal;
+import java.util.*;
+
 /**
  * Helper class for web services payments<br>
  * <b>WARN</b>: Be aware that this helper <b>doesn't</b> access the services through the security layer. They are all local services.
@@ -110,7 +97,7 @@ public class PaymentHelper {
         // First, we need a list of existing TTs for the payment
         final TransferTypeQuery query = new TransferTypeQuery();
         query.setResultType(ResultType.LIST);
-        query.setContext(TransactionContext.PAYMENT);
+        query.setContext(dto.getContext());
         query.setChannel(channel);
         query.setFromOwner(dto.getFrom());
         query.setToOwner(dto.getTo());
Regards,
Justas

Xebax
Posts: 15
Joined: Fri Nov 16, 2012 1:19 pm

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by Xebax » Wed Feb 18, 2015 7:23 pm

stephendwolff wrote:ok - i've got the error message:

"INVALID_PARAMETERS. Reason: The service client doesn't have permission to the specified transfer type: 31 - ..."

I have the transfer type selected on the web services client screen - so should this work?
Hi,

I have exactly the same issue. Did you find a solution ? (I mean, other that modifying the code of Cyclos as suggested by Justas)

Regards,
Xebax

stephendwolff
Posts: 21
Joined: Fri Sep 21, 2012 11:41 am

Re: [Cyclos 3.7.3] Making Sys Ac to Sys Ac pmt via web servi

Post by stephendwolff » Tue Apr 21, 2015 12:24 pm

Hi Xebax,

I think we used a work around in the end - whereby the system account we needed to use, we made a member account, with a single user.

I've some experience with customising the source code, but this wasn't a bug we decided to address when the work around worked well for us.

Hope this fits your use case!

Cheers,

Stephen
Qoin - Money that Matters
Agency for Community Currencies
Consultancy - Projects - Services - Research

http://www.qoin.org

Post Reply