Skip to content

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
edgaraswallee committed Jun 22, 2023
1 parent 229c1fc commit 8e1b4fd
Show file tree
Hide file tree
Showing 12 changed files with 839 additions and 40 deletions.
415 changes: 415 additions & 0 deletions MailMessage.php

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions MailMessageAttachment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
if (! defined('_PS_VERSION_')){
exit();
}
/**
* Represents a mail attachment.
*
* @author Thomas Hunziker
*
*/
class MailMessageAttachment {

private $content;

private $name;

private $mimeType;

/**
* Constructor.
*
* Either the input as defined by Mail::send() for mail attachment
* or a mail attachment. In later case the attachment is copied.
*
* @param array|MailMessageAttachment $input
*/
public function __construct($input = null) {
if ($input instanceof MailMessageAttachment) {
$this->content = $input->content;
$this->name = $input->name;
$this->mimeType = $input->mimeType;
}
else if (is_array($input)) {
if (isset($input['content'])) {
$this->setContent($input['content']);
}
if (isset($input['name'])) {
$this->setName($input['name']);
}
if (isset($input['mime'])) {
$this->setMimeType($input['mime']);
}
}
}

/**
* Returns the attachment content.
*
* @return string
*/
public function getContent(){
return $this->content;
}

/**
* Sets the attachment content. This may be binary data.
*
* @param string $content
* @return MailMessageAttachment
*/
public function setContent($content){
$this->content = $content;
return $this;
}

/**
* Returns the name shown to the customer in the mail message.
*
* @return string
*/
public function getName(){
return $this->name;
}

/**
* Sets the name shown to the customer in the mail message.
*
* @param string $name
* @return MailMessageAttachment
*/
public function setName($name){
$this->name = $name;
return $this;
}

/**
* Returns the mime type of the attachment. E.g. application/pdf, text/html.
*
* @return string
*/
public function getMimeType(){
return $this->mimeType;
}

/**
* Sets the mime type of the mail attachment. E.g. application/pdf, text/html.
*
* @param string $mimeType
* @return MailMessageAttachment
*/
public function setMimeType($mimeType){
$this->mimeType = $mimeType;
return $this;
}

/**
* Returns the attachment as an array. This method is
* need to provide the correct input for Mail::send().
*
* @return array
*/
public function toArray() {
return array(
'content' => $this->getContent(),
'name' => $this->getName(),
'mime' => $this->getMimeType(),
);
}



}
124 changes: 124 additions & 0 deletions MailMessageEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
if (! defined('_PS_VERSION_')){
exit();
}
/**
* This class represents a mail message sending event. An object
* of this class is propagated in case an e-mail is sent.
*
* @author Thomas Hunziker
*
*/
class MailMessageEvent {

/**
* @var string
*/
private $name;

/**
* @var boolean
*/
private $die = false;

/**
* @var MailMessage[]
*/
private $messages = array();

/**
* Constructor.
*
* The name is used as identification of the event. It is normally
* the name of the template.
*
* @param string $name
*/
public function __construct($name) {
$this->name = (string)$name;
}

/**
* In case this method returns true, any error will stop the PHP
* process. Otherwise in case of an error the mail is not sent and
* the error is logged. But the process continues.
*
* By default this method returns false.
*
* @return boolean
*/
public function isDie(){
return $this->die;
}

/**
* Sets the behaviour in case of an error. See MailMessageEvent::isDie() for
* more information.
*
* By default it is set to false. In most cases this should not be changed.
*
* @param string $die
* @return MailMessageEvent
*/
public function setDie($die = true){
$this->die = $die;
return $this;
}

/**
* Returns the name of the e-mail event. This is the original template name of the
* e-mail. E.g. order_conf in case of the order confirmation. The name
* should be used to identify the event. For example if something should be changed
* in case of order confirmation the hook should filter with the expression:
*
* <code>
* if ($event->getName() == 'order_conf') {
* // Change messages
* }
* </code>
*
* @return string
*/
public function getName(){
return $this->name;
}

/**
* Returns a list of MailMessage send by this event. By default the list contains
* exaclty one message. In case the hook whats to suppress the sending of the message,
* the list should be set to an empty array. In case more than one message should be send
* more messages can be added.
*
* @return MailMessage[]
*/
public function getMessages(){
return $this->messages;
}

/**
* Returns the list of messages sent by the event. By default the list contains
* one message. Listeners of the event may add more messages or remove all message, which
* does prevent sending any mail message.
*
* @param MailMessage[] $messages
* @return MailMessageEvent
*/
public function setMessages(array $messages){
$this->messages = $messages;
return $this;
}

/**
* Adds the given message to the event. See MailMessageEvent::setMessages() for more information
* about the behaviour of multiple messages.
*
* @param MailMessage $message
* @return MailMessageEvent
*/
public function addMessage(MailMessage $message) {
$this->messages[] = $message;
return $this;
}


}
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# PrestaShop 8 wallee Integration
This repository contains the PrestaShop wallee payment module that enables the shop to process payments with [wallee](https://www.wallee.com).

## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.1/wallee.zip) of module with correct structure required by Prestashop installation

##### To use this extension, a [wallee](https://app-wallee.com/user/signup) account is required.

## Requirements

* [PrestaShop](https://www.prestashop.com/) 8
* [PHP](http://php.net/) 8.1 or later
* [Mailhook](https://github.com/wallee-payment/prestashop-mailhook/releases) to modify PrestaShop email behavior.

## Documentation

* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.0/docs/en/documentation.html)
* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.1/docs/en/documentation.html)

## Support

Support queries can be issued on the [wallee support site](https://app-wallee.com/space/select?target=/support).

## License

Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.0/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.1/LICENSE) for more information.

## Other PrestaShop Versions

Find the module for different PrestaShop versions [here](../../../prestashop).

## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.0/wallee.zip) of module with correct structure required by Prestashop installation
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.0/">
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.1/">
Source
</a>
</li>
Expand Down Expand Up @@ -51,7 +51,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.0/">Download</a> the module.</p>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.1/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down
29 changes: 0 additions & 29 deletions inc/Basemodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ private static function getOrder(array $params)

public static function checkRequirements(Wallee $module)
{
if (!Module::isInstalled('mailhook')) {
$module->addError(
Tools::displayError(
'The module mailhook is required.'
)
);
return false;
}
try {
\Wallee\Sdk\Http\HttpClientFactory::getClient();
} catch (Exception $e) {
Expand Down Expand Up @@ -255,27 +247,6 @@ public static function displayHelpButtons(Wallee $module)
return $module->display(dirname(dirname(__FILE__)), 'views/templates/admin/admin_help_buttons.tpl');
}

public static function getMailHookActiveWarning(Wallee $module)
{
$output = "";
if (! Module::isInstalled('mailhook') || ! Module::isEnabled('mailhook')) {
$error = "<b>" . $module->l('The module "Mail Hook" is not active.', 'basemodule') . "</b>";
$error .= "<br/>";
$error .= $module->l(
'This module is recommend for handling the shop emails. Otherwise the mail sending behavior may be inappropriate.',
'basemodule'
);
$error .= "<br/>";
$error .= sprintf(
$module->l('You can download the module %shere%s.', 'basemodule'),
'<a href="https://github.com/wallee-payment/prestashop-mailhook/releases" target="_blank">',
'</a>'
);
$output .= $module->displayError($error);
}
return $output;
}

public static function handleSaveAll(Wallee $module)
{
$output = "";
Expand Down
Loading

0 comments on commit 8e1b4fd

Please sign in to comment.