Commit e078b0ce authored by Rik ter Beek's avatar Rik ter Beek

implemented some functionality for apple pay for the web

parent 2749977b
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Block;
use Magento\Framework\View\Element\Template;
class ApplePay extends \Magento\Framework\View\Element\Template
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var \Adyen\Payment\Helper\ApplePay
*/
protected $_adyenApplePayHelper;
/**
* @var \Magento\Customer\Model\Session
*/
protected $_customerSession;
/**
* Customer session
*
* @var \Magento\Framework\App\Http\Context
*/
protected $httpContext;
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry;
/**
* @var ProductRepositoryInterface
*/
protected $_productRepository;
/**
* @var \Magento\Customer\Helper\Session\CurrentCustomer
*/
protected $_currentCustomer;
/**
* Constructor
*
* @param Template\Context $context
* @param array $data
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Helper\ApplePay $adyenApplePayHelper,
\Magento\Customer\Model\Session $customerSession,
\Magento\Framework\App\Http\Context $httpContext,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
\Magento\Catalog\Block\Product\Context $productContext,
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
Template\Context $context,
array $data = []
) {
$this->_adyenHelper = $adyenHelper;
$this->_adyenApplePayHelper = $adyenApplePayHelper;
$this->_customerSession = $customerSession;
$this->httpContext = $httpContext;
$this->_productRepository = $productRepository;
if ($productContext) {
$this->_coreRegistry = $productContext->getRegistry();
}
$this->_currentCustomer = $currentCustomer;
parent::__construct($context, $data);
// $this->_isScopePrivate = true;
}
/**
* @return bool
*/
public function hasApplePayEnabled()
{
if (!$this->_adyenHelper->getAdyenApplePayConfigDataFlag("active")) {
return false;
}
// if user is not logged in and quest checkout is not enabled don't show the button
if ($this->_customerSession->isLoggedIn() &&
!$this->_adyenHelper->getAdyenApplePayConfigData('allow_quest_checkout')) {
return false;
}
return true;
}
/**
* Retrieve current product model
*
* @return \Magento\Catalog\Model\Product
*/
public function getProduct()
{
if ($this->_coreRegistry) {
if (!$this->_coreRegistry->registry('product') && $this->getProductId()) {
$product = $this->_productRepository->getById($this->getProductId());
$this->_coreRegistry->register('product', $product);
}
$product = $this->_coreRegistry->registry('product');
print_r(get_class($product));die();
return $this->_coreRegistry->registry('product');
}
return null;
}
/**
* @return array
*/
public function getShippingMethods()
{
echo 'getShippingMethods';
$product = $this->getProduct();
// print_r($this->_customerSession->getId());
//die();
if ($this->_customerSession->isLoggedIn()) {
echo "LOGGED IN CORRECT WAY";
}
if ($this->isLoggedIn()) {
// logged in
echo 'loggedin';
$customerId = $this->_currentCustomer->getCustomerId();
echo 'customerid:'.$customerId;
echo 'customerid2:'. $this->_customerSession->getCustomerId();
echo 'test';
echo 'end';
die();
// $defaultBilling = $this->getCustomerSession()->getCustomer()->getDefaultBilling();
}
}
/**
* @return mixed
*/
public function getMerchantIdentifier()
{
return $this->_adyenHelper->getApplePayMerchantIdentifier();
}
/**
* Only possible if quest checkout is turned off
*
* @return bool
*/
public function optionToChangeAddress()
{
if (
!$this->_adyenHelper->getAdyenApplePayConfigData('allow_quest_checkout')
) {
return $this->_adyenHelper->getAdyenApplePayConfigData('change_address');
}
return true;
}
/**
* @return mixed
*/
public function getShippingType()
{
return $this->_adyenHelper->getAdyenApplePayConfigData('shipping_type');
}
/**
* Is logged in
*
* @return bool
*/
public function isLoggedIn()
{
return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
}
/**
* retrieve customer session
*/
public function getCustomerSession()
{
return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH)->getSession();
}
/**
* Renders captcha HTML (if required)
*
* @return string
*/
// protected function _toHtml()
// {
//// $data = $this->_adyenApplePayHelper->getApplePayData();
//// print_r($data);die();
//
//// if ($this->_customerSession->isLoggedIn()) {
//// echo "LOGGED IN CORRECT WAY";
//// }
//
//// die();
//
////// $blockPath = $this->_captchaData->getCaptcha($this->getFormId())->getBlockName();
////// $block = $this->getLayout()->createBlock($blockPath);
////// $block->setData($this->getData());
////// return $block->toHtml();
// }
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\CustomerData;
use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Customer\Helper\Session\CurrentCustomer;
use Magento\Customer\Helper\Session\CurrentCustomerAddress;
class ApplePay implements SectionSourceInterface
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $_customerSession;
/**
* @var CurrentCustomerAddress
*/
protected $_currentCustomerAddress;
/**
* @var CurrentCustomer
*/
protected $currentCustomer;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger;
protected $_localeLists;
/**
* ApplePay constructor.
* @param CurrentCustomer $currentCustomer
* @param \Magento\Customer\Model\Session $customerSession
*/
public function __construct(
CurrentCustomer $currentCustomer,
CurrentCustomerAddress $currentCustomerAddress,
\Magento\Customer\Model\Session $customerSession,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\Locale\ListsInterface $localeLists
) {
$this->_customerSession = $customerSession;
$this->_currentCustomerAddress = $currentCustomerAddress;
$this->currentCustomer = $currentCustomer;
$this->_adyenLogger = $adyenLogger;
$this->_localeLists = $localeLists;
}
/**
* {@inheritdoc}
*/
public function getSectionData()
{
$this->_adyenLogger->error("START SECIOTN DATA");
$customerId = null;
if ($this->_customerSession->isLoggedIn()) {
$this->_adyenLogger->error("CUSSTOMER LOGIN!");
$customerId = $this->_customerSession->getCustomerId();
$customer = $this->currentCustomer->getCustomer();
$this->_adyenLogger->error("CUSSTOMER LOGIN2!");
$billingAddress = $this->_currentCustomerAddress->getDefaultBillingAddress();
$this->_adyenLogger->error("CUSSTOMER LOGIN3!");
if ($billingAddress) {
$lastName = trim($billingAddress->getMiddlename() . " " . $billingAddress->getLastName());
$countryName = $this->_localeLists->getCountryTranslation($billingAddress->getCountryId());
$billingContract = [
'emailAddress' => $customer->getEmail(),
'phoneNumber' => $billingAddress->getTelephone(),
'familyName' => $lastName,
'givenName' => $billingAddress->getFirstname(),
'addressLines' => $billingAddress->getStreet(),
'locality' => $billingAddress->getCity(),
'postalCode' => $billingAddress->getPostcode(),
'administrativeArea' => $billingAddress->getRegionId(), // state
'country' => $countryName,
'countryCode' => $billingAddress->getCountryId()
];
}
$this->_adyenLogger->error("CUSSTOMER LOGIN4!");
$shippingAddress = $this->_currentCustomerAddress->getDefaultShippingAddress();
if ($shippingAddress) {
$lastName = trim($shippingAddress->getMiddlename() . " " . $shippingAddress->getLastName());
$countryName = $this->_localeLists->getCountryTranslation($shippingAddress->getCountryId());
$shippingContract = [
'emailAddress' => $customer->getEmail(),
'phoneNumber' => $billingAddress->getTelephone(),
'familyName' => $lastName,
'givenName' => $billingAddress->getFirstname(),
'addressLines' => $billingAddress->getStreet(),
'locality' => $billingAddress->getCity(),
'postalCode' => $billingAddress->getPostcode(),
'administrativeArea' => $billingAddress->getRegionId(), // state
'country' => $countryName,
'countryCode' => $billingAddress->getCountryId()
];
}
$lastName = trim($customer->getMiddlename() . " " . $customer->getLastName());
$this->_adyenLogger->error(print_r($billingContract, true));
$this->_adyenLogger->error(print_r($shippingContract, true));
return [
'customerId' => $customerId,
'firstname' => $customer->getFirstname(),
'givenName' => $customer->getFirstname(),
'familyName' => $lastName,
'emailAddress' => $customer->getEmail(),
'billingContact' => $billingContract,
'shippingContact' => $shippingContract
];
}
return [];
}
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
/**
* @SuppressWarnings(PHPMD.LongVariable)
*/
class ApplePay extends AbstractHelper
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $_customerSession;
/**
* ApplePay constructor.
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Customer\Model\Session $customerSession
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Customer\Model\Session $customerSession
) {
parent::__construct($context);
$this->_customerSession = $customerSession;
}
/**
*
*/
public function getApplePayData()
{
if ($this->_customerSession->isLoggedIn()) {
echo "LOGGED IN CORRECT WAY";
}
echo 'hier2';
die();
}
}
\ No newline at end of file
...@@ -85,6 +85,20 @@ class Data extends AbstractHelper ...@@ -85,6 +85,20 @@ class Data extends AbstractHelper
]; ];
} }
/**
* @desc return recurring types for configuration setting
* @return array
*/
public function getShippingTypes()
{
return [
\Adyen\Payment\Model\ShippingType::SHIPPING_METHOD => __('Shipping Method'),
\Adyen\Payment\Model\ShippingType::DELIVERY_METHOD => __('Delivery Method'),
\Adyen\Payment\Model\ShippingType::STORE_PICKUP => __('Store Pickup Method'),
\Adyen\Payment\Model\ShippingType::SERVICE_PICKUP =>__('Service Pickup Method')
];
}
/** /**
* @desc return recurring types for configuration setting * @desc return recurring types for configuration setting
* @return array * @return array
...@@ -386,6 +400,28 @@ class Data extends AbstractHelper ...@@ -386,6 +400,28 @@ class Data extends AbstractHelper
return $this->getConfigData($field, 'adyen_pay_by_mail', $storeId, true); return $this->getConfigData($field, 'adyen_pay_by_mail', $storeId, true);
} }
/**
* @desc Gives back adyen_apple_pay configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenApplePayConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_apple_pay', $storeId);
}
/**
* @desc Gives back adyen_pay_by_mail configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenApplePayConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_apple_pay', $storeId, true);
}
/** /**
* @desc Retrieve decrypted hmac key * @desc Retrieve decrypted hmac key
* @return string * @return string
...@@ -416,6 +452,32 @@ class Data extends AbstractHelper ...@@ -416,6 +452,32 @@ class Data extends AbstractHelper
return $secretWord; return $secretWord;
} }
public function getApplePayMerchantIdentifier()
{
switch ($this->isDemoMode()) {
case true:
$applePayIdentifier = trim($this->getAdyenApplePayConfigData('merchant_identifier_test'));
break;
default:
$applePayIdentifier = trim($this->getAdyenApplePayConfigData('merchant_identifier_test'));
break;
}
return $applePayIdentifier;
}
public function getApplePayFullPathLocationPEMFile()
{
switch ($this->isDemoMode()) {
case true:
$applePayIdentifier = trim($this->getAdyenApplePayConfigData('full_path_location_pem_file_test'));
break;
default:
$applePayIdentifier = trim($this->getAdyenApplePayConfigData('full_path_location_pem_file_live'));
break;
}
return $applePayIdentifier;
}
/** /**
* @desc Check if configuration is set to demo mode * @desc Check if configuration is set to demo mode
* @return mixed * @return mixed
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\Config\Source;
class ShippingType implements \Magento\Framework\Option\ArrayInterface
{
const UNDEFINED_OPTION_LABEL = 'NONE';
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* RecurringType constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
$recurringTypes = $this->_adyenHelper->getShippingTypes();
foreach ($recurringTypes as $code => $label) {
$options[] = ['value' => $code, 'label' => $label];
}
return $options;
}
}
This diff is collapsed.
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
class ShippingType
{
CONST SHIPPING_METHOD = 'shipping';
const DELIVERY_METHOD = 'delivery';
const STORE_PICKUP = 'storePickup';
const SERVICE_PICKUP = 'servicePickup';
}
\ No newline at end of file
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<include path="Adyen_Payment::system/adyen_manual_review.xml"/> <include path="Adyen_Payment::system/adyen_manual_review.xml"/>
<include path="Adyen_Payment::system/adyen_cc.xml"/> <include path="Adyen_Payment::system/adyen_cc.xml"/>
<include path="Adyen_Payment::system/adyen_oneclick.xml"/> <include path="Adyen_Payment::system/adyen_oneclick.xml"/>
<include path="Adyen_Payment::system/adyen_apple_pay.xml"/>
<include path="Adyen_Payment::system/adyen_hpp.xml"/> <include path="Adyen_Payment::system/adyen_hpp.xml"/>
<include path="Adyen_Payment::system/adyen_sepa.xml"/> <include path="Adyen_Payment::system/adyen_sepa.xml"/>
<include path="Adyen_Payment::system/adyen_pos.xml"/> <include path="Adyen_Payment::system/adyen_pos.xml"/>
......
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_apple_pay" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Apple Pay for the Web]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment><![CDATA[You need to configure Apple Pay on the Adyen Platform. Please contact support@adyen.com and provide us CSR + merchant Identifier.<br /> Apple Pay will only be visable if you are running on IOS10 and higher. You need to browse on a Safari browser and you need to have active creditcards in your wallet.]]></comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_apple_pay/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_apple_pay/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_apple_pay/sort_order</config_path>
</field>
<field id="merchant_identifier_test" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test: Apple Merchant Identifier</label>
<tooltip>You can retrieve this from you Apple Account</tooltip>
<config_path>payment/adyen_apple_pay/merchant_identifier_test</config_path>
</field>
<field id="merchant_identifier_live" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Live: Apple Merchant Identifier</label>
<tooltip>You can retrieve this from you Apple Account</tooltip>
<config_path>payment/adyen_apple_pay/merchant_identifier_live</config_path>
</field>
<field id="full_path_location_pem_file_test" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test: PEM File location</label>
<tooltip>You need to generate a pem file from the apple certificate. You need to upload this to your webserver and define the full path location here.</tooltip>
<config_path>payment/adyen_apple_pay/full_path_location_pem_file_test</config_path>
</field>
<field id="full_path_location_pem_file_live" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Live: PEM File location</label>
<tooltip>You need to generate a pem file from the apple certificate. You need to upload this to your webserver and define the full path location here.</tooltip>
<config_path>payment/adyen_apple_pay/full_path_location_pem_file_live</config_path>
</field>
<field id="shipping_type" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Shipping Type</label>
<tooltip>Title of the shipping method selection on the payments sheet you only these options this is limited by Apple</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\ShippingType</source_model>
<config_path>payment/adyen_apple_pay/shipping_type</config_path>
</field>
<field id="allow_quest_checkout" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow Guest Checkout</label>
<tooltip>Show Apple Pay icon if user is not logged in. The user has the option to set his own contact detals and shipping\billing address</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_apple_pay/allow_quest_checkout</config_path>
</field>
<field id="change_address" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Option to change address details in Apple Payment Sheet</label>
<tooltip>Do you want to offer the customer that is logged in to change his address in the Apple Payment Sheet?</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_apple_pay/change_address</config_path>
<depends><field id="allow_quest_checkout">0</field></depends>
</field>
<field id="show_in_payment_step_checkout" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show payment method as well in the Payment Information step of the checkout</label>
<tooltip>If you set this to NO this will not be shown as a payment method option in the checkout steps. It will be visable on the product and shopping basket page</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_apple_pay/show_in_payment_step_checkout</config_path>
</field>
<field id="show_outside_of_checkout" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show Apple buy button on product and cart page</label>
<tooltip>Set this to 'no' if you have advanced options for, for example, shipping that are not supported by the Apple Pay checkout forcing the user to first go through the Magento Checkout</tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_apple_pay/show_outside_of_checkout</config_path>
<depends><field id="show_in_payment_step_checkout">1</field></depends>
</field>
</group>
</include>
\ No newline at end of file
...@@ -60,6 +60,18 @@ ...@@ -60,6 +60,18 @@
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<group>adyen</group> <group>adyen</group>
</adyen_oneclick> </adyen_oneclick>
<adyen_apple_pay translate="title" module="adyen">
<active>0</active>
<model>Adyen\Payment\Model\Method\ApplePay</model>
<group>adyen</group>
<title>Adyen Apple Pay</title>
<sort_order>6</sort_order>
<shipping_type>shipping</shipping_type>
<allow_quest_checkout>1</allow_quest_checkout>
<change_address>1</change_address>
<show_in_payment_step_checkout>1</show_in_payment_step_checkout>
<show_outside_of_checkout>1</show_outside_of_checkout>
</adyen_apple_pay>
<adyen_hpp> <adyen_hpp>
<active>0</active> <active>0</active>
<model>Adyen\Payment\Model\Method\Hpp</model> <model>Adyen\Payment\Model\Method\Hpp</model>
......
...@@ -35,4 +35,11 @@ ...@@ -35,4 +35,11 @@
</argument> </argument>
</arguments> </arguments>
</type> </type>
<type name="Magento\Customer\CustomerData\SectionPoolInterface">
<arguments>
<argument name="sectionSourceMap" xsi:type="array">
<item name="adyen-apple-pay" xsi:type="string">Adyen\Payment\CustomerData\ApplePay</item>
</argument>
</arguments>
</type>
</config> </config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Adyen_Payment::css/adyen_apple_pay.css"/>
<!--<script src="Adyen_Payment::js/adyen_apple_pay.js"/>-->
</head>
<body>
<!--<referenceContainer name="product.info.form.content">-->
<!--<block class="Adyen\Payment\Block\ApplePay" name="product.info.applepay" after="product.info.addtocart" template="apple_pay.phtml"/>-->
<!--</referenceContainer>-->
<referenceContainer name="product.info.form.content">
<block class="Adyen\Payment\Block\ApplePay" name="product.info.applepay"
after="product.info.addtocart" template="apple_pay.phtml" cacheable="false" >
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="applePay" xsi:type="array">
<item name="component" xsi:type="string">Adyen_Payment/js/adyen_apple_pay</item>
</item>
</item>
</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
/*jshint browser:true jquery:true*/ /*jshint browser:true jquery:true*/
/*global alert*/ /*global alert*/
var config = { var config = {
// map: {
// '*': {
// adyen_apple_pay: 'Adyen_Payment/js/adyen_apple_pay'
// }
// },
paths: { paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min' 'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min'
}, },
......
<?php
//
//$_product = $block->getProduct();
//
//if ($_product) {
// // in product
//}
//
//$block->getShippingMethods();
//echo 'hier';
//die();
?>
<div data-bind="scope: 'apple-pay'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"apple-pay": {
"component": "Adyen_Payment/js/adyen_apple_pay",
"template" : "Adyen_Payment/apple_pay",
"productId": "<?php echo $block->getProduct()->getDescription() . "test"; ?>"
}
}
}
}
}
</script>
.apple-pay-button-with-text {
--apple-pay-scale: 1.5625; /* (height / 32) */
display: inline-flex;
justify-content: center;
font-size: 12px;
border-radius: 5px;
padding: 0px;
box-sizing: border-box;
/*min-width: 200px;*/
width:100%;
min-height: 32px;
max-height: 64px;
margin-bottom: 10px;
}
.apple-pay-button-black-with-text {
background-color: black;
color: white;
}
.apple-pay-button-white-with-text {
background-color: white;
color: black;
}
.apple-pay-button-white-with-line-with-text {
background-color: white;
color: black;
border: .5px solid black;
}
.apple-pay-button-with-text.apple-pay-button-black-with-text > .logo {
background-image: -webkit-named-image(apple-pay-logo-white);
background-color: black;
}
.apple-pay-button-with-text.apple-pay-button-white-with-text > .logo {
background-image: -webkit-named-image(apple-pay-logo-black);
background-color: white;
}
.apple-pay-button-with-text.apple-pay-button-white-with-line-with-text > .logo {
background-image: -webkit-named-image(apple-pay-logo-black);
background-color: white;
}
.apple-pay-button-with-text > .text {
font-family: -apple-system;
font-size: calc(1em * var(--apple-pay-scale));
font-weight: 300;
align-self: center;
margin-right: calc(2px * var(--apple-pay-scale));
}
.apple-pay-button-with-text > .logo {
width: calc(35px * var(--apple-pay-scale));
height: 100%;
background-size: 100% 60%;
background-repeat: no-repeat;
background-position: 0 50%;
margin-left: calc(2px * var(--apple-pay-scale));
border: none;
min-width: 0px; /* override magento min-width */
}
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
// define(['uiComponent'], function(Component) {
//
// return Component.extend({
// initialize: function () {
// this._super();
// this.sayHello = "Hello this is content populated with KO!";
// }
// });
// });
define([
'uiComponent',
'Magento_Customer/js/customer-data',
'jquery'
], function (Component, customerData, $) {
'use strict';
return Component.extend({
initialize: function () {
this._super();
this.sayHello = "Hello this is content populated with KO!";
this.applePayData = customerData.get('adyen-apple-pay');
// this.applePay = {customerId: 'test' };
// test2
var productId = this.productId;
// TODO: add observer on qty
var qty = $('qty');
// qty.subscribe(function (event) {
// alert("DF");
// });
},
processApplePay: function () {
var paymentRequest = {
currencyCode: ''
};
alert("DF");
},
});
});
\ No newline at end of file
<p>I am 2 template located on: app/code/Adyen/Payment/view/frontend/web/template/apple_pay.html and dynamically loaded. This is my message to you:</p>
<p data-bind="text: sayHello"></p>
<div id="adyen-apple-pay-button" class="apple-pay-button-with-text apple-pay-button-black-with-text" style="" data-bind="click: processApplePay">
<span class="text">Buy With</span>
<span class="logo"></span>
</div>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment