Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
a0baf50a
Commit
a0baf50a
authored
Sep 09, 2015
by
rikterbeek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code to get Adyen CC api working
parent
d4486a92
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
352 additions
and
92 deletions
+352
-92
app/code/Adyen/Payment/Controller/Index/Index.php
app/code/Adyen/Payment/Controller/Index/Index.php
+1
-0
app/code/Adyen/Payment/Model/Api/PaymentRequest.php
app/code/Adyen/Payment/Model/Api/PaymentRequest.php
+7
-3
app/code/Adyen/Payment/Model/Method/Cc.php
app/code/Adyen/Payment/Model/Method/Cc.php
+15
-3
app/code/Adyen/Payment/Model/Method/Hpp.php
app/code/Adyen/Payment/Model/Method/Hpp.php
+51
-13
app/code/Adyen/Payment/etc/frontend/di.xml
app/code/Adyen/Payment/etc/frontend/di.xml
+1
-0
app/code/Adyen/Payment/etc/frontend/routes.xml
app/code/Adyen/Payment/etc/frontend/routes.xml
+3
-0
app/code/Adyen/Payment/view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
...nd/web/js/view/payment/method-renderer/adyen-cc-method.js
+47
-29
app/code/Adyen/Payment/view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+11
-2
app/code/Adyen/Payment/view/frontend/web/template/payment/cc-form.html
...n/Payment/view/frontend/web/template/payment/cc-form.html
+200
-4
app/code/Adyen/Payment/view/frontend/web/template/payment/hpp-form.html
.../Payment/view/frontend/web/template/payment/hpp-form.html
+16
-38
No files found.
app/code/Adyen/Payment/Controller/Index/Index.php
View file @
a0baf50a
...
...
@@ -7,6 +7,7 @@ class Index extends \Magento\Framework\App\Action\Action
{
public
function
execute
()
{
echo
'test'
;
die
();
$this
->
_view
->
loadLayout
();
$this
->
_view
->
getLayout
()
->
initMessages
();
$this
->
_view
->
renderLayout
();
...
...
app/code/Adyen/Payment/Model/Api/PaymentRequest.php
View file @
a0baf50a
...
...
@@ -58,7 +58,7 @@ class PaymentRequest extends \Magento\Framework\Object
"paymentRequest.merchantAccount"
=>
$merchantAccount
,
"paymentRequest.amount.currency"
=>
"EUR"
,
"paymentRequest.amount.value"
=>
"199"
,
"paymentRequest.reference"
=>
"TEST-PAYMENT-"
.
date
(
"Y-m-d-H:i:s"
),
"paymentRequest.reference"
=>
$order
->
getIncrementId
(
),
"paymentRequest.shopperIP"
=>
"ShopperIPAddress"
,
"paymentRequest.shopperEmail"
=>
"TheShopperEmailAddress"
,
"paymentRequest.shopperReference"
=>
"YourReference"
,
...
...
@@ -110,9 +110,13 @@ class PaymentRequest extends \Magento\Framework\Object
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'HTTP Status code'
.
$results
));
}
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'HTTP Status code'
.
print_r
(
$results
,
true
)));
parse_str
(
$results
,
$results
);
// throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . print_r($results, true)));
parse_str
(
$results
,
$results
);
$this
->
_logger
->
critical
(
"result is"
.
print_r
(
$results
,
true
));
curl_close
(
$ch
);
...
...
app/code/Adyen/Payment/Model/Method/Cc.php
View file @
a0baf50a
...
...
@@ -97,7 +97,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public
function
isAvailable
(
$quote
=
null
)
{
$this
->
_logger
->
critical
(
"IS AVAILABLE!! IS TRUE"
);
$this
->
_logger
->
critical
(
"
CC
IS AVAILABLE!! IS TRUE"
);
return
true
;
}
...
...
@@ -110,7 +110,10 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/
public
function
assignData
(
$data
)
{
print_r
(
$data
);
die
();
$this
->
_logger
->
critical
(
"Assign data!!:"
.
print_r
(
$data
,
true
));
return
parent
::
assignData
(
$data
);
//// print_r($data);die();
// $this->_logger->critical("TEST in validate FUNTION !!:");
}
public
function
validate
()
...
...
@@ -160,10 +163,19 @@ class Cc extends \Magento\Payment\Model\Method\Cc
break
;
}
$this
->
_logger
->
critical
(
"HIERRR result is "
.
print_r
(
$response
,
true
));
if
(
!
empty
(
$response
))
{
print_r
(
$response
);
die
();
$this
->
_logger
->
critical
(
"NOT EMPTY "
);
// print_r($response);die();
// $this->_processResponse($payment, $response, $request);
}
else
{
$this
->
_logger
->
critical
(
" EMPTY response"
);
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Empty result.'
));
}
...
...
app/code/Adyen/Payment/Model/Method/Hpp.php
View file @
a0baf50a
...
...
@@ -33,7 +33,52 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
protected
$_canAuthorize
=
true
;
protected
$_isInitializeNeeded
=
true
;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Logger $logger
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public
function
__construct
(
\Magento\Framework\UrlInterface
$urlBuilder
,
\Magento\Framework\Model\Context
$context
,
\Magento\Framework\Registry
$registry
,
\Magento\Framework\Api\ExtensionAttributesFactory
$extensionFactory
,
\Magento\Framework\Api\AttributeValueFactory
$customAttributeFactory
,
\Magento\Payment\Helper\Data
$paymentData
,
\Magento\Framework\App\Config\ScopeConfigInterface
$scopeConfig
,
\Magento\Payment\Model\Method\Logger
$logger
,
\Magento\Framework\Model\Resource\AbstractResource
$resource
=
null
,
\Magento\Framework\Data\Collection\AbstractDb
$resourceCollection
=
null
,
array
$data
=
[]
)
{
parent
::
__construct
(
$context
,
$registry
,
$extensionFactory
,
$customAttributeFactory
,
$paymentData
,
$scopeConfig
,
$logger
,
$resource
,
$resourceCollection
,
$data
);
$this
->
_urlBuilder
=
$urlBuilder
;
}
public
function
isAvailable
(
$quote
=
null
)
{
$this
->
_logger
->
critical
(
"HPP IS AVAILABLE!! IS TRUE"
);
return
true
;
}
public
function
initialize
(
$paymentAction
,
$stateObject
)
{
...
...
@@ -79,24 +124,17 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
// return \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE;
// }
/**
* Checkout
order place redirect URL getter
* Checkout
redirect URL getter for onepage checkout (hardcode)
*
* @see \Magento\Checkout\Controller\Onepage::savePaymentAction()
* @see \Magento\Quote\Model\Quote\Payment::getCheckoutRedirectUrl()
* @return string
*/
public
function
get
OrderPlace
RedirectUrl
()
public
function
get
Checkout
RedirectUrl
()
{
$this
->
_logger
->
critical
(
"getOrderPlaceRedirectUrl"
);
$method
=
$this
->
getMethodInstance
();
if
(
$method
)
{
$this
->
_logger
->
critical
(
"getOrderPlaceRedirectUrl url is:"
.
$method
->
getConfigData
(
'order_place_redirect_url'
));
return
$method
->
getConfigData
(
'order_place_redirect_url'
);
}
else
{
$this
->
_logger
->
critical
(
"ELSE:"
);
return
"http://www.google.com/"
;
}
return
''
;
// return $this->_urlBuilder->getUrl('paypal/payflowexpress/start');
return
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/redirect'
);
}
...
...
app/code/Adyen/Payment/etc/frontend/di.xml
View file @
a0baf50a
...
...
@@ -17,6 +17,7 @@
<arguments>
<argument
name=
"configProviders"
xsi:type=
"array"
>
<item
name=
"adyen_cc_config_provider"
xsi:type=
"object"
>
AdyenCcConfigProvider
</item>
<item
name=
"adyen_hpp_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenHppConfigProvider
</item>
</argument>
</arguments>
</type>
...
...
app/code/Adyen/Payment/etc/frontend/routes.xml
View file @
a0baf50a
...
...
@@ -3,5 +3,8 @@
<route
id=
"hello"
frontName=
"hello"
>
<module
name=
"Adyen_Payment"
/>
</route>
<route
id=
"adyen"
frontName=
"adyen"
>
<module
name=
"Adyen_Payment"
/>
</route>
</router>
</config>
\ No newline at end of file
app/code/Adyen/Payment/view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
View file @
a0baf50a
...
...
@@ -6,54 +6,72 @@
/*global define*/
define
(
[
'
jquery
'
,
'
Magento_Payment/js/view/payment/iframe
'
,
'
Magento_Checkout/js/action/set-payment-information
'
'
Magento_Payment/js/view/payment/cc-form
'
,
'
Magento_Checkout/js/action/set-payment-information
'
,
],
function
(
$
,
Component
,
setPaymentInformationAction
)
{
function
(
Component
,
setPaymentInformationAction
)
{
'
use strict
'
;
return
Component
.
extend
({
defaults
:
{
template
:
'
Adyen_Payment/payment/cc-form
'
template
:
'
Adyen_Payment/payment/cc-form
'
,
creditCardOwner
:
''
},
initObservable
:
function
()
{
this
.
_super
()
.
observe
([
'
creditCardType
'
,
'
creditCardExpYear
'
,
'
creditCardExpMonth
'
,
'
creditCardNumber
'
,
'
creditCardVerificationNumber
'
,
'
creditCardSsStartMonth
'
,
'
creditCardSsStartYear
'
,
'
selectedCardType
'
,
'
creditCardOwner
'
]);
return
this
;
},
placeOrderHandler
:
null
,
validateHandler
:
null
,
setPlaceOrderHandler
:
function
(
handler
)
{
this
.
placeOrderHandler
=
handler
;
},
setValidateHandler
:
function
(
handler
)
{
this
.
validateHandler
=
handler
;
},
context
:
function
()
{
return
this
;
},
isShowLegend
:
function
()
{
return
true
;
},
getCode
:
function
()
{
return
'
adyen_cc
'
;
},
getData
:
function
()
{
return
{
'
method
'
:
this
.
item
.
method
,
'
cc_type
'
:
this
.
creditCardType
(),
'
cc_exp_year
'
:
this
.
creditCardExpYear
(),
'
cc_exp_month
'
:
this
.
creditCardExpMonth
(),
'
cc_number
'
:
this
.
creditCardNumber
(),
'
cc_owner
'
:
this
.
creditCardOwner
(),
additional_data
:
{
'
cc_cid
'
:
this
.
creditCardVerificationNumber
(),
'
cc_ss_start_month
'
:
this
.
creditCardSsStartMonth
(),
'
cc_ss_start_year
'
:
this
.
creditCardSsStartYear
()
}
};
},
isActive
:
function
()
{
return
true
;
},
placeOrder
:
function
()
{
var
self
=
this
;
if
(
this
.
validateHandler
()
)
{
this
.
isPlaceOrderActionAllowed
(
false
)
;
$
.
when
(
setPaymentInformationAction
()).
done
(
function
()
{
self
.
placeOrderHandler
();
}).
fail
(
function
()
{
self
.
isPlaceOrderActionAllowed
(
true
);
});
}
}
getTitle
:
function
()
{
return
'
Adyen cc
'
;
},
getControllerName
:
function
(
)
{
return
window
.
checkoutConfig
.
payment
.
iframe
.
controllerName
[
this
.
getCode
()]
;
},
getPlaceOrderUrl
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
iframe
.
placeOrderUrl
[
this
.
getCode
()];
},
context
:
function
()
{
return
this
;
}
,
});
}
);
...
...
app/code/Adyen/Payment/view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
a0baf50a
...
...
@@ -6,13 +6,22 @@
/*global define*/
define
(
[
'
Magento_Checkout/js/view/payment/default
'
'
jquery
'
,
'
Magento_Checkout/js/view/payment/default
'
,
'
Adyen_Payment/js/action/set-payment-method
'
],
function
(
Component
)
{
function
(
$
,
Component
,
setPaymentMethodAction
)
{
'
use strict
'
;
return
Component
.
extend
({
defaults
:
{
template
:
'
Adyen_Payment/payment/hpp-form
'
},
/** Redirect to adyen */
continueToAdyen
:
function
()
{
//update payment method information if additional data was changed
this
.
selectPaymentMethod
();
setPaymentMethodAction
();
return
false
;
}
});
}
...
...
app/code/Adyen/Payment/view/frontend/web/template/payment/cc-form.html
View file @
a0baf50a
This diff is collapsed.
Click to expand it.
app/code/Adyen/Payment/view/frontend/web/template/payment/hpp-form.html
View file @
a0baf50a
...
...
@@ -12,48 +12,26 @@
data-bind=
"attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"
/>
<label
data-bind=
"attr: {'for': getCode()}"
class=
"label"
><span
data-bind=
"text: getTitle()"
></span></label>
</div>
<div
class=
"payment-method-content"
>
<div
class=
"payment-method-billing-address"
>
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<fieldset
class=
"fieldset"
data-bind=
'attr: {id: "payment_form_" + getCode()}'
>
<div
class=
"payment-method-note"
>
<!-- ko text: $t('You will be redirected to the Adyen website.') --><!-- /ko -->
</div>
</fieldset>
<div
class=
"checkout-agreements-block"
>
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<form
class=
"form"
id=
"co-transparent-form"
action=
"#"
method=
"post"
data-bind=
"mageInit: {
'transparent':{
'context': context(),
'controller': getControllerName(),
'gateway': getCode(),
'orderSaveUrl':getPlaceOrderUrl(),
'cgiUrl': getCgiUrl(),
'dateDelim': getDateDelim(),
'cardFieldsMap': getCardFieldsMap(),
'nativeAction': getSaveOrderUrl()
}, 'validation':[]}"
>
<div
class=
"checkout-agreements-block"
>
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div
class=
"actions-toolbar"
>
<div
class=
"primary"
>
<button
class=
"action primary checkout"
type=
"submit"
data-bind=
"
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled
>
<span
data-bind=
"text: $t('Place Order')"
></span>
</button>
</div>
<div
class=
"actions-toolbar"
>
<div
class=
"primary"
>
<button
class=
"action primary checkout"
type=
"submit"
data-bind=
"click: continueToAdyen, enable: (getCode() == isChecked())"
disabled
>
<span
data-bind=
"text: $t('Continue to Adyen')"
></span>
</button>
</div>
</
form
>
</
div
>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment