Setting Payments authorization on MemberProduct

Any issue about Cyclos 4 scripting and Webservices

Moderators: hugo, alexandre, rmvanarkel

Post Reply
martin.rueegg
Posts: 80
Joined: Thu Aug 11, 2016 12:38 pm
Location: Bristol, UK
Contact:

Setting Payments authorization on MemberProduct

Post by martin.rueegg » Thu Dec 14, 2017 6:27 am

Hello

I'm currently writing a library to dump and re-load the Cyclos configuration. However, I can't find a way to set the Payment authorization on a MemberProduct.

I was trying to find how to set the Payments authorization for a MemberProduct using the script. The documentation gave me no clue where to find it. Also looked at AuthorizationLevelServiceLocal and AuthorizationRoleServiceLocal. No avail.

Thanks so much,
Martin.
Cyclos v4.8.2 w/ Social license
Technical Manager, Bristol Pound CIC, Bristol, UK, http://bristolpound.org

martin.rueegg
Posts: 80
Joined: Thu Aug 11, 2016 12:38 pm
Location: Bristol, UK
Contact:

Re: Setting Payments authorization on MemberProduct

Post by martin.rueegg » Thu Dec 14, 2017 8:15 am

Response from Luis:
Luis wrote:
Hi Martin.
There are lots of processing that takes place when we save a product.
The correct way to grant the permission to authorize payments to a member product would be:

Code: Select all

import org.cyclos.entities.users.MemberProduct
import org.cyclos.model.users.products.AuthorizedPaymentsOperation
import org.cyclos.model.users.products.MemberProductDTO

def product = entityManagerHandler.find(MemberProduct, 'users')
def dto = productService.toDTO(product) as MemberProductDTO
dto.myAuthorizedPayments = EnumSet.of(AuthorizedPaymentsOperation.VIEW,
    AuthorizedPaymentsOperation.AUTHORIZE)
productService.save(dto)
(...)

Best regards, Luis.
Cyclos v4.8.2 w/ Social license
Technical Manager, Bristol Pound CIC, Bristol, UK, http://bristolpound.org

Post Reply