Created
May 25, 2021 17:22
-
-
Save GiovanniCavallari/4022f6d6521505d0bec13f398a10deb0 to your computer and use it in GitHub Desktop.
Mercadopago plugin index file for stores with multistores
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
/** | |
* Create the payment states | |
* | |
* @return bool | |
* @throws PrestaShopDatabaseException | |
* @throws PrestaShopException | |
*/ | |
public function createPaymentStates() | |
{ | |
$order_states = array( | |
array('#ccfbff', $this->l('Transaction in Process'), 'in_process', '110010000'), | |
array('#c9fecd', $this->l('Transaction Completed'), 'payment', '110010010'), | |
array('#fec9c9', $this->l('Transaction Canceled'), 'order_canceled', '100010000'), | |
array('#fec9c9', $this->l('Transaction Declined'), 'payment_error', '100010000'), | |
array('#ffeddb', $this->l('Transaction Refunded'), 'refund', '100010000'), | |
array('#c28566', $this->l('Transaction Chargedback'), 'charged_back', '100010000'), | |
array('#b280b2', $this->l('Transaction in Mediation'), 'in_mediation', '100010000'), | |
array('#fffb96', $this->l('Transaction Pending'), 'pending', '110010000'), | |
array('#ccfbff', $this->l('Transaction Authorized'), 'authorized', '100010000'), | |
array('#ffb0d9', $this->l('Transaction in Possible Fraud'), 'payment_error', '100010000'), | |
); | |
foreach ($order_states as $key => $value) { | |
if ($this->orderStateAvailable(Configuration::get('MERCADOPAGO_STATUS_' . $key)) == 1) { | |
continue; | |
} else { | |
$order_state = new OrderState(); | |
$order_state->name = array(); | |
$order_state->template = array(); | |
$order_state->module_name = $this->name; | |
$order_state->color = $value[0]; | |
$order_state->invoice = $value[3][0]; | |
$order_state->send_email = $value[3][1]; | |
$order_state->unremovable = $value[3][2]; | |
$order_state->hidden = $value[3][3]; | |
$order_state->logable = $value[3][4]; | |
$order_state->delivery = $value[3][5]; | |
$order_state->shipped = $value[3][6]; | |
$order_state->paid = $value[3][7]; | |
$order_state->deleted = $value[3][8]; | |
$order_state->name = array_fill(0, 10, $value[1]); | |
$order_state->template = array_fill(0, 10, $value[2]); | |
if ($order_state->add()) { | |
$file = _PS_ROOT_DIR_ . '/img/os/' . (int) $order_state->id . '.gif'; | |
copy((dirname(__FILE__) . '/views/img/mp_icon.gif'), $file); | |
Configuration::updateGlobalValue('MERCADOPAGO_STATUS_' . $key, $order_state->id); | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment