Payum Paypal Rest config_path - symfony

I am trying to implement paypal-rest payment with the payum bundle in symfony (3.1.4).
I need to get PayPal Plus running in my Symfony App.
Therefore I read this article
https://github.com/Payum/Payum/blob/master/docs/paypal/rest/get-it-started.md
Now - I can't figure out what the 'config_path' parameter is ment to be set to and what exactly has to be provides at this config_path.
Symfony states
'The config_path fields are required.'
My payum config looks like this atm
payum:
security:
token_storage:
AppBundle\Entity\PaymentToken: { doctrine: orm }
storages:
AppBundle\Entity\Payment: { doctrine: orm }
gateways:
paypal_express_payment:
factory: paypal_express_checkout
username: "%ppe_uname%"
password: "%ppe_pw%"
signature: "%ppe_signature%"
sandbox: false
paypal_rest_payment:
factory: paypal_rest
client_id: "%ppr_cid%"
client_secret: "%ppr_sec%"
sandbox: true
The paypal_express_payment part works fine.
If I add just a random config-path like 'my_config.txt' Symfony states
Request GetHumanStatus{model: ArrayObject} is not supported. Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker.
So - where and what is the config_path ment to be?
Any help or hints for more documentation that can lead into the right direction is very welcome.

It's meant to be sdk_config.ini from PayPal-PHP-SDK
gateways:
paypal_rest:
factory: paypal_rest
client_id: '%paypal_rest.client_id%'
client_secret: '%paypal_rest.client_secret%'
config_path: '%kernel.root_dir%/config/sdk_config.ini'
UPDATE: I don't think that Doctrine ORM storage is supported by Payum PaypalRest plugin.
PaypalRest\Action\CaptureAction requires the model (Payment) to be inherited from PayPal\Api\Payment and then it uses its create and execute methods for payment capture. I don't think it's a good idea to extend from PayPal\Api\Payment in the Doctrine entity.
I was able to eliminate this error by using Payum\Paypal\Rest\Model\PaymentDetails as a payment and filesystem as a storage:
payum:
storages:
Payum\Paypal\Rest\Model\PaymentDetails:
filesystem:
storage_dir: %kernel.root_dir%/Resources/payments
id_property: idStorage

Try to set it to default value like this:
paypal_rest_payment:
factory: paypal_rest
client_id: "%ppr_cid%"
client_secret: "%ppr_sec%"
sandbox: true
config_path: ~

Related

How to configure sending errors by e-mail with Symfony 5.1, Monolog and Mailer component?

