Skip to content

Commit

Permalink
Merge branch 'release/1.3.0' into main-6-4
Browse files Browse the repository at this point in the history
  • Loading branch information
thibautgdt committed Jun 7, 2024
2 parents 361a897 + ab380f6 commit ceea3c1
Show file tree
Hide file tree
Showing 24 changed files with 483 additions and 60 deletions.
8 changes: 0 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,6 @@ build:
when: manual
extends: .login_to_registry
script:
- sed -i "s|RELEASE_NAME|$RELEASE_NAME|" ./bin/docker/conf/nginx/proxy_helm.conf
- sed -i "s|URL_DOMAIN|${DOCKER_STACK}-${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}.${URL_CD}|" ./bin/docker/conf/nginx/proxy_helm.conf
- /kaniko/executor
--cache=true
--context "dir://${CI_PROJECT_DIR}"
--dockerfile "./bin/docker/images/proxy/Dockerfile_helm"
--destination "${REGISTRY_CD}/${DOCKER_STACK}-${DOCKER_SERVICE}-proxy:${CI_COMMIT_REF_SLUG}"
- /kaniko/executor
--cache=true
--context "dir://${CI_PROJECT_DIR}"
Expand All @@ -350,7 +343,6 @@ build:
deploy2recette:
stage: deploy
image: $REGISTRY_CI/gitlab-ci-base:deployment
needs: []
rules:
- if: $ONLY_DEPLOY
when: on_success
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Version 1.3.0

- **Add** : Add PayPal v2

## Version 1.2.0

- **Add** : Added new payment means
Expand Down
30 changes: 29 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Contributions to the HiPay Enterprise module for Shopware 6 should be made via G

If you would like to make a significant change, please open an issue to discuss it, in order to minimize duplication of effort.

## Development
### Install

Installation with Docker for testing

Expand Down Expand Up @@ -78,6 +78,34 @@ The login and password are the default: admin / shopware.

You can test the module with your HiPay account configuration.

### Debug

If you want to debug locally our CMS module, here are the steps :

- Verify the value of `XDEBUG_REMOTE_HOST` in your `.env` file you have copied in last step.
- For Linux users, it should be `172.17.0.1` (value by default)
- For MacOS users, replace it by `host.docker.internal`
- Then, create a Xdebug launch according to your IDE (here is for VSCode) :

```json
{
"name": "Shopware",
"type": "php",
"request": "launch",
"hostname": "172.17.0.1", // Only for Linux users
"port": 9000,
"pathMappings": {
"/var/www/html/custom/plugins/HiPayPaymentPlugin/src": "${workspaceFolder}/src",
"/var/www/html/custom/plugins/HiPayPaymentPlugin/composer.json": "${workspaceFolder}/composer.json",
"/var/www/html/custom/plugins/HiPayPaymentPlugin/tests": "${workspaceFolder}/tests",
"/var/www/html": "${workspaceFolder}/web"
},
"runtimeArgs": [
"-dxdebug.idekey=VSCODE"
]
}
```

## Quality & Testing

In order to play tests, install first dependencies: `composer install`
Expand Down
58 changes: 29 additions & 29 deletions bin/docker/images/shopware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ LABEL maintainer="PI-Ecommerce"
LABEL maintainer_email="pi-ecommerce@hipay.com"

RUN echo '\
CAPTURE_MODE=$CAPTURE_MODE \n\
HIPAY_ENVIRONMENT=$HIPAY_ENVIRONMENT \n\
OPERATION_MODE=$OPERATION_MODE \n\
PRIVATE_LOGIN_PRODUCTION=$PRIVATE_LOGIN_PRODUCTION \n\
PRIVATE_PASSWORD_PRODUCTION=$PRIVATE_PASSWORD_PRODUCTION \n\
PUBLIC_LOGIN_PRODUCTION=$PUBLIC_LOGIN_PRODUCTION \n\
PUBLIC_PASSWORD_PRODUCTION=$PUBLIC_PASSWORD_PRODUCTION \n\
PASSPHRASE_PRODUCTION=$PASSPHRASE_PRODUCTION \n\
HASH_PRODUCTION=$HASH_PRODUCTION \n\
PRIVATE_LOGIN_STAGE=$PRIVATE_LOGIN_STAGE \n\
PRIVATE_PASSWORD_STAGE=$PRIVATE_PASSWORD_STAGE \n\
PUBLIC_LOGIN_STAGE=$PUBLIC_LOGIN_STAGE \n\
PUBLIC_PASSWORD_STAGE=$PUBLIC_PASSWORD_STAGE \n\
PASSPHRASE_STAGE=$PASSPHRASE_STAGE \n\
HASH_STAGE=$HASH_STAGE \n\
PRIVATE_APPLEPAY_LOGIN_PRODUCTION=$PRIVATE_APPLEPAY_LOGIN_PRODUCTION \n\
PRIVATE_APPLEPAY_PASSWORD_PRODUCTION=$PRIVATE_APPLEPAY_PASSWORD_PRODUCTION \n\
PUBLIC_APPLEPAY_LOGIN_PRODUCTION=$PUBLIC_APPLEPAY_LOGIN_PRODUCTION \n\
PUBLIC_APPLEPAY_PASSWORD_PRODUCTION=$PUBLIC_APPLEPAY_PASSWORD_PRODUCTION \n\
APPLEPAY_PASSPHRASE_PRODUCTION=$APPLEPAY_PASSPHRASE_PRODUCTION \n\
HASH_PRODUCTION_APPLEPAY=$HASH_PRODUCTION_APPLEPAY \n\
PRIVATE_APPLEPAY_LOGIN_STAGE=$PRIVATE_APPLEPAY_LOGIN_STAGE \n\
PRIVATE_APPLEPAY_PASSWORD_STAGE=$PRIVATE_APPLEPAY_PASSWORD_STAGE \n\
PUBLIC_APPLEPAY_LOGIN_STAGE=$PUBLIC_APPLEPAY_LOGIN_STAGE \n\
PUBLIC_APPLEPAY_PASSWORD_STAGE=$PUBLIC_APPLEPAY_PASSWORD_STAGE \n\
APPLEPAY_PASSPHRASE_STAGE=$APPLEPAY_PASSPHRASE_STAGE \n\
HASH_STAGE_APPLEPAY=$HASH_STAGE_APPLEPAY \n\
LOG_DEBUG=$LOG_DEBUG \
' >>.env
CAPTURE_MODE=$CAPTURE_MODE \n\
HIPAY_ENVIRONMENT=$HIPAY_ENVIRONMENT \n\
OPERATION_MODE=$OPERATION_MODE \n\
PRIVATE_LOGIN_PRODUCTION=$PRIVATE_LOGIN_PRODUCTION \n\
PRIVATE_PASSWORD_PRODUCTION=$PRIVATE_PASSWORD_PRODUCTION \n\
PUBLIC_LOGIN_PRODUCTION=$PUBLIC_LOGIN_PRODUCTION \n\
PUBLIC_PASSWORD_PRODUCTION=$PUBLIC_PASSWORD_PRODUCTION \n\
PASSPHRASE_PRODUCTION=$PASSPHRASE_PRODUCTION \n\
HASH_PRODUCTION=$HASH_PRODUCTION \n\
PRIVATE_LOGIN_STAGE=$PRIVATE_LOGIN_STAGE \n\
PRIVATE_PASSWORD_STAGE=$PRIVATE_PASSWORD_STAGE \n\
PUBLIC_LOGIN_STAGE=$PUBLIC_LOGIN_STAGE \n\
PUBLIC_PASSWORD_STAGE=$PUBLIC_PASSWORD_STAGE \n\
PASSPHRASE_STAGE=$PASSPHRASE_STAGE \n\
HASH_STAGE=$HASH_STAGE \n\
PRIVATE_APPLEPAY_LOGIN_PRODUCTION=$PRIVATE_APPLEPAY_LOGIN_PRODUCTION \n\
PRIVATE_APPLEPAY_PASSWORD_PRODUCTION=$PRIVATE_APPLEPAY_PASSWORD_PRODUCTION \n\
PUBLIC_APPLEPAY_LOGIN_PRODUCTION=$PUBLIC_APPLEPAY_LOGIN_PRODUCTION \n\
PUBLIC_APPLEPAY_PASSWORD_PRODUCTION=$PUBLIC_APPLEPAY_PASSWORD_PRODUCTION \n\
APPLEPAY_PASSPHRASE_PRODUCTION=$APPLEPAY_PASSPHRASE_PRODUCTION \n\
HASH_PRODUCTION_APPLEPAY=$HASH_PRODUCTION_APPLEPAY \n\
PRIVATE_APPLEPAY_LOGIN_STAGE=$PRIVATE_APPLEPAY_LOGIN_STAGE \n\
PRIVATE_APPLEPAY_PASSWORD_STAGE=$PRIVATE_APPLEPAY_PASSWORD_STAGE \n\
PUBLIC_APPLEPAY_LOGIN_STAGE=$PUBLIC_APPLEPAY_LOGIN_STAGE \n\
PUBLIC_APPLEPAY_PASSWORD_STAGE=$PUBLIC_APPLEPAY_PASSWORD_STAGE \n\
APPLEPAY_PASSPHRASE_STAGE=$APPLEPAY_PASSPHRASE_STAGE \n\
HASH_STAGE_APPLEPAY=$HASH_STAGE_APPLEPAY \n\
LOG_DEBUG=$LOG_DEBUG \
' >>.env

COPY . /var/www/html/custom/plugins/HiPayPaymentPlugin/

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hipay/hipay-enterprise-shopware-6",
"description": "HiPay enterprise plugin for Shopware 6",
"license": "Apache-2.0",
"version": "1.2.0",
"version": "1.3.0",
"authors": [
{
"email": "support.tpp@hipay.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function calculCapturedAmountInProgress(): float
return $capturedAmount;
}

public function getCaptureByOperationId(string $operationId, string $status = null): ?OrderCaptureEntity
public function getCaptureByOperationId(string $operationId, ?string $status = null): ?OrderCaptureEntity
{
$result = array_filter($this->getElements(), function (OrderCaptureEntity $capture) use ($operationId, $status) {
if ($status) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Checkout/Payment/Refund/OrderRefundCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function calculRefundedAmountInProgress(): float
return $refundedAmount;
}

public function getRefundByOperationId(string $operationId, string $status = null): ?OrderRefundEntity
public function getRefundByOperationId(string $operationId, ?string $status = null): ?OrderRefundEntity
{
$result = array_filter($this->getElements(), function (OrderRefundEntity $refund) use ($operationId, $status) {
if ($status) {
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentMethod/AbstractPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ private function getOrderCustomers(string $customerId): OrderCustomerCollection
*
* @param int $format libphonenumber\PhoneNumberFormat\PhoneNumberFormat const
*/
protected function formatPhoneNumber(?string $phoneNumber, string $isoCountry = null, int $format = PhoneNumberFormat::E164): ?string
protected function formatPhoneNumber(?string $phoneNumber, ?string $isoCountry = null, int $format = PhoneNumberFormat::E164): ?string
{
try {
$phoneUtil = PhoneNumberUtil::getInstance();
Expand Down
31 changes: 24 additions & 7 deletions src/PaymentMethod/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace HiPay\Payment\PaymentMethod;

use HiPay\Fullservice\Data\PaymentProduct;
use HiPay\Fullservice\Gateway\Request\Order\OrderRequest;
use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct;

/**
* Paypal payment Methods.
Expand All @@ -18,12 +20,8 @@ class Paypal extends AbstractPaymentMethod
/** {@inheritDoc} */
protected const PAYMENT_IMAGE = 'paypal.svg';

/** {@inheritDoc} */
protected static PaymentProduct $paymentConfig;

/**
* {@inheritDoc}
*/
public static function getName(string $lang): ?string
{
$names = [
Expand All @@ -34,9 +32,6 @@ public static function getName(string $lang): ?string
return $names[$lang] ?? null;
}

/**
* {@inheritDoc}
*/
public static function getDescription(string $lang): ?string
{
$descriptions = [
Expand All @@ -46,4 +41,26 @@ public static function getDescription(string $lang): ?string

return $descriptions[$lang] ?? null;
}

public static function addDefaultCustomFields(): array
{
return [
'merchantPayPalId' => '',
'color' => 'gold',
'shape' => 'pill',
'label' => 'paypal',
'height' => '40',
'bnpl' => true,
];
}

protected function hydrateHostedFields(OrderRequest $orderRequest, array $payload, AsyncPaymentTransactionStruct $transaction): OrderRequest
{
if ('paypal' === $orderRequest->payment_product && isset($payload['orderID'])) {
$providerData = ['paypal_id' => $payload['orderID']];
$orderRequest->provider_data = (string) json_encode($providerData);
}

return $orderRequest;
}
}
1 change: 1 addition & 0 deletions src/Resources/app/administration/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './config/hipay-download-logs';
import './settings/hipay-settings-cards-selector';
import './settings/hipay-settings-multibanco';
import './settings/hipay-settings-applepay';
import './settings/hipay-settings-paypal';

import './override/sw-data-grid';
import './override/sw-order-detail-base';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
<hipay-settings-multibanco :is-loading="isLoading"
:paymentMethod="paymentMethod"></hipay-settings-multibanco>
</template>
<template v-if="paymentMethod.formattedHandlerIdentifier == 'handler_hipay_paypal'">
<hipay-settings-paypal :is-loading="isLoading"
:paymentMethod="paymentMethod"></hipay-settings-paypal>
</template>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<sw-card position-identifier="sw-settings-payment-detail-content"
:title="$tc('hipay.settings.paypal.title')"
:is-loading="isLoading">

<sw-alert>
<div>{{ $tc('hipay.settings.paypal.info')}}</div>
</sw-alert>

<sw-text-field :label="$tc('hipay.settings.paypal.merchantPayPalId')"
:value="paymentMethod.customFields?.merchantPayPalId"
:disabled="false"
@change="updateMerchantPayPalId"
@input="updatePayPalStatus">
</sw-text-field>

<sw-select-field :label="$tc('hipay.settings.paypal.color.title')"
:value="paymentMethod.customFields?.color || 'gold'"
:disabled="!isPayPalV2"
@change="updateColor">
<option
v-for="color in colors"
:key="color.value"
:value="color.value"
>
{{ color.label }}
</option>
</sw-select-field>

<sw-select-field :label="$tc('hipay.settings.paypal.shape.title')"
:value="paymentMethod.customFields?.shape || 'pill'"
:disabled="!isPayPalV2"
@change="updateShape">
<option
v-for="shape in shapes"
:key="shape.value"
:value="shape.value"
>
{{ shape.label }}
</option>
</sw-select-field>

<sw-select-field :label="$tc('hipay.settings.paypal.label.title')"
:value="paymentMethod.customFields?.label || 'paypal'"
:disabled="!isPayPalV2"
@change="updateLabel">
<option
v-for="label in labels"
:key="label.value"
:value="label.value"
>
{{ label.label }}
</option>
</sw-select-field>

<sw-number-field numberType="int"
:disabled="!isPayPalV2"
:label="$tc('hipay.settings.paypal.height.title')"
:step="1"
:min="25"
:max="55"
:value="paymentMethod.customFields?.height || '40'"
:digits="2"
:fillDigits="false"
:allowEmpty="true"
@change="updateHeight">
</sw-number-field>

<sw-alert>
<div>{{ $tc('hipay.settings.paypal.info_bnpl')}}</div>
</sw-alert>

<sw-switch-field
:value="paymentMethod.customFields?.bnpl"
:disabled="!isPayPalV2"
:label="$tc('hipay.settings.paypal.bnpl_label')"
@change="updateBnpl"
></sw-switch-field>
</sw-card>
Loading

0 comments on commit ceea3c1

Please sign in to comment.