diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6369f46..728643b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.1.15
+- Send customer first name and last name from billing and shipping profiles
+- Respect Shop URL
+
# 1.1.14
- Add cookies to the cookie manager
- Resize icon to 40px * 40px
diff --git a/README.md b/README.md
index f1749d9..6293b28 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ account dashboard.
## Documentation
-[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/shopware-6/1.1.14/docs/en/documentation.html)
+[Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/shopware-6/1.1.15/docs/en/documentation.html)
## License
diff --git a/composer.json b/composer.json
index a341670..2c424bd 100644
--- a/composer.json
+++ b/composer.json
@@ -54,5 +54,5 @@
"postfinancecheckout/sdk": "2.1.0"
},
"type": "shopware-platform-plugin",
- "version": "1.1.14"
+ "version": "1.1.15"
}
\ No newline at end of file
diff --git a/docs/en/documentation.html b/docs/en/documentation.html
index 9e34e20..9a38cd8 100644
--- a/docs/en/documentation.html
+++ b/docs/en/documentation.html
@@ -22,7 +22,7 @@
Documentation
-
+
Source
diff --git a/src/Core/Api/Transaction/Service/TransactionService.php b/src/Core/Api/Transaction/Service/TransactionService.php
index 60a179b..dc64c01 100644
--- a/src/Core/Api/Transaction/Service/TransactionService.php
+++ b/src/Core/Api/Transaction/Service/TransactionService.php
@@ -54,10 +54,10 @@ class TransactionService {
/**
* TransactionService constructor.
+ *
* @param \Psr\Container\ContainerInterface $container
* @param \PostFinanceCheckoutPayment\Core\Util\LocaleCodeProvider $localeCodeProvider
* @param \PostFinanceCheckoutPayment\Core\Settings\Service\SettingsService $settingsService
- * @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
ContainerInterface $container,
diff --git a/src/Core/Storefront/Checkout/Controller/CheckoutController.php b/src/Core/Storefront/Checkout/Controller/CheckoutController.php
index 78cbf0b..3596136 100644
--- a/src/Core/Storefront/Checkout/Controller/CheckoutController.php
+++ b/src/Core/Storefront/Checkout/Controller/CheckoutController.php
@@ -20,13 +20,12 @@
Page\Checkout\Finish\CheckoutFinishPage,
Page\GenericPageLoader,};
use Symfony\Component\{
- HttpFoundation\JsonResponse,
HttpFoundation\Request,
HttpFoundation\Response,
Routing\Annotation\Route};
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use PostFinanceCheckout\Sdk\{
Model\Transaction,
- Model\TransactionPending,
Model\TransactionState};
use PostFinanceCheckoutPayment\Core\{
Api\Transaction\Service\TransactionService,
@@ -186,7 +185,17 @@ public function pay(SalesChannelContext $salesChannelContext, Request $request):
->setIntegration($this->settings->getIntegration())
->setJavascriptUrl($javascriptUrl)
->setDeviceJavascriptUrl($this->settings->getSpaceId(), $this->container->get('session')->getId())
- ->setTransactionPossiblePaymentMethods($possiblePaymentMethods);
+ ->setTransactionPossiblePaymentMethods($possiblePaymentMethods)
+ ->setCheckoutUrl($this->generateUrl(
+ 'frontend.postfinancecheckout.checkout.pay',
+ ['orderId' => $orderId,],
+ UrlGeneratorInterface::ABSOLUTE_URL
+ ))
+ ->setCartRecreateUrl($this->generateUrl(
+ 'frontend.postfinancecheckout.checkout.recreate-cart',
+ ['orderId' => $orderId,],
+ UrlGeneratorInterface::ABSOLUTE_URL
+ ));
$page->addExtension('postFinanceCheckoutData', $checkoutPageData);
diff --git a/src/Core/Storefront/Checkout/Struct/CheckoutPageData.php b/src/Core/Storefront/Checkout/Struct/CheckoutPageData.php
index ede95a6..c43bd52 100644
--- a/src/Core/Storefront/Checkout/Struct/CheckoutPageData.php
+++ b/src/Core/Storefront/Checkout/Struct/CheckoutPageData.php
@@ -10,36 +10,77 @@
* @package PostFinanceCheckoutPayment\Storefront\Checkout\Struct
*/
class CheckoutPageData extends Struct {
+
/**
* @var string
*/
- protected $deviceJavascriptUrl;
+ protected $cartRecreateUrl;
+ /**
+ * @var string
+ */
+ protected $checkoutUrl;
+ /**
+ * @var string
+ */
+ protected $deviceJavascriptUrl;
/**
* @var string
*/
protected $integration;
-
/**
* @var string
*/
protected $javascriptUrl;
-
/**
* @var string
*/
protected $paymentMethodId;
-
/**
* @var array
*/
protected $possiblePaymentMethodsArray = [];
-
/**
* @var array
*/
protected $transactionPossiblePaymentMethods = [];
+ /**
+ * @return string
+ */
+ public function getCartRecreateUrl(): string
+ {
+ return $this->cartRecreateUrl;
+ }
+
+ /**
+ * @param string $cartRecreateUrl
+ * @return CheckoutPageData
+ */
+ public function setCartRecreateUrl(string $cartRecreateUrl): CheckoutPageData
+ {
+ $this->cartRecreateUrl = $cartRecreateUrl;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCheckoutUrl(): string
+ {
+ return $this->checkoutUrl;
+ }
+
+ /**
+ * @param string $checkoutUrl
+ * @return CheckoutPageData
+ */
+ public function setCheckoutUrl(string $checkoutUrl): CheckoutPageData
+ {
+ $this->checkoutUrl = $checkoutUrl;
+ return $this;
+ }
+
/**
* @return string
*/
diff --git a/src/Core/Util/Payload/TransactionPayload.php b/src/Core/Util/Payload/TransactionPayload.php
index 13777a5..1e58677 100644
--- a/src/Core/Util/Payload/TransactionPayload.php
+++ b/src/Core/Util/Payload/TransactionPayload.php
@@ -360,17 +360,59 @@ protected function getAdjustmentLineItem(array &$lineItems): ?LineItemCreate
*/
protected function getAddressPayload(CustomerEntity $customer, CustomerAddressEntity $customerAddressEntity): AddressCreate
{
+ // Family name
+ $family_name = null;
+ if (!empty($customerAddressEntity->getLastName())) {
+ $family_name = $customerAddressEntity->getLastName();
+ } else {
+ if (!empty($customer->getLastName())) {
+ $family_name = $customer->getLastName();
+ }
+ }
+ $family_name = !empty($family_name) ? $this->fixLength($family_name, 100) : null;
+
+ // Given name
+ $given_name = null;
+ if (!empty($customerAddressEntity->getFirstName())) {
+ $given_name = $customerAddressEntity->getFirstName();
+ } else if (!empty($customer->getFirstName())) {
+ $given_name = $customer->getFirstName();
+ }
+ $given_name = !empty($given_name) ? $this->fixLength($given_name, 100) : null;
+
+ // Organization name
+ $organization_name = null;
+ if (!empty($customerAddressEntity->getCompany())) {
+ $organization_name = $customerAddressEntity->getCompany();
+ } else if (!empty($customer->getCompany())) {
+ $organization_name = $customer->getCompany();
+ }
+ $organization_name = !empty($organization_name) ? $this->fixLength($organization_name, 100) : null;
+
+ // Salutation
+ $salutation = null;
+ if (!(
+ empty($customerAddressEntity->getSalutation()) ||
+ empty($customerAddressEntity->getSalutation()->getDisplayName())
+ )) {
+ $salutation = $customerAddressEntity->getSalutation()->getDisplayName();
+ } else if (!empty($customer->getSalutation())) {
+ $salutation = $customer->getSalutation()->getDisplayName();
+
+ }
+ $salutation = !empty($salutation) ? $this->fixLength($salutation, 20) : null;
+
$addressData = [
'city' => $customerAddressEntity->getCity() ? $this->fixLength($customerAddressEntity->getCity(), 100) : null,
'country' => $customerAddressEntity->getCountry() ? $customerAddressEntity->getCountry()->getIso() : null,
'email_address' => $customer->getEmail() ? $this->fixLength($customer->getEmail(), 254) : null,
- 'family_name' => $customer->getLastName() ? $this->fixLength($customer->getLastName(), 100) : null,
- 'given_name' => $customer->getFirstName() ? $this->fixLength($customer->getFirstName(), 100) : null,
- 'organization_name' => $customer->getCompany() ? $this->fixLength($customer->getCompany(), 100) : null,
+ 'family_name' => $family_name,
+ 'given_name' => $given_name,
+ 'organization_name' => $organization_name,
'phone_number' => $customerAddressEntity->getPhoneNumber() ? $this->fixLength($customerAddressEntity->getPhoneNumber(), 100) : null,
'postcode' => $customerAddressEntity->getZipcode() ? $this->fixLength($customerAddressEntity->getZipcode(), 40) : null,
'postal_state' => $customerAddressEntity->getCountryState() ? $customerAddressEntity->getCountryState()->getShortCode() : null,
- 'salutation' => $customer->getSalutation() ? $this->fixLength($customer->getSalutation()->getDisplayName(), 20) : null,
+ 'salutation' => $salutation,
'street' => $customerAddressEntity->getStreet() ? $this->fixLength($customerAddressEntity->getStreet(), 300) : null,
];
diff --git a/src/Resources/public/storefront/js/app.js b/src/Resources/public/storefront/js/app.js
index bd11ce4..a0c9fb2 100644
--- a/src/Resources/public/storefront/js/app.js
+++ b/src/Resources/public/storefront/js/app.js
@@ -29,10 +29,11 @@
payment_method_handler_status: 'input[name="postfinancecheckout_payment_handler_validation_status"]',
payment_form_id: 'confirmOrderForm',
button_cancel_id: 'postfinancecheckoutOrderCancel',
- order_id: '',
loader_id: 'postfinancecheckoutLoader',
- pay_url: '/postfinancecheckout/checkout/pay?orderId=',
- recreate_cart_url: '/postfinancecheckout/checkout/recreate-cart?orderId=',
+ checkout_url: null,
+ checkout_url_id: 'checkoutUrl',
+ cart_recreate_url: null,
+ cart_recreate_url_id: 'cartRecreateUrl',
handler: null,
/**
@@ -40,9 +41,8 @@
*/
init: function () {
PostFinanceCheckoutCheckout.activateLoader(true);
- this.order_id = this.getParameterByName('orderId');
- this.pay_url += this.order_id;
- this.recreate_cart_url += this.order_id;
+ this.checkout_url = document.getElementById(this.checkout_url_id).value;
+ this.cart_recreate_url = document.getElementById(this.cart_recreate_url_id).value;
document.getElementById(this.button_cancel_id).addEventListener('click', this.recreateCart, false);
document.getElementById(this.payment_form_id).addEventListener('submit', this.submitPayment, false);
@@ -64,7 +64,7 @@
},
recreateCart: function (e) {
- window.location.href = PostFinanceCheckoutCheckout.recreate_cart_url;
+ window.location.href = PostFinanceCheckoutCheckout.cart_recreate_url;
e.preventDefault();
},
@@ -159,24 +159,6 @@
if (errorElement) {
errorElement.parentNode.removeChild(errorElement);
}
- },
-
- /**
- * Get query name value
- *
- * @param name
- * @param url
- * @link https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
- * @return {*}
- */
- getParameterByName: function (name, url) {
- if (!url) url = window.location.href;
- name = name.replace(/[\[\]]/g, '\\$&');
- const regex = new RegExp('[?&]' + name + '(=([^]*)|&|#|$)'),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
};
@@ -189,13 +171,17 @@
*/
window.addEventListener('load', function (e) {
PostFinanceCheckoutCheckout.init();
- window.history.pushState({}, document.title, PostFinanceCheckoutCheckout.recreate_cart_url);
- window.history.pushState({}, document.title, PostFinanceCheckoutCheckout.pay_url);
+ window.history.pushState({}, document.title, PostFinanceCheckoutCheckout.cart_recreate_url);
+ window.history.pushState({}, document.title, PostFinanceCheckoutCheckout.checkout_url);
}, false);
+/**
+ * This only works if the user has interacted with the page
+ * @link https://stackoverflow.com/questions/57339098/chrome-popstate-not-firing-on-back-button-if-no-user-interaction
+ */
window.addEventListener('popstate', function (e) {
if (window.history.state == null) { // This means it's page load
return;
}
- window.location.href = PostFinanceCheckoutCheckout.recreate_cart_url;
+ window.location.href = PostFinanceCheckoutCheckout.cart_recreate_url;
}, false);
\ No newline at end of file
diff --git a/src/Resources/views/storefront/page/checkout/order/postfinancecheckout.html.twig b/src/Resources/views/storefront/page/checkout/order/postfinancecheckout.html.twig
index 48f496d..a797d94 100644
--- a/src/Resources/views/storefront/page/checkout/order/postfinancecheckout.html.twig
+++ b/src/Resources/views/storefront/page/checkout/order/postfinancecheckout.html.twig
@@ -56,6 +56,8 @@
{% block page_checkout_aside_actions %}