Skip to content

Commit

Permalink
various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiodionisi committed Jul 27, 2018
1 parent c6399d5 commit 1ad6fb8
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 211 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions README.md

This file was deleted.

28 changes: 0 additions & 28 deletions app/code/community/Satispay/Satispay/Model/Observer.php

This file was deleted.

1 change: 0 additions & 1 deletion app/code/community/Satispay/Satispay/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public function refund(Varien_Object $payment, $amount) {

\SatispayOnline\Api::setSecurityBearer($helper->getSecurityBearer($payment->getOrder()->getStoreId()));
\SatispayOnline\Api::setStaging($helper->isStaging($payment->getOrder()->getStoreId()));

\SatispayOnline\Api::setPluginName('Magento');
\SatispayOnline\Api::setType('ECOMMERCE-PLUGIN');
$magentoVersion = Mage::getVersionInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ public function indexAction() {

\SatispayOnline\Api::setSecurityBearer($helper->getSecurityBearer());
\SatispayOnline\Api::setStaging($helper->isStaging());

\SatispayOnline\Api::setPluginName('Magento');
\SatispayOnline\Api::setType('ECOMMERCE-PLUGIN');
$magentoVersion = Mage::getVersionInfo();
\SatispayOnline\Api::setPlatformVersion($magentoVersion['major'].'.'.$magentoVersion['minor'].'.'.$magentoVersion['revision']);

$charge_id = $this->getRequest()->getQuery('charge_id');
$charge = \SatispayOnline\Charge::get($charge_id);
$charge = \SatispayOnline\Charge::get($this->getRequest()->getQuery('charge_id'));
$order = Mage::getModel('sales/order')->load($charge->metadata->order_id);

if ($charge->status === 'SUCCESS') {
$payment = $order->getPayment();
$payment->setTransactionId($charge_id)
->setIsTransactionClosed(false)
->registerCaptureNotification($order->getGrandTotal(), false);
$order->save();
if ($order->getStatus() === 'pending') {
if ($charge->status === 'SUCCESS') {
$payment = $order->getPayment();
$payment->setTransactionId($charge->id)
->setIsTransactionClosed(false)
->registerCaptureNotification($order->getGrandTotal(), false);
$order->save();

$invoice = $payment->getCreatedInvoice();
if ($invoice && !$order->getEmailSent()) {
$order->queueNewOrderEmail()
->setIsCustomerNotified(true)
->save();
$invoice = $payment->getCreatedInvoice();
if ($invoice && !$order->getEmailSent()) {
$order->queueNewOrderEmail()
->setIsCustomerNotified(true)
->save();
}
}
}

if ($charge->status === 'FAILURE') {
$order->cancel()->save();
if ($charge->status === 'FAILURE') {
$order->cancel()->save();
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
require_once(dirname(__FILE__).'/../includes/online-api-php-sdk/init.php');

class Satispay_Satispay_ExpireController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$helper = Mage::helper('satispay');

\SatispayOnline\Api::setSecurityBearer($helper->getSecurityBearer());
\SatispayOnline\Api::setStaging($helper->isStaging());
\SatispayOnline\Api::setPluginName('Magento');
\SatispayOnline\Api::setType('ECOMMERCE-PLUGIN');
$magentoVersion = Mage::getVersionInfo();
\SatispayOnline\Api::setPlatformVersion($magentoVersion['major'].'.'.$magentoVersion['minor'].'.'.$magentoVersion['revision']);

$order = Mage::getModel('sales/order')->load($this->getRequest()->getQuery('order_id'));
if ($order->getStatus() === 'pending') {
$order->cancel()->save();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public function indexAction() {

\SatispayOnline\Api::setSecurityBearer($helper->getSecurityBearer());
\SatispayOnline\Api::setStaging($helper->isStaging());

\SatispayOnline\Api::setPluginName('Magento');
\SatispayOnline\Api::setType('ECOMMERCE-PLUGIN');
$magentoVersion = Mage::getVersionInfo();
Expand All @@ -16,23 +15,47 @@ public function indexAction() {
$session = Mage::getSingleton('checkout/session');
$order = $session->getLastRealOrder();

$checkout = \SatispayOnline\Checkout::create(array(
'description' => '#'.$order->getIncrementId(),
'phone_number' => '',
'redirect_url' => Mage::getUrl('satispay/redirect', array(
$backFromSatispay = $this->getRequest()->getQuery('back-from-satispay');
if (!empty($backFromSatispay)) {
$session->clearHelperData();
$order->cancel()->save();

$cart = Mage::getSingleton('checkout/cart');
$items = $order->getItemsCollection();
foreach ($items as $item) {
try {
$cart->addOrderItem($item);
} catch (Exception $e) { }
}
$cart->save();

$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart', array(
'_secure' => true
)),
'callback_url' => Mage::getUrl('satispay/callback', array(
'_secure' => true,
'_query' => 'charge_id={uuid}'
)),
'amount_unit' => round($order->getGrandTotal() * 100),
'currency' => $order->getOrderCurrencyCode(),
'metadata' => array(
'order_id' => $order->getId()
)
));
)));
} else {
$checkout = \SatispayOnline\Checkout::create(array(
'description' => '#'.$order->getIncrementId(),
'phone_number' => '',
'redirect_url' => Mage::getUrl('satispay/redirect', array(
'_secure' => true
)),
'callback_url' => Mage::getUrl('satispay/callback', array(
'_secure' => true,
'_query' => 'charge_id={uuid}'
)),
'checkout_expire_callback_url' => Mage::getUrl('satispay/expire', array(
'_secure' => true,
'_query' => 'order_id='.$order->getId()
)),
'expire_in' => 60*15,
'amount_unit' => round($order->getGrandTotal() * 100),
'currency' => $order->getOrderCurrencyCode(),
'metadata' => array(
'order_id' => $order->getId()
)
));

$this->getResponse()->setRedirect($checkout->checkout_url);
$this->getResponse()->setBody("<script>history.replaceState({}, '', '?back-from-satispay=1'); setTimeout(function () { location.href = '$checkout->checkout_url'; }, 200);</script>");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public function indexAction() {

\SatispayOnline\Api::setSecurityBearer($helper->getSecurityBearer());
\SatispayOnline\Api::setStaging($helper->isStaging());

\SatispayOnline\Api::setPluginName('Magento');
\SatispayOnline\Api::setType('ECOMMERCE-PLUGIN');
$magentoVersion = Mage::getVersionInfo();
Expand All @@ -30,14 +29,10 @@ public function indexAction() {
foreach ($items as $item) {
try {
$cart->addOrderItem($item);
} catch (Exception $e) {
$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart', array(
'_secure' => true
)));
}
} catch (Exception $e) { }
}

$cart->save();

$this->getResponse()->setRedirect(Mage::getUrl('checkout/cart', array(
'_secure' => true
)));
Expand Down
14 changes: 1 addition & 13 deletions app/code/community/Satispay/Satispay/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Satispay_Satispay>
<version>1.4.3</version>
<version>1.5.0</version>
</Satispay_Satispay>
</modules>
<global>
Expand Down Expand Up @@ -50,16 +50,4 @@
</satispay>
</payment>
</default>
<crontab>
<jobs>
<satispay_check_pendings>
<schedule>
<cron_expr>* * * * *</cron_expr>
</schedule>
<run>
<model>satispay/observer::checkPendings</model>
</run>
</satispay_check_pendings>
</jobs>
</crontab>
</config>
2 changes: 1 addition & 1 deletion app/code/community/Satispay/Satispay/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<satispay translate="label">
<label>Satispay</label>
<frontend_type>text</frontend_type>
<sort_order>5</sort_order>
<sort_order>9</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
require(dirname(__FILE__) . '/lib/Api.php');
require_once(dirname(__FILE__) . '/lib/Api.php');

require(dirname(__FILE__) . '/lib/Bearer.php');
require(dirname(__FILE__) . '/lib/Charge.php');
require(dirname(__FILE__) . '/lib/Checkout.php');
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/User.php');
require_once(dirname(__FILE__) . '/lib/Bearer.php');
require_once(dirname(__FILE__) . '/lib/Charge.php');
require_once(dirname(__FILE__) . '/lib/Checkout.php');
require_once(dirname(__FILE__) . '/lib/Refund.php');
require_once(dirname(__FILE__) . '/lib/User.php');
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Api {
public static $endpointStaging = 'https://staging.authservices.satispay.com';
public static $endpoint = 'https://authservices.satispay.com';
public static $version = '1.6.4';
public static $version = '1.6.5';

public static $securityBearer = '';
public static $staging = false;
Expand Down
12 changes: 8 additions & 4 deletions connect/Satispay.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<_>
<form_key>kTwfouTH8gvGDGjy</form_key>
<form_key>V6IQHPTSQX6nZaJ4</form_key>
<name>Satispay_Satispay</name>
<channel>community</channel>
<version_ids>
Expand All @@ -9,9 +9,9 @@
<description>Satispay is a new payment system that allows you to pay stores or friends from your smartphone. To make the service more secure, more efficient and cheaper, we constructed an entirely new platform that is independent from traditional payment methods such as debit and credit cards.</description>
<license>GPL-3.0</license>
<license_uri>https://www.gnu.org/licenses/gpl-3.0.en.html</license_uri>
<version>1.4.3</version>
<version>1.5.0</version>
<stability>stable</stability>
<notes>Fixed multi website refund</notes>
<notes>Various Improvements</notes>
<authors>
<name>
<name>Satispay</name>
Expand Down Expand Up @@ -40,7 +40,7 @@
<max/>
</max>
<files>
<files> </files>
<files> </files>
</files>
</package>
<extension>
Expand Down Expand Up @@ -82,4 +82,8 @@
<ignore/>
</ignore>
</contents>
<page>1</page>
<limit>200</limit>
<folder/>
<package/>
</_>
Loading

0 comments on commit 1ad6fb8

Please sign in to comment.