Skip to content

Commit

Permalink
Merge pull request #20 from thejoshualewis/master
Browse files Browse the repository at this point in the history
IPN verification
  • Loading branch information
thejoshualewis committed Jun 25, 2019
2 parents 6cd3543 + e974e4a commit 6240d84
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
66 changes: 37 additions & 29 deletions code/Bitpay/BPCheckout/Model/IpnManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,54 +103,62 @@ public function postIpn()
switch ($event['name']) {

case 'invoice_completed':
if ($invoice_status == 'complete'):

$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> status has changed to Completed.');
$order->setState(Order::STATE_PROCESSING)->setStatus(Order::STATE_PROCESSING);
$order->save();
$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> status has changed to Completed.');
$order->setState(Order::STATE_PROCESSING)->setStatus(Order::STATE_PROCESSING);
$order->save();

$this->createMGInvoice($order);
$this->createMGInvoice($order);

return true;
return true;
endif;
break;

case 'invoice_confirmed':
#pending or processing from plugin settings

$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> processing has been completed.');
if ($bitpay_ipn_mapping != 'processing'):
#$order->setState(Order::STATE_NEW)->setStatus(Order::STATE_NEW);
$order->setState('new', true);
$order->setStatus('pending', true);
else:
$order->setState(Order::STATE_PROCESSING)->setStatus(Order::STATE_PROCESSING);
$this->createMGInvoice($order);
if ($invoice_status == 'confirmed'):
$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> processing has been completed.');
if ($bitpay_ipn_mapping != 'processing'):
#$order->setState(Order::STATE_NEW)->setStatus(Order::STATE_NEW);
$order->setState('new', true);
$order->setStatus('pending', true);
else:
$order->setState(Order::STATE_PROCESSING)->setStatus(Order::STATE_PROCESSING);
$this->createMGInvoice($order);
endif;

$order->save();
return true;
endif;

$order->save();
return true;
break;

case 'invoice_paidInFull':
#STATE_PENDING
$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> is processing.');
$order->setState('new', true);
$order->setStatus('pending', true);
$order->save();
return true;
if ($invoice_status == 'paid'):

$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> is processing.');
$order->setState('new', true);
$order->setStatus('pending', true);
$order->save();
return true;
endif;
break;

case 'invoice_failedToConfirm':

$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> has become invalid because of network congestion. Order will automatically update when the status changes.');
$order->save();
return true;
if ($invoice_status == 'invalid'):
$order->addStatusHistoryComment('BitPay Invoice <a href = "http://' . $item->endpoint . '/dashboard/payments/' . $order_invoice . '" target = "_blank">' . $order_invoice . '</a> has become invalid because of network congestion. Order will automatically update when the status changes.');
$order->save();
return true;
endif;
break;

case 'invoice_expired':
$order->delete();
if ($invoice_status == 'expired'):
$order->delete();

return true;
return true;
endif;
break;

case 'invoice_refundComplete':
Expand Down Expand Up @@ -181,6 +189,6 @@ public function createMGInvoice($order)
}
public function getExtensionVersion()
{
return 'Bitpay_BPCheckout_Magento2_3.0.7.0';
return 'Bitpay_BPCheckout_Magento2_3.0.8.0';
}
}
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/Observer/BPRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
} //end execute function
public function getExtensionVersion()
{
return 'Bitpay_BPCheckout_Magento2_3.0.7.0';
return 'Bitpay_BPCheckout_Magento2_3.0.8.0';

}

Expand Down
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "",
"type": "magento2-module",
"license": "mit",
"version":"3.0.7",
"version":"3.0.8",
"authors": [
{
"email": "integrations@bitpay.com",
Expand Down
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Bitpay_BPCheckout" setup_version="3.0.7.0"></module>
<module name="Bitpay_BPCheckout" setup_version="3.0.8.0"></module>
</config>

0 comments on commit 6240d84

Please sign in to comment.