-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PW-1364: review comments #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ public function getOriginKeyForOrigin() | |
|
||
if (!empty($response['originKeys'][$origin])) { | ||
$originKey = $response['originKeys'][$origin]; | ||
} else { | ||
$this->adyenLogger()->logError("OriginKey is empty, please verify that your API key is correct"); | ||
} | ||
|
||
return $originKey; | ||
|
@@ -102,15 +104,14 @@ public function initializeAdyenClient() | |
$client = $this->createAdyenClient(); | ||
$client->setApplicationName("Prestashop plugin"); | ||
$client->setXApiKey($apiKey); | ||
$client->setAdyenPaymentSource($this->getModuleName(), $this->getModuleVersion()); | ||
$client->setExternalPlatform("Prestashop" , _PS_VERSION_); | ||
|
||
if ($this->isDemoMode()) { | ||
$client->setEnvironment(\Adyen\Environment::TEST); | ||
} else { | ||
//todo liveendpointprefix | ||
// $client->setEnvironment(\Adyen\Environment::LIVE, $this->getLiveEndpointPrefix($storeId)); | ||
$client->setEnvironment(\Adyen\Environment::LIVE, Configuration::get('ADYEN_LIVE_ENDPOINT_URL_PREFIX')); | ||
} | ||
|
||
|
||
return $client; | ||
} | ||
|
||
|
@@ -200,4 +201,46 @@ public function isPrestashop16() | |
return false; | ||
} | ||
|
||
/** | ||
* Return the formatted currency. Adyen accepts the currency in multiple formats. | ||
* @param $amount | ||
* @param $currency | ||
* @return string | ||
*/ | ||
public function formatAmount($amount, $currency) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we not add this into our UTIL class of the API library and use it there. Same we can do for M2 so we have consistency if there are changes made. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, please check Adyen/adyen-php-api-library#113 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice :) |
||
{ | ||
switch ($currency) { | ||
case "CVE": | ||
case "DJF": | ||
case "GNF": | ||
case "IDR": | ||
case "JPY": | ||
case "KMF": | ||
case "KRW": | ||
case "PYG": | ||
case "RWF": | ||
case "UGX": | ||
case "VND": | ||
case "VUV": | ||
case "XAF": | ||
case "XOF": | ||
case "XPF": | ||
$format = 0; | ||
break; | ||
case "BHD": | ||
case "IQD": | ||
case "JOD": | ||
case "KWD": | ||
case "LYD": | ||
case "OMR": | ||
case "TND": | ||
$format = 3; | ||
break; | ||
default: | ||
$format = 2; | ||
} | ||
|
||
return (int)number_format($amount, $format, '', ''); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{extends file='page.tpl'} | ||
|
||
{block name='page_content_container'} | ||
<h3>{l s='There was an error' mod='adyen'}</h3> | ||
|
||
<p class="warning"> | ||
{l s='We have noticed that there is a problem with your order.' mod='adyen'} | ||
</p> | ||
|
||
{/block} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,88 @@ | ||
<div class="row"> | ||
<div class="col-xs-12 col-md-6"> | ||
<form action="{$action}" id="payment-form" method="post"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
<script> | ||
$(document).ready(function () { | ||
renderSecureFields(); | ||
}); | ||
|
||
function renderSecureFields() { | ||
var locale = "en_US"; | ||
var cardNode = document.getElementById('cardContainer'); | ||
// we can now rely on $ within the safety of our "bodyguard" function | ||
var checkout = new AdyenCheckout({ | ||
locale: locale, | ||
originKey: "{$originKey}", | ||
environment: "{$environment}", | ||
risk: { | ||
enabled: false | ||
} | ||
{if !$originKey} | ||
<form id="payment-form" method="post"> | ||
<h5>There is an error with retrieving the originKey, | ||
please check your API key in the Adyen Module configuration</h5> | ||
</form> | ||
{else} | ||
<div class="row"> | ||
<div class="col-xs-12 col-md-6"> | ||
<form action="{$action}" id="payment-form" method="post"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
<script> | ||
$(document).ready(function () { | ||
renderSecureFields(); | ||
}); | ||
var card = checkout.create('card', { | ||
type: 'card', | ||
hasHolderName: true, | ||
holderNameRequired: true, | ||
|
||
onChange: function (state, component) { | ||
console.log(state, component); | ||
if (state.isValid && !component.state.errors.encryptedSecurityCode) { | ||
document.getElementById('holderName').value = state.data.paymentMethod.holderName; | ||
document.getElementById('encryptedCardNumber').value = state.data.paymentMethod.encryptedCardNumber; | ||
document.getElementById('encryptedExpiryMonth').value = state.data.paymentMethod.encryptedExpiryMonth; | ||
document.getElementById('encryptedExpiryYear').value = state.data.paymentMethod.encryptedExpiryYear; | ||
if (state.data.paymentMethod.encryptedSecurityCode) { | ||
document.getElementById('encryptedSecurityCode').value = state.data.paymentMethod.encryptedSecurityCode; | ||
function renderSecureFields() { | ||
var locale = "en_US"; | ||
var cardNode = document.getElementById('cardContainer'); | ||
// we can now rely on $ within the safety of our "bodyguard" function | ||
var checkout = new AdyenCheckout({ | ||
locale: locale, | ||
originKey: "{$originKey}", | ||
environment: "{$environment}", | ||
risk: { | ||
enabled: false | ||
} | ||
}); | ||
var card = checkout.create('card', { | ||
type: 'card', | ||
hasHolderName: true, | ||
holderNameRequired: true, | ||
|
||
onChange: function (state, component) { | ||
if (state.isValid && !component.state.errors.encryptedSecurityCode) { | ||
document.getElementById('holderName').value = state.data.paymentMethod.holderName; | ||
document.getElementById('encryptedCardNumber').value = state.data.paymentMethod.encryptedCardNumber; | ||
document.getElementById('encryptedExpiryMonth').value = state.data.paymentMethod.encryptedExpiryMonth; | ||
document.getElementById('encryptedExpiryYear').value = state.data.paymentMethod.encryptedExpiryYear; | ||
if (state.data.paymentMethod.encryptedSecurityCode) { | ||
document.getElementById('encryptedSecurityCode').value = state.data.paymentMethod.encryptedSecurityCode; | ||
} | ||
document.getElementById("allValidcard").value = true; | ||
} else { | ||
resetFields(); | ||
} | ||
document.getElementById("allValidcard").value = true; | ||
} else { | ||
resetFields(); | ||
} | ||
} | ||
}); | ||
card.mount(cardNode); | ||
} | ||
}); | ||
card.mount(cardNode); | ||
} | ||
|
||
function resetFields() { | ||
document.getElementById('holderName').value = ""; | ||
document.getElementById('encryptedCardNumber').value = ""; | ||
document.getElementById('encryptedExpiryMonth').value = ""; | ||
document.getElementById('encryptedExpiryYear').value = ""; | ||
document.getElementById('encryptedSecurityCode').value = ""; | ||
document.getElementById("allValidcard").value = ""; | ||
} | ||
</script> | ||
<div class="checkout-container" id="cardContainer"> | ||
<div class="form-div"> | ||
<input type="hidden" name="holderName" id="holderName" | ||
value=""> | ||
<input type="hidden" name="encryptedCardNumber" id="encryptedCardNumber" | ||
value=""> | ||
<input type="hidden" name="encryptedExpiryMonth" id="encryptedExpiryMonth" | ||
value=""> | ||
<input type="hidden" name="encryptedExpiryYear" id="encryptedExpiryYear" | ||
value=""> | ||
<input type="hidden" name="encryptedSecurityCode" id="encryptedSecurityCode" | ||
value=""> | ||
<input type="hidden" class="required-entry" name="allValidcard" id="allValidcard" value=""> | ||
<input type="hidden" name="payment[screen_width]" id="screenWidth" value=""> | ||
<input type="hidden" name="payment[screen_height]" id="screenHeight" value=""> | ||
<input type="hidden" name="payment[color_depth]" id="colorDepth" value=""> | ||
<input type="hidden" name="payment[time_zone_offset]" id="timeZoneOffset" value=""> | ||
<input type="hidden" name="payment[language]" id="language" value=""> | ||
<input type="hidden" name="payment[java_enabled]" id="javaEnabled" value=""> | ||
function resetFields() { | ||
document.getElementById('holderName').value = ""; | ||
document.getElementById('encryptedCardNumber').value = ""; | ||
document.getElementById('encryptedExpiryMonth').value = ""; | ||
document.getElementById('encryptedExpiryYear').value = ""; | ||
document.getElementById('encryptedSecurityCode').value = ""; | ||
document.getElementById("allValidcard").value = ""; | ||
} | ||
</script> | ||
<div class="checkout-container" id="cardContainer"> | ||
<div class="form-div"> | ||
<input type="hidden" name="holderName" id="holderName" | ||
value=""> | ||
<input type="hidden" name="encryptedCardNumber" id="encryptedCardNumber" | ||
value=""> | ||
<input type="hidden" name="encryptedExpiryMonth" id="encryptedExpiryMonth" | ||
value=""> | ||
<input type="hidden" name="encryptedExpiryYear" id="encryptedExpiryYear" | ||
value=""> | ||
<input type="hidden" name="encryptedSecurityCode" id="encryptedSecurityCode" | ||
value=""> | ||
<input type="hidden" class="required-entry" name="allValidcard" id="allValidcard" value=""> | ||
<input type="hidden" name="payment[screen_width]" id="screenWidth" value=""> | ||
<input type="hidden" name="payment[screen_height]" id="screenHeight" value=""> | ||
<input type="hidden" name="payment[color_depth]" id="colorDepth" value=""> | ||
<input type="hidden" name="payment[time_zone_offset]" id="timeZoneOffset" value=""> | ||
<input type="hidden" name="payment[language]" id="language" value=""> | ||
<input type="hidden" name="payment[java_enabled]" id="javaEnabled" value=""> | ||
</div> | ||
</div> | ||
</div> | ||
{if $prestashop16} | ||
<button type="submit" class="button btn btn-default standard-checkout button-medium"><span> | ||
{if $prestashop16} | ||
<button type="submit" class="button btn btn-default standard-checkout button-medium"><span> | ||
{l s='Pay' mod='adyen'} <i class="icon-chevron-right right"></i> </span></button> | ||
{/if} | ||
</form> | ||
{/if} | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{/if} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better if we change this big if to all small ifs with the separate setters. so:
if(!empty($response['additionalData']['cardBin']) {
..
}
if(!empty($response['additionalData']['expiryDate'])) {
..
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done