-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Credit card components are now a javascript plugin, live mode is fixe…
…d. A test button for the API configuration is available.
- Loading branch information
Reinder
committed
Jul 8, 2020
1 parent
984486f
commit bf556e6
Showing
19 changed files
with
441 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Resources/app/administration/src/core/service/api/mollie-payments-config.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const ApiService = Shopware.Classes.ApiService; | ||
|
||
class MolliePaymentsConfigService extends ApiService { | ||
constructor(httpClient, loginService, apiEndpoint = 'mollie') { | ||
super(httpClient, loginService, apiEndpoint); | ||
} | ||
|
||
testApiKeys(data = {liveApiKey: null, testApiKey: null}) { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.post( | ||
`_action/${this.getApiBasePath()}/config/test-api-keys`, | ||
JSON.stringify(data), | ||
{ | ||
headers: headers | ||
} | ||
) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
} | ||
|
||
export default MolliePaymentsConfigService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ration/src/module/mollie-payments/extension/sw-plugin/component/sw-plugin-config/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import template from './sw-plugin-config.html.twig'; | ||
|
||
const { Component, Mixin } = Shopware; | ||
|
||
Component.override('sw-plugin-config', { | ||
template, | ||
|
||
inject: [ | ||
'MolliePaymentsConfigService', | ||
], | ||
|
||
mixins: [ | ||
Mixin.getByName('notification') | ||
], | ||
|
||
methods: { | ||
onTestButtonClicked() { | ||
let me = this; | ||
|
||
const liveApiKeyInput = document.querySelector('input[name="MolliePayments.config.liveApiKey"]'); | ||
const testApiKeyInput = document.querySelector('input[name="MolliePayments.config.testApiKey"]'); | ||
|
||
const liveApiKey = !!liveApiKeyInput ? liveApiKeyInput.value : null; | ||
const testApiKey = !!testApiKeyInput ? testApiKeyInput.value : null; | ||
|
||
this.MolliePaymentsConfigService.testApiKeys({liveApiKey, testApiKey}) | ||
.then((response) => { | ||
if (typeof response.results) { | ||
response.results.forEach(function (result) { | ||
let messageData = { | ||
title: me.$tc('sw-payment.testApiKeys.title'), | ||
message: `${me.$tc('sw-payment.testApiKeys.apiKey')} "${result.key}" (${result.mode}) ${(result.valid === true ? me.$tc('sw-payment.testApiKeys.isValid') : me.$tc('sw-payment.testApiKeys.isInvalid'))}.` | ||
}; | ||
|
||
let input = result.mode === 'live' ? liveApiKeyInput : testApiKeyInput; | ||
|
||
if (!!input) { | ||
input.parentNode.parentNode.classList.remove('has--error'); | ||
} | ||
|
||
if (result.valid === true) { | ||
me.createNotificationSuccess(messageData); | ||
} else { | ||
me.createNotificationError(messageData); | ||
|
||
if (!!input) { | ||
input.parentNode.parentNode.classList.add('has--error'); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
}); |
23 changes: 23 additions & 0 deletions
23
...mollie-payments/extension/sw-plugin/component/sw-plugin-config/sw-plugin-config.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{#{% sw_extends 'administration/module/sw-plugin/component/sw-plugin-config/sw-plugin-config.html.twig' %}#} | ||
|
||
{% block sw_plugin_config_actions %} | ||
<template #smart-bar-actions> | ||
{% block sw_plugin_config_actions_abort %} | ||
<sw-button :routerLink="{ name: 'sw.plugin.index' }"> | ||
{{ $tc('global.default.cancel') }} | ||
</sw-button> | ||
{% endblock %} | ||
|
||
{% block sw_plugin_config_actions_test %} | ||
<sw-button @click="onTestButtonClicked"> | ||
{{ $tc('sw-payment.testButton') }} | ||
</sw-button> | ||
{% endblock %} | ||
|
||
{% block sw_plugin_config_actions_save %} | ||
<sw-button variant="primary" class="sw-plugin-config__save-action" @click.prevent="onSave"> | ||
{{ $tc('global.default.save') }} | ||
</sw-button> | ||
{% endblock %} | ||
</template> | ||
{% endblock %} |
1 change: 1 addition & 0 deletions
1
src/Resources/app/administration/src/module/mollie-payments/extension/sw-plugin/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './component/sw-plugin-config'; |
1 change: 1 addition & 0 deletions
1
src/Resources/app/administration/src/module/mollie-payments/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Resources/app/storefront/dist/storefront/js/mollie-payments.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.