Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from appinlet/release/1.0.7
Browse files Browse the repository at this point in the history
Release/1.0.7
  • Loading branch information
appinlet authored Sep 17, 2020
2 parents bbbea96 + 6fd9bf0 commit 32cf3f3
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 74 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PayWeb_Magento_1
## PayGate Magento plugin v1.0.6 for Magento v1.9.4.3
## PayGate Magento plugin v1.0.7 for Magento v1.9.4.x

This is the PayGate PayWeb3 plugin for Magento 1. Please feel free to contact the PayGate support team at support@paygate.co.za should you require any assistance.

## Installation
[![How To Setup PayGate PayWeb for Magento 1](https://www.appinlet.com/wp-content/uploads/2018/09/Magento-1-Integration.jpg)](https://www.youtube.com/watch?v=jv_mGpYW7yA "How To Setup PayGate PayWeb for Magento 1")

Please navigate to the [releases page](https://github.com/PayGate/PayWeb_Magento_1/releases), download the latest release (v1.0.6) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.
Please navigate to the [releases page](https://github.com/PayGate/PayWeb_Magento_1/releases), download the latest release (v1.0.7) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down
2 changes: 1 addition & 1 deletion Redirect/app/code/local/PayGate/Pay/Model/Functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down Expand Up @@ -65,7 +65,7 @@ public function redirectAction()
'REFERENCE' => $order->getRealOrderId(),
'AMOUNT' => number_format( $order->getGrandTotal(), 2, '', '' ),
'CURRENCY' => $order->getOrderCurrencyCode(),
'RETURN_URL' => $module->getReturnUrl(),
'RETURN_URL' => $module->getReturnUrl() . '?gid=' . $order->getRealOrderId() . '&qid=' . $quoteId,
'TRANSACTION_DATE' => date( 'Y-m-d H:i' ),
'LOCALE' => str_replace( '_', '-', Mage::app()->getLocale()->getLocaleCode() ),
'COUNTRY' => $country_code3,
Expand Down Expand Up @@ -100,39 +100,38 @@ public function returnAction()

$session = Mage::getSingleton( 'checkout/session' );

$status = $_POST['TRANSACTION_STATUS'];
$status = filter_var( $_POST['TRANSACTION_STATUS'], FILTER_SANITIZE_STRING );

/**
* @var $module PayGate_Pay_Model_Functions
*/
$module = Mage::getModel( 'pay/functions' );
$key = $module->getSecretKey();

$session = Mage::getSingleton( 'checkout/session' );
$reference = $session->getData( 'REFERENCE' );
$orderId = filter_var( $_GET['gid'], FILTER_SANITIZE_STRING );
$quoteId = filter_var( $_GET['qid'], FILTER_SANITIZE_STRING );

$queryFields = [
'PAYGATE_ID' => $module->getID(),
'PAY_REQUEST_ID' => $_POST['PAY_REQUEST_ID'],
'REFERENCE' => $reference,
'PAY_REQUEST_ID' => filter_var( $_POST['PAY_REQUEST_ID'], FILTER_SANITIZE_STRING ),
'REFERENCE' => $orderId,
];

$queryFields['CHECKSUM'] = md5( implode( '', $queryFields ) . $key );
$response = $this->curlPost( 'https://secure.paygate.co.za/payweb3/query.trans', $queryFields );
parse_str( $response, $queryFields );

if ( count( $queryFields ) > 0 ) {
$orderId = $queryFields['USER2'];
$orderId = filter_var( $queryFields['USER2'], FILTER_SANITIZE_STRING );
switch ( $status ) {
case 1:
$this->successful( $orderId );
$this->successful( $orderId, $quoteId );
break;
case 2:
$this->failed( $orderId );
$this->failed( $orderId, $quoteId );
break;
case 0:
case 4:
$this->canceled( $orderId );
$this->canceled( $orderId, $quoteId );
break;
default:
header( 'Location:' . Mage::getUrl() );
Expand Down Expand Up @@ -160,7 +159,7 @@ public function returnAction()
}
}

public function canceled( $orderId )
public function canceled( $orderId, $quoteId = false )
{
/**
* @var $order Mage_Sales_Model_Order
Expand All @@ -178,7 +177,7 @@ public function canceled( $orderId )
*/
$session = Mage::getSingleton( 'checkout/session' );

if ( $quoteId = $session->getQuoteId() ) {
if ( $quoteId ) {
/**
* @var $quote Mage_Sales_Model_Quote
*/
Expand All @@ -202,7 +201,7 @@ public function canceled( $orderId )
die;
}

public function successful( $orderId )
public function successful( $orderId, $quoteId = false )
{
/**
* @var $module PayGate_Pay_Model_Functions
Expand All @@ -214,7 +213,7 @@ public function successful( $orderId )
*/
$order = Mage::getModel( 'sales/order' )->loadByIncrementId( $orderId );

$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->save();
$order->setState( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT )->save();

$payment = $order->getPayment();
$payment->save();
Expand All @@ -226,23 +225,25 @@ public function successful( $orderId )
$invoice->register()->capture();

Mage::getModel( 'core/resource_transaction' )
->addObject( $invoice )
->addObject( $invoice->getOrder() )
->save();
->addObject( $invoice )
->addObject( $invoice->getOrder() )
->save();

if ( $module->getSendInvoiceEmail() ? true : false ) {
$message = Mage::helper( 'paygate' )->__( 'Notified customer about invoice #%s.', $invoice->getIncrementId() );
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment( $message )
->setIsCustomerNotified( true )
->save();
->setIsCustomerNotified( true )
->save();
} else {
$comment = $order->save();
}
$this->clearCart();

$checkoutSession = Mage::getSingleton( 'checkout/type_onepage' )->getCheckout();
$lastqid = $checkoutSession->getLastQuoteId();
$checkoutSession->setLastSuccessQuoteId( $lastqid );
$checkoutSession->setLastSuccessQuoteId( $quoteId );
$checkoutSession->setLastQuoteId( $quoteId );
$checkoutSession->setLastOrderId( $orderId );
$checkoutSession->setLastRealOrderId( $orderId );

$url = Mage::getUrl( 'checkout/onepage/success' );

Expand All @@ -264,7 +265,7 @@ public function clearCart()
}
}

public function failed( $orderId )
public function failed( $orderId, $quoteId = false )
{
/**
* @var $order Mage_Sales_Model_Order
Expand All @@ -281,7 +282,7 @@ public function failed( $orderId )
*/
$session = Mage::getSingleton( 'checkout/session' );

if ( $quoteId = $session->getQuoteId() ) {
if ( $quoteId ) {
/**
* @var $quote Mage_Sales_Model_Quote
*/
Expand Down
4 changes: 2 additions & 2 deletions Redirect/app/code/local/PayGate/Pay/etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand All @@ -11,7 +11,7 @@
<config>
<modules>
<PayGate_Pay>
<version>1.0.6</version>
<version>1.0.7</version>
</PayGate_Pay>
</modules>
<global>
Expand Down
2 changes: 1 addition & 1 deletion Redirect/app/code/local/PayGate/Pay/etc/system.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
4 changes: 2 additions & 2 deletions Redirect/app/etc/modules/PayGate_Pay.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand All @@ -16,7 +16,7 @@
<depends>
<Mage_Payment />
</depends>
<version>1.0.6</version>
<version>1.0.7</version>
</PayGate_Pay>
</modules>
</config>
1 change: 1 addition & 0 deletions Redirect/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Date : Version: Description
2019-10-18: v1.0.5 : Fix duplicate order and invoice creation
Magento 1.9.4.x compatibility
2019-10-25: v1.0.6 : Alternate invoicing approach.
2020-09-17: v1.0.7 : Fix sessions cleared in some browsers.
2 changes: 1 addition & 1 deletion iFrame/app/code/local/PayGate/Pay/Model/Functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2019 PayGate (Pty) Ltd
* Copyright (c) 2020 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
Loading

0 comments on commit 32cf3f3

Please sign in to comment.