Git Product home page Git Product logo

paypalplugin's Introduction

Sylius Logo.



PayPal Plugin

Sylius Core Team’s plugin for PayPal Commerce Platform - the newest and most advanced of PayPal solutions.

Why should I use PayPal in my online business?

  • one of the most popular payment methods in the world;
  • worldwide network of 280+ millions consumers and 24+ millions merchants;
  • bank payouts are available in U.S., U.K., the E.U., Australia, and Canada;
  • PCI DSS and 3DS 2.0 compliance
  • full risk management, incl. customisable fraud tools & insight and dispute resolution via dynamic APIs.

What does this plugin give me?

  • official payment integration developed and maintained by the Sylius Core Team;
  • global support for over 100 currencies across 200+ markets;
  • two-side operations between Sylius & PayPal administration panels (payments, refunds, reports, etc.);
  • better conversion thanks to direct checkout from both product & cart page;
  • support for all credit & debit cards;
  • popular regional payment methods, i.e. iDeal, SEPA, Sofort, eps, Griopay or Przelewy24;
  • direct PayPal transactions with PayPal wallet
  1. Installation
  2. PayPal environment
  3. Onboarding
  4. Reports
  5. Processing payments
  6. Development

Supported branches

  • 1.5 (v1.5.*) - security fixes
  • 1.6 (v1.6.*) - bug fixes, improvements
  • 1.7 (v1.7.*) - new features

paypalplugin's People

Contributors

armellarcier avatar chadyred avatar damonsson avatar diimpp avatar djlechuck avatar ezar101 avatar gsadee avatar jakubtobiasz avatar jdeveloper avatar jibbarth avatar laskeju avatar lchrusciel avatar leszczuu avatar lucagallinari avatar mpysiak avatar noresponsemate avatar oallain avatar pamil avatar rafikooo avatar roshyo avatar sirdomin avatar themilek avatar toofff avatar wojdylak avatar zales0123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypalplugin's Issues

Payment from cart page fails, if "Skip shipping step if only one shipping method is available" is activated for channel

I tried to setup Paypal Commerce Checkout.
It works well as a payment method in the checkout process. If the user clicks on the Paypal button on the payment page in the checkout process and proceeds with the payment via Paypal, the shipping and order confimation page is skipped and the user gets directly to the "thank you" page.

However, the direct Paypal payment button on the card page did not work. I figured out that calling "process-pay-pal-order" failed with the following error:

Uncaught PHP Exception SM\SMException: "Transition "select_shipping" cannot be applied on state "shipping_skipped" of object "App\Entity\Order\Order" with graph "sylius_order_checkout"" at /vendor/winzou/state-machine/src/SM/StateMachine/StateMachine.php line 112 {"exception":"[object] (SM\\SMException(code: 0): Transition \"select_shipping\" cannot be applied on state \"shipping_skipped\" of object \"App\\Entity\\Order\\Order\" with graph \"sylius_order_checkout\" at vendor/winzou/state-machine/src/SM/StateMachine/StateMachine.php:112)"}

The error occurs, if for the channel "Skip shipping step if only one shipping method is available" is activated. Once I deactivate the option in the channel config, the Paypal button on the cart page brings the user to the "checkout/complete" page, on which the order has to be confirmed. That works well. However, I think that the order should be confirmed directly (similar as for the Paypal button on the payment page in the checkout process).

Version: v1.2.2

Missing service "monolog.logger.paypal" when installing with composer

Hello,

I have an issue when installing the plugin on Sylius 1.8. The composer installation went fine, but when clearing the cache, the following error appears :

The service "Sylius\PayPalPlugin\Client\PayPalClientInterface" has a dependency on a non-existent service "monolog.logger.paypal".

And indeed I do not find a declaration for this service in the plugin code. The error is gone when I add the following in the services.yaml (of my application) :

services:
    monolog.logger.paypal: '@logger'

Is the declaration service missing or it is something else ?

Thank you !

Add more structure to src/Controller/**

Currently all admin/shop/override controllers are in the same directory, which makes it harder to understand what goes where.

Proposition to use

Controller/Admin/EnableSellerAction.php
Controller/Admin/DownloadPayoutsReportAction.php
Controller/Shop/**
Controller/Webhook/**
Controller/Order/OrderItemController.php

OrderItemController.php can be improved by moving contents to trait OrderItemControllerTrait.php + default controller, so it won't pose problems with integration with other plugins.

Additionally there are security concerns with EnableSellerAction/DownloadPayoutsReportAction, which are loaded with active credentials, but relying on firewall to be correctly configured.

image
I can guarantee, that there would be people missing admin prefix and accidentally exposing those endpoints at shop firewall, seen that multiple times.

As solution, those controllers can be checking for logged in admin user.

[Feedback] Redirected to the homepage instead of the Thank You page

After an order using the Paypal radio button in checkout, not the Yellow PayPal button itself, I arrive on the review step, then I continue. Here, instead of being redirected to the Thank You page with a possibility to end the payment (because I didn't go to PayPal, see #138), I am redirected to the homepage.

The behavior is strange.

Some locales are not supported on PayPal

I configured the payment method with a sandbox account. After clicking on the place order button in the checkout, i land on the payment page but the paypal form/buttons are missing (instead the credit card tab is filled):

payment

And in the console i found this:

GET https://www.paypal.com/sdk/js?components=hosted-fields,buttons&locale=it&client-id=****&merchant-id=****&intent=capture net::ERR_ABORTED 400

If I call the URL i get this error:

"Invalid query value for locale: it"

If i call it with it_IT locale it works.
As i can see from the supported locales in the Paypal docs (https://developer.paypal.com/docs/api/reference/locale-codes/#supported-locale-codes) they do not support 2-digit locales.

So probably a mapping between Sylius locales and Paypal locales is needed?

Paypal Order creation fails due to wrong decimal precision

Sometimes calls to https://api.paypal.com/v2/checkout/orders return a 422 status code response with the following content:

Array(
    [name] => UNPROCESSABLE_ENTITY
    [details] => Array(
            [0] => Array(
                    [field] => /purchase_units/@reference_id=='XXX'/amount/value
                    [value] => 242.79999999999998
                    [issue] => DECIMAL_PRECISION
                    [description] => If the currency supports decimals, only two decimal place precision is supported.
                )
        )
    [message] => The requested action could not be performed, semantically incorrect, or failed business validation.
    [debug_id] => XXX
    [links] => Array(
            [0] => Array(
                    [href] => https://developer.paypal.com/docs/api/orders/v2/#error-DECIMAL_PRECISION
                    [rel] => information_link
                    [method] => GET
                )
        )
)

This is due to the fact that decimal precision is not properly enforced before calling the Paypal Create Order API: it should have exactly 2 decimals. Prices/amounts stored in the DB could be divided by 100 and you should always obtain a number with 2 decimals but the PayPalItemDataProvider does some sums and multiplications on the amounts and it lead to a floating point error.

This could be solved in CreateOrderApi class by enforcing decimal for all amount while setting up data, with something like this:
number_format($amount, 2, '.', '')


Moreover, but maybe it could be discussed in a separate issue, Paypal seems to require a different decimal precision based on the currency: https://developer.paypal.com/docs/api/reference/currency-codes/

Wrong attribute "invoice_number" is used

Hi,

SyliusPayPalPlugin version affected: v1.3.0

Description
During creation and updates of PayPal orders and payments there is used the attribute "invoice_number", this attribute got ignored from PayPal.

Possible Solution
According to the PayPal API doc the attribute should be named "invoice_id"

This has to be changed in the following files:

[Bug] Transition "cancel" is called even on completed or already canceled payment

SyliusPayPalPlugin version affected: >=1.3.2

Description
The "CancelLastPayPalPaymentAction" is called even when the payment page in "unloaded" due to a successful payment. This lead to call the transition "cancel" on the payment even if it's completed and results in an error like this:

Uncaught PHP Exception SM\SMException: "Transition "cancel" cannot be applied on state "completed" of object "App\Entity\Payment\Payment" with graph "sylius_payment""

Steps to reproduce

  1. Place an order with a successful payment
  2. You can see in the network tab or in the log (it depends on your monolog settings) that the request to "cancel-last-pay-pal-payment" failed with a 500.

Possible Solution
This is due to this. The cancel transition is called without checking if it can be run (with ->can()).
There is also this point in which this change should be applied.

3D Secure

Actually the plugin does not "handle" the 3D Secure, and for European countries this is required by the PSD2. Here is the guide to enable it. By using liabilityShifted, authenticationStatus and authenticationReason you can decide if the 3D secure went successful or if it failed, so that the user can be informed on what went wrong and what he can do. Some cases are his fault and others does not depend on him. Some cases can be handled as success or failure depending on merchant.

I don't know if this should be handled by the plugin but at least the doc should be improved to specify that this is required by law for Europe and some links to the doc would be helpful.

LocaleProcessors: wrong locale code and infinite redirect

SyliusPayPalPlugin version affected: v1.2.2

Description
If the locale code passed to the LocalProcessors::process() method is in a ISO 639-1 format Sylius converts that locale in the first ISO 15897 format available (see Symfony\Component\Intl\Locales).
For example IT is converted into it_CH instead of it_IT, so PayPal returns an "Unexpected locale" error during the checkout process.

Moreover, due to the following JS code you can find in vendor/sylius/paypal-plugin/src/Resources/views/payFromCartPage.html.twig, vendor/sylius/paypal-plugin/src/Resources/views/payFromPaymentPage.html.twig and vendor/sylius/paypal-plugin/src/Resources/views/payFromProductPage.html.twig, the page keeps on reloading endlessly.

        onError: function (error) {
            return fetch(errorPayPalPaymentUrl, {
                method: 'post',
                headers: {},
                body: error
            }).then(window.location.reload());
        },

Steps to reproduce

  • Setup a store with IT localization.
  • Enable Sylius PayPal Plugin
  • Go to a product / cart / checkout page

Possible Solution
Due to lack of time, we've not checked if PayPal provides an API endpoint to fetch available locale codes (if they provide it, it would be nice to have a weekly cron that updates a dedicated DB table).
As a temporary (ugly) patch, we've solved this issue in this way:

LocaleProcessor.php

<?php

declare(strict_types=1);

namespace App\VendorExtension\PayPalPlugin\Processor;

use Sylius\PayPalPlugin\Processor\LocaleProcessorInterface;
use Symfony\Component\Intl\Locales;

final class LocaleProcessor implements LocaleProcessorInterface
{

    const DEFAULT_LOCALE = 'en_US';

    private $locales;

    public function __construct()
    {
        $this->locales = json_decode(file_get_contents(dirname(__FILE__, 2) . '/Resources/data/locales.json'));
    }

    public function process(string $locale): string
    {
        if ($this->isValidLocale($locale)) {
            return $locale;
        }

        foreach($this->locales as $refLocale) {
            if (substr($locale, 0, 2) === substr($refLocale->localeCode, 0, 2) && 0 === (int) $refLocale->priority) {
                return $refLocale->localeCode;
            }
        }

        return self::DEFAULT_LOCALE;
    }

    private function isValidLocale(string $locale): bool
    {
        foreach($this->locales as $refLocale) {
            if ($locale === $refLocale->localeCode) {
                return true;
            }
        }

        return false;
    }
}

JS snippet used to generate locales.json

/**
 * INSTRUCTIONS:
 * - Visit https://developer.paypal.com/docs/api/reference/locale-codes/
 * - Open the inspector
 * - Copy the snippet below insided console and run it
 * - Open locales.json
 * - Simply type CTRL+V (Linux and Win) or CMD+V (macOS)
 */

/* eslint-disable no-undef */
const collection = [];

document.querySelectorAll('.ppvx_table.ppvx_table-responsive-sm tr').forEach((el) => {
  const td = el.querySelectorAll('td');
  if (td.length) {
    collection.push({
      region: td[0].textContent,
      regionCode: td[1].textContent.toLowerCase(),
      localeCode: td[3].textContent,
      restApiCode: td[4].textContent,
      priority: parseInt(td[2].textContent, 10),
    });
  }
});

copy(collection);

Wrong service injection for controller CompletePayPalOrderFromPaymentPageAction

Hi,

The controller Sylius\PayPalPlugin\Controller\CompletePayPalOrderFromPaymentPageAction has an attribute $orderManager wich is wrongly injected.

The service fos_oauth_server.entity_manager is used instead of sylius.manager.order which makes the application crash when the API of Sylius is deactivated.

        <service id="Sylius\PayPalPlugin\Controller\CompletePayPalOrderFromPaymentPageAction" public="true">
            <argument type="service" id="Sylius\PayPalPlugin\Manager\PaymentStateManagerInterface" />
            <argument type="service" id="router" />
            <argument type="service" id="Sylius\PayPalPlugin\Provider\OrderProviderInterface" />
            <argument type="service" id="sm.factory" />
            <argument type="service" id="fos_oauth_server.entity_manager" />
        </service>

I will open a PR later today. 👍

Single page onboarding

To improve user experience we should not redirect to onboarding page when creating new payment method.
image

Notice: Undefined index: migrations_paths

Hi 🙂

I tried to install the PayPalPlugin with the command composer require sylius/paypal-plugin
but I got the error Notice: Undefined index: migrations_paths.

I tried to remove the line 48 from SyliusPayPalExtension.php and it fixed the issue...

image

Cannot access to paypal payment with only virtual products in order

SyliusPayPalPlugin version affected: 1.3.1

Description
The Paypal checkout page displays an error when the order only contains virtual product. The error "Error: Expected an order id to be passed [] []" is logged in the Paypal logs.

Steps to reproduce
Add a virtual product (without shipping) to the cart, choose the paypal payment method and got to the checkout Paypal page.

[Bug] Unable to edit PayPal client_id and client_secret in Admin

SyliusPayPalPlugin version affected: 1.10.5

Description
I'm trying to change my PayPal credentials, but the client_id and client_secret are readonly fields in the backend.
Is there a way to change my PayPal credentials?

Thanks

Steps to reproduce
In Admin go to Payment methods -> PayPal and try to edit client_id or client_secret.

Conflict with symplify/package-builder

This packages composer.json marks symplify/package-builder versions "^8.3.24" as conflicting.

With sylius 1.8.5 I get symplify/package-builder version 8.3.48

Sylius/CodingStandard requires "symplify/easy-coding-standard": "^7.3 || ^8.1" (see here)

I can't downgrade symplify/easy-coding-standard to 7.3 because sylius/grid-bundle v1.7.5 conflicts with symplify/smart-file-system v7.3.18

Here is what happens when I composer require sylius/paypal-plugin:

Using version ^1.1 for sylius/paypal-plugin
./composer.json has been updated
Running composer update sylius/paypal-plugin
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires sylius/paypal-plugin ^1.1 -> satisfiable by sylius/paypal-plugin[v1.1.0].
    - symplify/easy-coding-standard 8.3.48 requires symplify/package-builder ^8.3.48 -> satisfiable by symplify/package-builder[8.3.48].
    - sylius-labs/coding-standard v3.2.1 requires symplify/easy-coding-standard ^7.3 || ^8.1 -> satisfiable by symplify/easy-coding-standard[8.3.48].
    - symplify/package-builder 8.3.48 conflicts with sylius/paypal-plugin v1.1.0.
    - sylius-labs/coding-standard is locked to version v3.2.1 and an update of this package was not requested.


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

I don't see how I can work around this.

So what is the reason for the conflict being declared in PayPalPlugin's composer.json in the first place?

Redirect to homepage during checkout

Hi,

i'm testing on my local machine (using the docker containers included in the project), the paypal checkout.
The express checkout is working fine, but the normal one is keep redirecting me to the homepage: without any errors on the screen or in the logs.

After installing xdebug i found this:

{"token":"36b6a8","route":"payum_authorize_do","method":"GET","controller":{"class":"Payum\\Bundle\\PayumBundle\\Controller\\AuthorizeController","method":"doAction","file":"\/srv\/sylius\/vendor\/payum\/payum-bundle\/Controller\/AuthorizeController.php","line":9},"status_code":302,"status_text":"Found"}

I try to insert in that controller action anything: dump, die, exit.
But it seems that is never been called; there is something before i think.

Can someone help me?

Thanks

It's not possible to specify sandbox mode and debugging level based on environment

We cannot do something like this

sylius_pay_pal:
    logging:
        increased: '%env(bool:SYLIUS_PAY_PAL_PLUGIN_LOGGING_INCREASED)%'
    sandbox: '%env(SYLIUS_PAY_PAL_PLUGIN_SANDBOX)%'

cause these configs are loaded in a Dependency Injection Extension class.

The only way to do this actually is through a custom compiler pass that replicate what is done in the SyliusPayPalExtension but by reading the env variables.

This is useful in a staging environment that usually should be identical to production, so APP_ENV=prod, but with some custom env variables, like sandbox mode for payments.

[Feedback] UX issues in the Pay page

image

I think the "Pay" button should be replaced by the Yellow PayPal one if PayPal is selected. Instead of having the yellow button next to the radio button.

It's the same in the checkout.

XHR requests error not handled properly for hosted fields

The two XHR requests made in the hosted fields JS logic in pay with paypal page does not handle errors properly. This leads to a stuck page with an infinite spinner.

This can be easily tested by replicating this issue: #165

I can provide a PR for this

"Expected an order id to be passed" error

Dear Sylius team,

This potentially isn't a bug, but I'm reaching out to you for some help.
I'm trying to use the PayPal Commerce plugin. Installation and configuration went well. The PayPal Buttons are visible on the page. However, when a user clicks on the PayPal button, the sandbox api responds with an error: "Expected an order id to be passed".
I figured out, that the "create-pay-pal-order-from-cart" route does not return an orderID in my case. When the paypal buttons on the cart and payment pages are clicked, the order stays in the "cart" status without attaching the paypal payment entity. Consequently, $payment->getDetails()['paypal_order_id'] (line 78 in CreatePayPalOrderFromCartAction.php) does not provide an OrderID.

Does anyone know, what I might have missed during configuration, which mich explain this issue?

Thanks!

DECIMAL_PRECISION whereas it's only 2

Hello,

I have an issue but I don't understand why, the value are less than 2 decimals...

{
		"application_context": {
			"shipping_preference": "SET_PROVIDED_ADDRESS"
		},
		"intent": "CAPTURE",
		"purchase_units": [
			{
				"amount": {
					"breakdown": {
						"discount": {
							"currency_code": "xxxxxx",
							"value": "xxxxxx"
						},
						"item_total": {
							"currency_code": "EUR",
							"value": 9.71
						},
						"shipping": {
							"currency_code": "EUR",
							"value": 6.5
						},
						"tax_total": {
							"currency_code": "EUR",
							"value": 0
						}
					},
					"currency_code": "EUR",
					"value": 16.21
				},
				"invoice_number": "xxxxxx",
				"items": [
					{
						"name": "Pipe longue coudée REG",
						"quantity": 1,
						"tax": {
							"currency_code": "EUR",
							"value": 0
						},
						"unit_amount": {
							"currency_code": "EUR",
							"value": 9.71
						}
					}
				],
				"payee": {
					"merchant_id": "7KH6PMA7FYN6G"
				},
				"reference_id": "ea7b5eb4-3f51-43fd-b24b-7360ab9951c7",
				"shipping": {
					"address": {
						"address_line_1": "*****",
						"admin_area_2": "Aubeterre-sur-Dronne",
						"country_code": "FR",
						"postal_code": "16390"
					},
					"name": {
						"full_name": "*****"
					}
				},
				"soft_descriptor": "Sylius PayPal Payment"
			}
		]
	}

And the error :

"body": {
		"debug_id": "2ec0be278095d",
		"details": [
			{
				"description": "If the currency supports decimals, only two decimal place precision is supported.",
				"field": "/purchase_units/@reference_id=='2e03277d-110a-4d59-a103-1a38eef64506'/amount/value",
				"issue": "DECIMAL_PRECISION",
				"value": "xxxxxx"
			}
		],
		"links": [
			{
				"href": "https://developer.paypal.com/docs/api/orders/v2/#error-DECIMAL_PRECISION",
				"method": "GET",
				"rel": "information_link"
			}
		],
		"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
		"name": "UNPROCESSABLE_ENTITY"
	}

SO DECIMAL_PRECISION respect the "If the currency supports decimals, only two decimal places are supported." definition with "16.21"...

Can you help me?

Sylius 1.10.2 and Paypal 1.2.2

Got 500 in select payment

When I go to the page of selecting payment method a got the following error:

ArgumentCountError
Too few arguments to function Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType::__construct(), 0 passed in /var/www/html/vendor/symfony/form/FormRegistry.php on line 91 and at least 1 expected

Screenshot_20201107_120555

If I comment in src/Resources/config/services.xml of the plugin the following lines:

<service
    id="sylius.form.type.checkout_select_payment"
    class="Sylius\PayPalPlugin\Form\Type\SelectPaymentType"
>
    <argument>%sylius.model.order.class%</argument>
    <argument>%sylius.form.type.checkout_select_payment.validation_groups%</argument>
    <tag name="form.type" />
</service>

The page works becouse it takes de default SelectPaymentType of sylius.

Notice: Undefined index: status

Hi 🙂

Sometimes I get this error and it is not possible to pay and complete the order.
I'll try to find out why this is happening to give you more details...

Thank you!

[2021-02-27T09:04:31.884693-05:00] paypal.ERROR: POST request to "https://api.paypal.com/v2/checkout/orders" failed with debug ID 1e418bc543e0d [] []
[2021-02-27T09:04:32.000958-05:00] paypal.ERROR: Error: Expected an order id to be passed [] []
[2021-02-27T09:04:36.553244-05:00] paypal.ERROR: Error: Unexpected token < in JSON at position 0 [] []

image

[Bug] Wrong dependency

SyliusPayPalPlugin version affected: 1.4.x

Description

I may be wrong but I think using a dependency to mock the container in the standard require section of the composer.json file sounds wrong:

"require": {
"php": "^7.4 || ^8.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius/sylius": "^1.10",
"phpseclib/phpseclib": "^2.0",
"sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3",
"doctrine/doctrine-migrations-bundle": "^3.0"
},

I guess it's not super-super safe to have it in production as well? (didn't check anything, but since it's testing stuff...)

Possible Solution

Moving it to require-dev section.

Other options of integration PayPal on frontend

For now PayPal buttons is the only supported option for integration PayPal. It would be nice if route /create-pay-pal-order could accept arguments for PayPal createOrder method in it's body.

For example return_url, which is necessary when you don't want to use PayPal buttons, but redirect to checkout instead. Now, when you redirect users to PayPal checkout page, it never returns them to e-shop, because PayPal doesn't have return_url, which should be provided in create PayPal order process as a part of order context. So after approve transaction, PayPal doesn't return user back to the e-shop, but stay on checkout page without option to go back and complete transaction.

PayPayClient shouldn't be using channelContext under the hood

'PayPal-Partner-Attribution-Id' => $this->payPalConfigurationProvider->getPartnerAttributionId($channel),

channelContext makes Client stateful and denies ability to select right Partner-Attribution-Id.

Additionally Partner-Attribution-Id seems optional, but asserted as required at Provider/PayPalConfigurationProvider->getPartnerAttributionId
image

Logic for getting GatewayConfig at Provider/PayPalConfigurationProvider doesn't look production ready as well.

Determine reports host based on payment method

After merging #118 there would be a problem if we have 2 or more PayPal payment methods configured. Providing PayPal configurations based on the channel is good for most cases, but for reports, we need to change it (we cannot base on channel context in Admin panel).

[Feedback] Empty addresses after payment?

After creating an account from a guest order (using the PayPal button on the product page directly), it seems that I have two addresses in my account, but they are empty:

image

Improves validation feedback for hosted fields

Actually, when an hosted field input is invalid it shows a generic "Invalid form" alert. It would be great to have a better feedback so that for the user is clear what's wrong in the form.
I can start a PR if this is something that you would consider

Order with payment "stuck" in processing state when complete request fails

Steps to reproduce

        return $this->client->post(sprintf('v2/checkout/orders/%s/capture', $orderId), $token, null, [
            'PayPal-Mock-Response' => '{"mock_application_codes": "INSTRUMENT_DECLINED"}'
        ]);
  • Place an order
  • In "Pay with Paypal page" use the yellow paypal button, and confirm the payment on Paypal
  • You will be redirected to the homepage, but if you try to retry the payment it will fail cause it's in "PROCESSING" state but the CreatePayPalOrderAction class try to load the last payment with "NEW" state and it won't find any.

Possible solution
This does not happen with HostedFields cause there is an additional check here that cancel the payment if it is still processing after the complete call.
But i think that this solution is weak. If, for example, the user closes the page while the capture request is going on, it will never call the cancel payment. Or maybe due to another error, the cancel payment url could never be called, and the payment of the order will remain PROCESSING.
Probably, it should be responsibility of the CompletePayPalOrderAction controller to cancel the payment if it failed. What do you think?

PayPal plugin KO when using locale "en"

Hi,

I have configured a shop using the locale en which didn't give me errors when I installed it, therefore it is a validate locale

then I struggled for hours to understand why the PayPal button was not showing in the shipment method section and here is the thing :

Your locale is saved in the cart (table sylius_order)
image

and the plugin PayPal uses this variable in /vendor/sylius/paypal-plugin/src/Resources/views/payFromCartPage.html.twig to build the HTTP request to PayPal (for having the javascript library).

When you have en (and I presume it does the problem for other 2 chars locales), it automatically adds a suffix _001

Check bellow

image

https://www.paypal.com/sdk/js?client-id=CLIENT_ID_HIDDEN_FOR_GITHUB&locale=en_001&currency=USD"

This request returns

throw new Error("SDK Validation error: 'Invalid query value for locale: en_001'" );

/* Original Error:

Invalid query value for locale: en_001 (debug id: 1497937e2b6bb)

*/

Hope it can help some people having this issue!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.