Page 1 of 1
[v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Tue Oct 10, 2017 6:18 am
by straightlight
In admin/controller/marketplace/api.php file,
find:
Code: Select all
$this->response->setOutput($this->load->view('marketplace/api', $data));
add above:
Code: Select all
if ($this->config->has('opencart_username')) {
$data['opencart_username'] = html_entity_decode($this->config->get('opencart_username'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_username'] = '';
}
if ($this->config->has('opencart_secret')) {
$data['opencart_secret'] = html_entity_decode($this->config->get('opencart_secret'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_secret'] = '';
}
In admin/view/template/marketplace/api.twig file,
find:
Code: Select all
if (json['error']['username']) {
$('input[name="username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
replace with:
Code: Select all
if (json['error']['username']) {
$('input[name="opencart_username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="opencart_secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
Then, find:
Code: Select all
<input type="text" name="opencart_username" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
replace with:
Code: Select all
<input type="text" name="opencart_username" value="{{ opencart_username }}" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
Then, find:
Code: Select all
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control"></textarea>
replace with:
Code: Select all
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control">{{ opencart_secret }}</textarea>
This should resolved the problem.
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Wed Oct 11, 2017 6:12 am
by TBFdirect
this did not seem to fix the problem, here is a copy of my amended files
api.php
Code: Select all
<?php
class ControllerMarketplaceApi extends Controller {
public function index() {
$this->load->language('marketplace/api');
$data['user_token'] = $this->session->data['user_token'];
if ($this->config->has('opencart_username')) {
$data['opencart_username'] = html_entity_decode($this->config->get('opencart_username'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_username'] = '';
}
if ($this->config->has('opencart_secret')) {
$data['opencart_secret'] = html_entity_decode($this->config->get('opencart_secret'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_secret'] = '';
}
$this->response->setOutput($this->load->view('marketplace/api', $data));
}
public function save() {
$this->load->language('marketplace/api');
$json = array();
if (!$this->user->hasPermission('modify', 'marketplace/api')) {
$json['error']['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['opencart_username']) {
$json['error']['username'] = $this->language->get('error_username');
}
if (!$this->request->post['opencart_secret']) {
$json['error']['secret'] = $this->language->get('error_secret');
}
if (!$json) {
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting('opencart', $this->request->post);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
api.twig
Code: Select all
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><i class="fa fa-cog"></i> {{ heading_title }}</h4>
</div>
<div class="modal-body">
<div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_signup }}</div>
<div class="form-group">
<label for="input-username">{{ entry_username }}</label>
<input type="text" name="opencart_username" value="{{ opencart_username }}" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
</div>
<div class="form-group">
<label for="input-secret">{{ entry_secret }}</label>
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control">{{ opencart_secret }}</textarea>
</div>
<div class="form-group text-right">
<button type="button" id="button-save" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_save }}</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"><!--
$('#button-save').on('click', function(e) {
$.ajax({
url: 'index.php?route=marketplace/api/save&user_token={{ user_token }}',
type: 'post',
dataType: 'json',
data: $('#modal-opencart :input'),
beforeSend: function() {
$('#button-save').button('loading');
},
complete: function() {
$('#button-save').button('reset');
},
success: function(json) {
$('.alert-dismissible, .text-danger').remove();
if (json['error']) {
if (json['error']['warning']) {
$('#modal-opencart .modal-body').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
}
if (json['error']['username']) {
$('input[name="opencart_username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="opencart_secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
}
if (json['success']) {
$('#modal-opencart .modal-body').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
window.location.reload();
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Wed Oct 11, 2017 6:42 am
by straightlight
From the controller, one thing that could be re-changed would be:
Code: Select all
if (!empty($this->request->post['opencart_username'])) {
$data['opencart_username'] = $this->request->post['opencart_username'];
} elseif ($this->config->has('opencart_username')) {
$data['opencart_username'] = html_entity_decode($this->config->get('opencart_username'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_username'] = '';
}
if (!empty($this->request->post['opencart_secret'])) {
$data['opencart_secret'] = $this->request->post['opencart_secret'];
} elseif ($this->config->has('opencart_secret')) {
$data['opencart_secret'] = html_entity_decode($this->config->get('opencart_secret'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_secret'] = '';
}
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Wed Oct 11, 2017 5:55 pm
by TBFdirect
i'm not sure if its the api that is the problem here?
no apps from the store show at all, see attached img
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Wed Jan 17, 2018 12:56 pm
by jeffm2000
I tried to apply both fixes suggested, and it did not seem to fix the problem. There was no change. Without this fix, I am dead in the water. It is impossible to setup a payment plan of any kind.
This bug means that anyone trying to install opencart for the first time will be unable to complete the install and setup a simple payment gateway.
It seems this bug has been around for a while. Has anyone figured out a way around this issue???
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Sat Dec 29, 2018 3:25 am
by bavington12
straightlight wrote: ↑Tue Oct 10, 2017 6:18 am
In admin/controller/marketplace/api.php file,
find:
Code: Select all
$this->response->setOutput($this->load->view('marketplace/api', $data));
add above:
Code: Select all
if ($this->config->has('opencart_username')) {
$data['opencart_username'] = html_entity_decode($this->config->get('opencart_username'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_username'] = '';
}
if ($this->config->has('opencart_secret')) {
$data['opencart_secret'] = html_entity_decode($this->config->get('opencart_secret'), ENT_QUOTES, 'UTF-8');
} else {
$data['opencart_secret'] = '';
}
In admin/view/template/marketplace/api.twig file,
find:
Code: Select all
if (json['error']['username']) {
$('input[name="username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
replace with:
Code: Select all
if (json['error']['username']) {
$('input[name="opencart_username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="opencart_secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
Then, find:
Code: Select all
<input type="text" name="opencart_username" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
replace with:
Code: Select all
<input type="text" name="opencart_username" value="{{ opencart_username }}" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
Then, find:
Code: Select all
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control"></textarea>
replace with:
Code: Select all
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control">{{ opencart_secret }}</textarea>
This should resolved the problem.
Is this the fix to getting the API marketplace work in the admin section
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Sat Dec 29, 2018 7:03 am
by straightlight
As per the folder name indicates.
Re: [v3.0.2.0 - Fix] - Admin MarketPlace API
Posted: Thu Oct 15, 2020 12:18 am
by alexlii1971
This does not fix the issue, and I found the code contents are different, but installed exactly Version 3.0.3.2:
here are my copies attatched and content as below:
api.php
Code: Select all
<?php
class ControllerMarketplaceApi extends Controller {
public function index() {
$this->load->language('marketplace/api');
$data['user_token'] = $this->session->data['user_token'];
$this->response->setOutput($this->load->view('marketplace/api', $data));
}
public function save() {
$this->load->language('marketplace/api');
$json = array();
if (!$this->user->hasPermission('modify', 'marketplace/api')) {
$json['error']['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['opencart_username']) {
$json['error']['username'] = $this->language->get('error_username');
}
if (!$this->request->post['opencart_secret']) {
$json['error']['secret'] = $this->language->get('error_secret');
}
if (!$json) {
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting('opencart', $this->request->post);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
and api.twig
Code: Select all
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><i class="fa fa-cog"></i> {{ heading_title }}</h4>
</div>
<div class="modal-body">
<div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_signup }}</div>
<div class="form-group">
<label for="input-username">{{ entry_username }}</label>
<input type="text" name="opencart_username" value="" placeholder="{{ entry_username }}" id="input-username" class="form-control" />
</div>
<div class="form-group">
<label for="input-secret">{{ entry_secret }}</label>
<textarea name="opencart_secret" placeholder="{{ entry_secret }}" rows="8" id="input-secret" class="form-control"></textarea>
</div>
<div class="form-group text-right">
<button type="button" id="button-save" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_save }}</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"><!--
$('#button-save').on('click', function(e) {
$.ajax({
url: 'index.php?route=marketplace/api/save&user_token={{ user_token }}',
type: 'post',
dataType: 'json',
data: $('#modal-opencart :input'),
beforeSend: function() {
$('#button-save').button('loading');
},
complete: function() {
$('#button-save').button('reset');
},
success: function(json) {
$('.alert-dismissible, .text-danger').remove();
if (json['error']) {
if (json['error']['warning']) {
$('#modal-opencart .modal-body').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
}
if (json['error']['username']) {
$('input[name="opencart_username"]').after('<div class="text-danger">' + json['error']['username'] + '</div>');
}
if (json['error']['secret']) {
$('textarea[name="opencart_secret"]').after('<div class="text-danger">' + json['error']['secret'] + '</div>');
}
}
}
if (json['success']) {
$('#modal-opencart .modal-body').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
window.location.reload();
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>