Skip to content

Commit

Permalink
Release 1.0.43
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralbala committed Mar 13, 2023
1 parent 065f6a4 commit 8b640e0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
12 changes: 12 additions & 0 deletions Application/Model/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public function getVersion(){
return $this->version;
}

public function getEmailSent(){
return $this->getFieldData('pfcemailsent');
}

public function setOrderId($value){
$this->_setFieldData('oxorderid', $value);
}
Expand Down Expand Up @@ -141,6 +145,14 @@ protected function setSdkTransaction($value){
$this->sdkTransaction = $value;
}

public function setEmailSent($value){
$this->_setFieldData('pfcemailsent', $value);
}

public function markEmailAsSent(){
$this->setEmailSent(true);
}

public function loadByOrder($orderId){
$select = $this->buildSelectString(array(
'oxorderid' => $orderId
Expand Down
37 changes: 36 additions & 1 deletion Extend/Application/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,42 @@ public function PostFinanceCheckoutAuthorize(){
$basket = $this->getPostFinanceCheckoutBasket();
$basket->onUpdate();
$basket->calculateBasket();
$res = $this->_sendOrderByEmail($this->getOrderUser(), $basket, $this->getPaymentType());

if ($this->checkPostFinanceCheckoutEmailSent()) {
$res = $this->_sendOrderByEmail($this->getOrderUser(), $basket, $this->getPaymentType());
$this->markPostFinanceCheckoutEmailAsSent();
PostFinanceCheckoutModule::log(Logger::DEBUG, "Confirmation email was sent {$this->getId()}.");
}
}

/**
* Check if the email was sent when the transaction state is updated to authorized to avoid duplicate emails.
* Return true if the email hasn't been emailed yet
*
* @return bool
*/
public function checkPostFinanceCheckoutEmailSent(){
$currentState = substr($this->getFieldData('OXTRANSSTATUS'), strlen('POSTFINANCECHECKOUT_'));
$transaction = $this->getPostFinanceCheckoutTransaction();

if ($currentState === TransactionState::AUTHORIZED && !$transaction->getEmailSent()) {
return true;
}

$sent = $transaction->getEmailSent() ? 'yes' : 'no';
PostFinanceCheckoutModule::log(Logger::DEBUG,
"Attempted to send an email on order {$this->getId()} with current state {$currentState}, was sent? {$sent}.");

return false;
}

/**
* Marks as sent when the transaction state is updated to authorized only the first time.
*/
public function markPostFinanceCheckoutEmailAsSent(){
$transaction = $this->getPostFinanceCheckoutTransaction();
$transaction->markEmailAsSent();
$transaction->save();
}

public function setPostFinanceCheckoutPaid(){
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# OXID 6.X

v1.0.42, 2023-1
v1.0.43, 2023-3

This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html).

Expand Down Expand Up @@ -33,8 +33,8 @@ Support queries can be issued on the [PostFinance Checkout support site](https:/

## Documentation

* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.42/docs/en/documentation.html)
* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.43/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.42/LICENSE) for more information.
Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.43/LICENSE) for more information.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/3_fix_emails_optimistic_locking_migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `pfcPostFinanceCheckout_transaction` ADD `PFCEMAILSENT` bool DEFAULT '0';
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# OXID 6.X

v1.0.42, 2023-1
v1.0.43, 2023-3

This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html).

Expand Down Expand Up @@ -33,8 +33,8 @@ Support queries can be issued on the [PostFinance Checkout support site](https:/

## Documentation

* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.42/docs/en/documentation.html)
* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.43/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.42/LICENSE) for more information.
Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.43/LICENSE) for more information.
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/pfpayments/oxid-6.0/releases/tag/1.0.42/">
<a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.43/">
Source
</a>
</li>
Expand All @@ -49,7 +49,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.42/">Download</a> the extension.</p>
<p><a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.43/">Download</a> the extension.</p>
</li>
<li>
<p>Extract the files and upload them to the root directory of your store using FTP/SSH.</p>
Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'en' => 'PFC PostFinanceCheckout Module'
),
'thumbnail' => 'out/pictures/picture.png',
'version' => '1.0.42',
'version' => '1.0.43',
'author' => 'customweb GmbH',
'url' => 'https://www.customweb.com',
'email' => 'info@customweb.com',
Expand Down

0 comments on commit 8b640e0

Please sign in to comment.