Exemple #1
0
 public function execute()
 {
     $skipFraudDetection = false;
     \Paynl\Config::setApiToken($this->_config->getApiToken());
     $transaction = \Paynl\Transaction::getForExchange();
     if ($transaction->isPending()) {
         die("TRUE| Ignoring pending");
     }
     $orderId = $transaction->getDescription();
     $order = $this->_orderFactory->create()->loadByIncrementId($orderId);
     if (empty($order)) {
         die('FALSE| Cannot load order');
     }
     if ($order->getTotalDue() <= 0) {
         die('TRUE| Total due <= 0, so iam not touching the status if the order');
     }
     if ($transaction->isPaid()) {
         if ($order->getOrderCurrencyCode() != 'EUR') {
             $skipFraudDetection = true;
         }
         $payment = $order->getPayment();
         $payment->setTransactionId($transaction->getId());
         $payment->setCurrencyCode($transaction->getPaidCurrency());
         $payment->setIsTransactionClosed(0);
         $payment->registerCaptureNotification($transaction->getPaidAmount(), $skipFraudDetection);
         $order->save();
         // notify customer
         $invoice = $payment->getCreatedInvoice();
         if ($invoice && !$order->getEmailSent()) {
             $this->_orderSender->send($order);
             $order->addStatusHistoryComment(__('You notified customer about invoice #%1.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save();
         }
         die("TRUE| PAID");
     } elseif ($transaction->isCanceled()) {
         $order->cancel()->save();
         die("TRUE| CANCELED");
     }
 }
Exemple #2
0
<?php

/* 
 * Copyright (C) 2015 Andy Pieters <*****@*****.**>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once '../vendor/autoload.php';
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');
$transaction = \Paynl\Transaction::getForExchange();
if ($transaction->isPaid()) {
    // process the payment
} elseif ($transaction->isCanceled()) {
    // payment canceled, restock items
}
// always start your response with TRUE|
echo "TRUE| ";
// Optionally you can send a message after TRUE|, you can view this messages in the logs. https://admin.pay.nl/logs/payment_state
echo $transaction->isPaid() ? 'Paid' : 'Not paid';