Do you have an example configuration to send logs by email with the Mailer component of Symfony 5.1.
In the Symfony blog we announce this feature, but I can't put the right config in monolog.yaml
https://symfony.com/blog/new-in-symfony-5-1-misc-improvements-part-3 :
That's why in Symfony 5.1 we added a new Monolog log handler which uses the Mailer component to send the logs via email.
Unfortunately this addition only covers the actuall MailerHandler class in the monolog-bridge. This does not cover the possibility to configure it in the monolog-bundle (that's the drawback if those components are distributed over multiple packages).
The PR for the change in the monolog-bundle is still open, and can be found here: Add Symfony Mailer support #354.
If you don't want to wait for the change in the monolog-bundle you could already use it by defining the handler as a service and then using it with the service type in the monolog configuration.
So define your service:
services:
# this configures the "mail" as a prototype, so you can
# define the sender and recipient mail addresses here
symfony_mailer_service_template:
class: Symfony\Component\Mime\Email
calls:
- ['from', ['webapp#example.com']]
- ['to', ['ops#example.com']]
- ['subject', ['Logs']]
symfony_mailer_service:
class: Symfony\Bridge\Monolog\Handler\MailerHandler
arguments:
- '#mailer.mailer'
- '#symfony_mailer_service_template'
- !php/const Monolog\Logger::DEBUG # log level
- true # bubble
And then in your mailer configuration you could use it like this:
monolog:
handlers:
main:
type: fingers_crossed
handler: deduplicated
deduplicated:
type: deduplication
handler: symfony_mailer
symfony_mailer:
type: service
id: symfony_mailer_service

Showing doctrine cache stats in symfony web toolbar

I am using APCu caching for doctine's query and metadata caches.
I know that one can wrap a cache into a TraceableAdapter such that its statistics are shown in the web profiler.
How can I define doctrine's caches to be a TracableAdapter?
Meanwhile the doctrine cache package has been deprecated. The recommended way to use a cache is to define a pool, together with an corresponding doctrine adapter service which can then be used in doctrine's config, see below. By that, the pool automatically shows up nicely in the debug tool bar / profiler.
framework:
cache:
default_redis_provider: 'redis://%env(REDIS_HOST)%/%env(REDIS_DB)%'
pools:
doctrine.metadata_cache_pool:
adapter: cache.adapter.redis
default_lifetime: 0
services:
doctrine.metadata_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '#doctrine.metadata_cache_pool'
doctrine:
orm:
metadata_cache_driver:
type: service
id: doctrine.metadata_cache_provider

Using Symfony expression in 3rd party bundle configuration

I am trying to configure HWIOAuth bundle to use dynamic client id. I have a service that can figure out what variable value to use depending on some request conditions.
Here's an expression in my HWI configuration, but can't seem to get it work:
hwi_oauth:
firewall_names:
- main
resource_owners:
auth:
client_id: "#=service('host.configmgr').GetClientIdParameter()"
client_secret: '%client_secret%'
The issue us with #=service('host.configmgr').GetClientIdParameter(). Can that even execute evaluate? The service is properly executes an used by another class somewhere else with success.
The %client_secret% parameter replacement works fine.
For more context, this part of the configuration lives in a dedicated file that is included in config.yml via { resource: hwiconfig.yml }
After some research looks like expressions are only supported for service definitions. This functionality is not supported for configurations outside services like the HWI bundle config.

FOSElasticaBundle - JMSSerializerBundle exclusion strategies not functioning on FOSUserBundle User entity

I'm using the FOSElasticaBundle with the orm persistence driver and the JMSSerializerBundle serializer.
My users are managed by the FOSUserBundle and I'm trying to index these but exclude some fields such as password.
The JMSSerializerBundle exclusion policies such as #ExclusionPolicy("all") #Expose #Exclude are are not having any affect when added to my User entity, which extends FOS\UserBundle\Model\User. However these strategies work as expected on my other entities.
How do I stop fields such as 'salt' and 'password' from being added to the Elasticsearch index?
As a workaround I'm using the 'query_builder_method' FOSElasticaBundle configuration setting to call a method that creates a queryBuilder, which uses DQL Partial Object Syntax to only select the fields that I want to be indexed.
Here's some helpful links:
DQL Partial Object Syntax:
http://docs.doctrine-project.org/en/2.1/reference/dql-doctrine-query-language.html#partial-object-syntax
Use a Custom Doctrine Query Builder:
https://github.com/FriendsOfSymfony/FOSElasticaBundle#use-a-custom-doctrine-query-builder
This is a know thing with Serializer and annotations. You have to define the exclusion strategy also on the parent (=FOS UserBundle) model.
I have solved it with additional yaml configuration:
This is my config:
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/Resources/serializer/FOS, namespace_prefix: 'FOS\UserBundle' }
And within that folder I have for example a User.Model.yml with this content:
FOS\UserBundle\Model\User:
exclusion_policy: ALL
properties:
email:
expose: true

JMSSerializerBundle complex generated value

I need implement RESTful API for my site on symfony 2, so i use FOSRestBundle + JMSSerializerBundle
I have such serializer yml for my entity:
Acme\DemoBundle\Entity\Product:
exclusion_policy: ALL
accessor_order: custom
custom_accessor_order: [id, title]
properties:
id:
expose: true
title:
expose: true
virtual_properties:
getMainPhoto:
serialized_name: photo
The problem is that getMainPhoto return me url to full sized image. I want preprocess this url before sending response to api client where i can generate new url to resized version of such image. I already have service in sf2 which can do this job:
$resized_url = $someService->generateResizedUrl($item->getMainPhoto(), 640, 480);
But i don't know how can i use this service with JMSSerializer. Maybe there is some callbacks for FOSRestBundle\JMSSerializerBundle just before it send response?
Have a look at the documentation. There are is a number of events and/or annotations you can use to hook into the serialization process.
You can exclude the original url, and then add the resized url using http://jmsyst.com/libs/serializer/master/event_system#serializer-post-serialize event.
You have to write a listener that listen when "Product" instances are serialized.

Resources