diff --git a/Api/Data/DonationInterface.php b/Api/Data/DonationInterface.php
index 0764f8d..497d220 100644
--- a/Api/Data/DonationInterface.php
+++ b/Api/Data/DonationInterface.php
@@ -13,6 +13,7 @@ interface DonationInterface
*/
const DONATION_ID = 'donation_id';
const DONATION_AMOUNT = 'donation_amount';
+ const DONATION_CURRENCY = 'currency';
const STATUS = 'status';
const MODE = 'mode';
const MASKED_QUOTE_ID = 'masked_quote_id';
@@ -50,6 +51,21 @@ public function getDonationAmount(): float;
*/
public function setDonationAmount(float $donationAmount);
+ /**
+ * Get Donation Currency
+ *
+ * @return string
+ */
+ public function getCurrency(): string;
+
+ /**
+ * Set Donation Currency
+ *
+ * @param string $currency
+ * @return $this
+ */
+ public function setCurrency($currency);
+
/**
* Get Status
*
diff --git a/Block/Checkout/LayoutProcessor/DonmoConfig.php b/Block/Checkout/LayoutProcessor/DonmoConfig.php
index 51c21db..72860e3 100644
--- a/Block/Checkout/LayoutProcessor/DonmoConfig.php
+++ b/Block/Checkout/LayoutProcessor/DonmoConfig.php
@@ -32,6 +32,7 @@ public function process($jsLayout)
['children']['donmo-block']['donmoConfig'] = [
'publicKey' => $this->donmoConfig->getPublicKey($this->mode),
'language' => $this->donmoConfig->getLanguageCode(),
+ 'currency' => $this->donmoConfig->getCurrencyCode(),
'integrationTitle' => $this->donmoConfig->getIntegrationTitle(),
'roundupMessage' => $this->donmoConfig->getRoundupMessage(),
'thankMessage' => $this->donmoConfig->getThankMessage(),
diff --git a/Model/Config.php b/Model/Config.php
index 85fd1c4..d487537 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -4,6 +4,7 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Locale\Resolver as LocaleResolver;
+use Magento\Store\Model\StoreManagerInterface;
class Config
{
@@ -17,16 +18,21 @@ class Config
private ScopeConfigInterface $scopeConfig;
private LocaleResolver $localeResolver;
+ private StoreManagerInterface $storeManager;
/**
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(ScopeConfigInterface $scopeConfig, LocaleResolver $localeResolver)
- {
+ public function __construct(
+ ScopeConfigInterface $scopeConfig,
+ LocaleResolver $localeResolver,
+ StoreManagerInterface $storeManager
+ ) {
$this->scopeConfig = $scopeConfig;
$this->localeResolver = $localeResolver;
+ $this->storeManager = $storeManager;
}
public function getCurrentMode(): string
@@ -79,4 +85,9 @@ public function getLanguageCode() : string
$languageCode = strstr($currentLocaleCode, '_', true);
return $languageCode;
}
+
+ public function getCurrencyCode() : string
+ {
+ return $this->storeManager->getStore()->getCurrentCurrencyCode();
+ }
}
diff --git a/Model/Donation.php b/Model/Donation.php
index 912803e..e549962 100644
--- a/Model/Donation.php
+++ b/Model/Donation.php
@@ -56,6 +56,27 @@ public function setDonationAmount($donationAmount)
return $this->setData(self::DONATION_AMOUNT, $donationAmount);
}
+ /**
+ * Get Currency
+ *
+ * @return string
+ */
+ public function getCurrency(): string
+ {
+ return $this->getData(self::DONATION_CURRENCY);
+ }
+
+ /**
+ * Set Status
+ *
+ * @param string $currency
+ * @return $this
+ */
+ public function setCurrency($currency)
+ {
+ return $this->setData(self::DONATION_CURRENCY, $currency);
+ }
+
/**
* Get Status
*
diff --git a/Model/DonationManagement.php b/Model/DonationManagement.php
index f84a5ab..151b06c 100644
--- a/Model/DonationManagement.php
+++ b/Model/DonationManagement.php
@@ -65,6 +65,7 @@ public function createDonation(Order $order): void
$quoteId = $order->getQuoteId();
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
$currentMode = $this->donmoConfig->getCurrentMode();
+ $currency = $order->getOrderCurrency()->getCurrencyCode();
if ($donationAmount) {
$donation = $this->donationFactory->create();
@@ -72,6 +73,7 @@ public function createDonation(Order $order): void
->setOrderId($orderId)
->setMaskedQuoteId($maskedId)
->setDonationAmount($donationAmount)
+ ->setCurrency($currency)
->setMode($currentMode)
->setStatus(self::STATUS_PENDING);
diff --git a/Model/GuestCartDonationManagement.php b/Model/GuestCartDonationManagement.php
index 59077d1..4f8578c 100644
--- a/Model/GuestCartDonationManagement.php
+++ b/Model/GuestCartDonationManagement.php
@@ -28,7 +28,6 @@ public function __construct(
*/
public function addDonationToCart(string $cartId, float $donationAmount): string
{
- $this->logger->info('addDonationToCart guest');
return $this->cartDonationManagement->addDonationToCart($this->maskedQuoteIdToQuoteId->execute($cartId), $donationAmount);
}
diff --git a/ViewModel/Cart/Donmo.php b/ViewModel/Cart/Donmo.php
index b7b0d3e..3eaf963 100644
--- a/ViewModel/Cart/Donmo.php
+++ b/ViewModel/Cart/Donmo.php
@@ -29,6 +29,7 @@ public function getDonmoConfig(): string
$this->json->serialize([
'publicKey' => $this->donmoConfig->getPublicKey($this->mode),
'language' => $this->donmoConfig->getLanguageCode(),
+ 'currency' => $this->donmoConfig->getCurrencyCode(),
'integrationTitle' => $this->donmoConfig->getIntegrationTitle(),
'roundupMessage' => $this->donmoConfig->getRoundupMessage(),
'thankMessage' => $this->donmoConfig->getThankMessage(),
diff --git a/etc/db_schema.xml b/etc/db_schema.xml
index 6fdc7ad..382fe75 100644
--- a/etc/db_schema.xml
+++ b/etc/db_schema.xml
@@ -11,6 +11,8 @@
+
+
diff --git a/lib/ApiService.php b/lib/ApiService.php
index 50ab1da..fcd327d 100644
--- a/lib/ApiService.php
+++ b/lib/ApiService.php
@@ -31,7 +31,8 @@ private function generatePayload(array $donations): array
$payload[] = [
'donationAmount' => $donation->getDonationAmount(),
'createdAt' => $donation->getCreatedAt(),
- 'orderId' => $donation->getMaskedQuoteId()
+ 'orderId' => $donation->getMaskedQuoteId(),
+ 'currency' => $donation->getCurrency()
];
}
return $payload;
@@ -46,13 +47,13 @@ public function createAndConfirmDonations($mode, array $donations): int
{
$sk = $this->donmoConfig->getSecretKey($mode);
- $url = Donmo::$apiBase . '/donations/confirm';
+ $url = Donmo::$apiBase . '/donations';
$ch = curl_init();
- $headers = array(
+ $headers = [
'Content-Type: application/json',
"sk: $sk"
- );
+ ];
$payload = $this->generatePayload($donations);
$body = json_encode(['donations' => $payload]);
@@ -84,10 +85,10 @@ public function deleteDonation($donationMode, $id): int
$url = Donmo::$apiBase . "/donations/{$id}";
$ch = curl_init();
- $headers = array(
+ $headers = [
'Content-Type: application/json',
"sk: $sk"
- );
+ ];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
diff --git a/lib/Donmo.php b/lib/Donmo.php
index 01f812f..e670ff4 100644
--- a/lib/Donmo.php
+++ b/lib/Donmo.php
@@ -4,5 +4,5 @@
class Donmo
{
- public static string $apiBase = 'https://api.donmo.org/v1/ua';
+ public static string $apiBase = 'https://api.donmo.org/v1';
}
diff --git a/view/adminhtml/ui_component/donmo_report.xml b/view/adminhtml/ui_component/donmo_report.xml
index aa3a8a4..212f4ae 100644
--- a/view/adminhtml/ui_component/donmo_report.xml
+++ b/view/adminhtml/ui_component/donmo_report.xml
@@ -103,7 +103,6 @@
text
@@ -112,10 +111,19 @@
+
+
+ text
+ text
+
+
+
+
+ sortOrder="26">
text
text
@@ -126,7 +134,7 @@
text
@@ -137,7 +145,7 @@
+ sortOrder="28">
select
@@ -149,7 +157,7 @@
diff --git a/view/frontend/web/js/view/cart/donmo-block.js b/view/frontend/web/js/view/cart/donmo-block.js
index df4baae..dfd9bea 100644
--- a/view/frontend/web/js/view/cart/donmo-block.js
+++ b/view/frontend/web/js/view/cart/donmo-block.js
@@ -54,6 +54,7 @@ define([
isBackendBased: true,
elementId: 'donmo-roundup',
language: this.donmoConfig.language,
+ currency: this.donmoConfig.currency,
orderId: quote.getQuoteId(),
integrationTitle: this.donmoConfig.integrationTitle,
roundupMessage: this.donmoConfig.roundupMessage,
diff --git a/view/frontend/web/js/view/checkout/summary/donmo-block.js b/view/frontend/web/js/view/checkout/summary/donmo-block.js
index df4baae..dfd9bea 100644
--- a/view/frontend/web/js/view/checkout/summary/donmo-block.js
+++ b/view/frontend/web/js/view/checkout/summary/donmo-block.js
@@ -54,6 +54,7 @@ define([
isBackendBased: true,
elementId: 'donmo-roundup',
language: this.donmoConfig.language,
+ currency: this.donmoConfig.currency,
orderId: quote.getQuoteId(),
integrationTitle: this.donmoConfig.integrationTitle,
roundupMessage: this.donmoConfig.roundupMessage,