Skip to content

Commit

Permalink
Merge pull request #12 from alma/feature/MPP-555/add-p1012x
Browse files Browse the repository at this point in the history
add p10/12x
  • Loading branch information
Benjamin-Freoua-Alma authored Sep 21, 2023
2 parents b1fc4b9 + f322d0b commit 9a1cdfa
Show file tree
Hide file tree
Showing 59 changed files with 903 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* [email protected]
* [email protected]
* [email protected]

31 changes: 31 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Reason for change

<!-- Describe here the reason for change, and provide a link to the corresponding ClickUp task or Sentry issue. -->

[ClickUp task](https://app.clickup.com/20427503/v/b/4-32476982-2/CLICKUP_ISSUE_ID)

### Code changes

<!-- Describe here the code changes at a high level. Anything that can help reviewers review your PR. -->

### How to test

_As a reviewer, you are encouraged to test the PR locally._

<!-- Describe here how to test your changes, if applicable. Insert UI screenshots when relevant -->

### Checklist for authors and reviewers

<!-- Move to the next section the non applicable items -->

- [ ] The title of the PR uses business wording, not technical jargon, for the changelog readers to understand it
- [ ] The PR implements the changes asked in the referenced task / issue
- [ ] The automated tests are compliant with the [testing strategy](https://www.notion.so/almapay/Backend-testing-strategy-06c642cec1bf47b9b8feca3a91ea8d4a)
- [ ] The tests are relevant, and cover the corner/error cases, not only the happy path
- [ ] You understand the impact of this PR on existing code/features
- [ ] The changes include adequate logging and Datadog traces
- [ ] Documentation is updated (API, developer documentation, ADR, Notion...)

### Non applicable

<!-- Move here non applicable items of the checklist, if any -->
30 changes: 30 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PHP Composer

on:
push:
branches: [main,develop]
pull_request:
branches: [main,develop]
workflow_dispatch: ~

jobs:
lint:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: .

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/vendor/
/node_modules/
/composer.lock

.idea/*
/etc/build/*
!/etc/build/.gitignore

Expand All @@ -11,3 +11,4 @@
/behat.yml
/phpspec.yml
/phpunit.xml
/crowdin.yaml
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

v2.0.0
------

- Fix: Compatibility Sylius 1.12
- Feat: Add installment P10/12X
- Feat: Display installment's plan in checkout page

v1.3.0
------

Expand Down
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,54 @@
## Documentation

### Installation
Use Composer to install the plugin:
1. Use Composer to install the plugin:

```
$ composer require alma/sylius-payment-plugin
```

Update your shop's translation catalogs:
2. Import routes:

```
# config/routes/sylius_shop.yaml
sylius_alma:
resource: "@AlmaSyliusPaymentPlugin/Resources/config/shop_routing.yaml"
prefix: /{_locale}
requirements:
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
```

3. Override Sylius' templates:

```
cp -R vendor/alma/sylius-payment-plugin/src/Resources/views/bundles/* templates/bundles/
```

4. Export assets:

```
bin/console sylius:install:asset
```

5. Update your shop's translation catalogs:

```
$ php bin/console translation:update --dump-messages fr AlmaSyliusPaymentPlugin
$ php bin/console translation:update --dump-messages en AlmaSyliusPaymentPlugin
```

Finally, clear your cache:
6. Finally, clear your cache:

```
$ php bin/console cache:clear
```

### Requirements

- PHP version >= 7.3
- Sylius version >= 1.9.0

Alma currently accepts Euros only; make sure you activate your payment method on channels that use that currency, else
you won't see it at checkout.

Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~

Lakion\Behat\MinkDebugExtension:
FriendsOfBehat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true
Expand Down
45 changes: 26 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"description": "Payment plugin to integrate Alma installments and pay later payments with your Sylius shop",
"license": "MIT",
"require": {
"php": ">=7.1",
"alma/alma-php-client": "^1.11.1",
"sylius/sylius": ">=1.6.9",
"php": "~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2",
"alma/alma-php-client": ">=1.11.2",
"sylius/sylius": ">=v1.9.0",
"ext-json": "*"
},
"require-dev": {
Expand All @@ -30,23 +30,23 @@
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friends-of-behat/mink-debug-extension": "^2.1.0",
"phpspec/phpspec": "^6.1|^7.0",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"lakion/mink-debug-extension": "^2.0.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "1.10.29",
"phpstan/phpstan-doctrine": "^1.3.42",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpstan/phpstan-webmozart-assert": "^1.2.4",
"phpunit/phpunit": "^8.5",
"phpstan/phpstan": "0.12.88",
"phpstan/phpstan-doctrine": "0.12.37",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.3.1",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4|^5.0",
"symfony/dotenv": "^4.4|^5.0",
"symfony/intl": "^4.4|^5.0",
"symfony/web-profiler-bundle": "^4.4|^5.0",
"symfony/web-server-bundle": "^4.4|^5.0",
"vimeo/psalm": "3.11.4"
"sylius-labs/coding-standard": "^3.1",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/intl": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"vimeo/psalm": "4.6.4"
},
"autoload": {
"psr-4": {
Expand All @@ -62,12 +62,19 @@
"Tests\\Alma\\SyliusPaymentPlugin\\": "tests/"
}
},
"authors": [
{
"name": "Alma",
"email": "[email protected]"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/thanks": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"symfony/flex": true
}
}
}
13 changes: 13 additions & 0 deletions crowdin.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"project_id" : "35"
"api_token" : "MY_API_TOKEN"
"base_path" : "src/"
"base_url" : "https://mycompany.crowdin.com"
"preserve_hierarchy": true

files:
-
source: Resources/translations/messages.en.yml
translation: Resources/translations/messages.%two_letters_code%.yml
-
source: Resources/translations/flashes.en.yml
translation: Resources/translations/flashes.%two_letters_code%.yml
15 changes: 0 additions & 15 deletions phpstan.neon

This file was deleted.

2 changes: 1 addition & 1 deletion src/AlmaSyliusPaymentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

final class AlmaSyliusPaymentPlugin extends Bundle
{
const VERSION = "1.3.0";
const VERSION = "2.0.0";

use SyliusPluginTrait;

Expand Down
17 changes: 17 additions & 0 deletions src/Bridge/AlmaBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ function getEligibilities(PaymentInterface $payment, array $installmentsCounts):
return [];
}

/**
* Retrieve the eligibilities from the data array sent
*
* @param array $data
* @return \Alma\API\Endpoints\Results\Eligibility|\Alma\API\Endpoints\Results\Eligibility[]|array
*/
public function retrieveEligibilities(array $data)
{
$alma = $this->getDefaultClient();
try {
return $alma->payments->eligibility($data, true);
} catch (RequestError $e) {
$this->logger->error("[Alma] Eligibility call failed with error: " . $e->getMessage());
}

return [];
}
/**
* @inheritDoc
*/
Expand Down
Loading

0 comments on commit 9a1cdfa

Please sign in to comment.