function validateNotification($notification) { $result = false; if (isNotificationFormatValid($notification) && $notification['event_type'] === 'refund.succeeded') { $transaction_object = new Services_Paymill_Transactions(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), 'https://api.paymill.com/v2/'); $id = $notification['event_resource']['transaction']['id']; $transaction_result = $transaction_object->getOne($id); $result = isset($transaction_result['id']) && $transaction_result['id'] === $id; } return $result; }
/** * Validates the requested refund * * @param array $notification * @return boolean */ private function isNotificationValid($notification) { if ($this->isStructureValid($notification) && $notification['event']['event_type'] == 'refund.succeeded') { $id = $notification['event']['event_resource']['transaction']['id']; $privateKey = trim($this->config->get('privateKey')); $transactionObject = new Services_Paymill_Transactions($privateKey, 'https://api.paymill.com/v2/'); $result = $transactionObject->getOne($id); $this->logging->log('validate transaction-id for refund', var_export($result['id'] === $id, true)); return $result['id'] === $id; } return false; }
private function _validateRequest($data) { $valid = false; if (!is_null($data) && isset($data->event) && isset($data->event->event_resource) && isset($data->event->event_resource->transaction)) { $transactionObject = new Services_Paymill_Transactions(trim($this->_getPaymentConfig('PRIVATE_API_KEY')), Util::$apiUrl); $transaction = $transactionObject->getOne($data->event->event_resource->transaction->id); // Validate data if (isset($transaction['id']) && $transaction['id'] === $data->event->event_resource->transaction->id) { $valid = true; } } return $valid; }
private function validateRequest($data) { $valid = false; // check structure if (!is_null($data) && isset($data->event) && isset($data->event->event_resource) && isset($data->event->event_resource->transaction)) { $transactionObject = new Services_Paymill_Transactions(trim(oxRegistry::getConfig()->getShopConfVar('PAYMILL_PRIVATEKEY')), paymill_util::API_ENDPOINT); $transaction = $transactionObject->getOne($data->event->event_resource->transaction->id); // Validate data if (isset($transaction['id']) && $transaction['id'] === $data->event->event_resource->transaction->id) { $valid = true; } } $this->log("Webhook Validation", var_export($valid, true)); return $valid; }
private function _validateRequest($data) { $valid = false; if (!is_null($data) && isset($data['event']) && isset($data['event']['event_resource'])) { $transactionId = $data['event']['event_resource']['id']; if (substr($transactionId, 0, 4) !== 'tran') { $transactionId = $data['event']['event_resource']['transaction']['id']; } $transactionObject = new Services_Paymill_Transactions(trim(Mage::helper('paymill/optionHelper')->getPrivateKey()), Mage::helper('paymill')->getApiUrl()); $transaction = $transactionObject->getOne($transactionId); if (isset($transaction['id']) && $transaction['id'] === $transactionId) { $valid = true; } } return $valid; }
function validateNotification($notification) { if (isset($notification) && !empty($notification)) { // Check eventtype if (isset($notification['event']['event_type'])) { if ($notification['event']['event_type'] == 'refund.succeeded') { $id = null; if (isset($notification['event']['event_resource']['transaction']['id'])) { $id = $notification['event']['event_resource']['transaction']['id']; } $transactionObject = new Services_Paymill_Transactions(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), 'https://api.paymill.com/v2/'); $result = $transactionObject->getOne($id); return $result['id'] === $id; } } } return false; }
private function proceedRefund($transactionId) { $result = false; $this->init(); $this->load->model('sale/order'); $orderId = $this->getPost('orderId', 0); $transaction = $this->paymillTransaction->getOne($transactionId); $this->log('Transaction used for Refund', var_export($transaction, true)); if (is_array($transaction)) { try { $result = $this->paymillRefund->create(array('transactionId' => $transactionId, 'params' => array('amount' => $transaction['origin_amount']))); $this->log('Refund resulted in', var_export($result, true)); $this->log('Refund successfully', $transaction['id']); $orderStatusId = $this->db->query('SELECT `order_status_id` FROM `' . DB_PREFIX . 'order_status` WHERE `name`= "Refunded"')->row['order_status_id']; $this->model_sale_order->addOrderHistory($orderId, array('order_status_id' => $orderStatusId, 'notify' => true, 'comment' => '')); } catch (Exception $ex) { $result = false; } } return $result; }
private function validateNotification($notification) { if (isset($notification) && !empty($notification)) { // Check eventtype if (isset($notification['event']['event_type'])) { if ($notification['event']['event_type'] == 'refunded.succeeded') { $id = null; if (isset($notification['event']['event_resource']['transaction']['id'])) { $id = $notification['event']['event_resource']['transaction']['id']; } $privateKey = trim($this->config->get($this->getPaymentName() . '_privatekey')); $transactionObject = new Services_Paymill_Transactions($privateKey, 'https://api.paymill.com/v2/'); $result = $transactionObject->getOne($id); return $result['id'] === $id; } } } return false; }
/** * Eventhandler for chargeback actions */ public function chargebackAction() { $type = $this->_request['type']; $transactionId = $this->_request['event_resource']['id']; $this->requireTransactions(); $transactions = new Services_Paymill_Transactions($this->_privateKey, $this->_apiUrl); $transaction = $transactions->getOne($transactionId); if ($this->getWebhookState($type) && isset($transaction['id'])) { $this->_request['action'] = 'Chargeback'; $this->updateOrderStatus(); } else { $this->successAction(); } }
/** * Tests Services_Paymill_Transactions->getOne() * @depends testCreate */ public function testGetOne($transactionId) { $transaction = $this->_transaction->getOne($transactionId); $this->assertEquals($transactionId, $transaction['id']); }
/** * Updates the description of target transaction by adding the prefix 'OrderID: ' followed by the order id * @param String $id * @param String $orderId */ function updateTransaction($id, $orderId) { $this->log('Updating transaction description', ''); require_once DIR_FS_CATALOG . 'ext/modules/payment/paymill/lib/Services/Paymill/Transactions.php'; $transactions = new Services_Paymill_Transactions($this->privateKey, $this->apiUrl); $transaction = $transactions->getOne($id); $description = substr('OrderID: ' . $orderId . ' ' . $transaction['description'], 0, 128); $transactions->update(array('id' => $id, 'description' => $description)); }
/** * Action Listener to execute the capture for applicable transactions * */ public function refundAction() { $result = false; $code = null; require_once dirname(__FILE__) . '/../../lib/Services/Paymill/Transactions.php'; require_once dirname(__FILE__) . '/../../lib/Services/Paymill/Refunds.php'; $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config(); $refund = new Services_Paymill_Refunds(trim($swConfig->get("privateKey")), 'https://api.paymill.com/v2/'); $transactionObject = new Services_Paymill_Transactions(trim($swConfig->get("privateKey")), 'https://api.paymill.com/v2/'); $modelHelper = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper(); $orderNumber = $modelHelper->getOrderNumberById($this->Request()->getParam("orderId")); $transactionId = $modelHelper->getPaymillTransactionId($orderNumber); $transactionResult = $transactionObject->getOne($transactionId); //Create Transaction $parameter = array('transactionId' => $transactionId, 'params' => array('amount' => $transactionResult['amount'], 'description' => $transactionResult['client']['email'] . " " . Shopware()->Config()->get('shopname'))); $response = $refund->create($parameter); if (isset($response['response_code'])) { $code = $response['response_code']; } //Validate result and prepare feedback if ($this->_validateRefundResponse($response)) { $result = true; $modelHelper->setPaymillRefund($orderNumber, $response['id']); $this->_updatePaymentStatus(20, $this->Request()->getParam("orderId")); } $this->View()->assign(array('success' => $result, 'code' => $code)); }
/** * Updates the description of target transaction by adding the prefix 'OrderID: ' followed by the order id * @param String $id * @param String $orderId */ function updateTransaction($id, $orderId) { $transactions = new Services_Paymill_Transactions($this->privateKey, $this->apiUrl); $transaction = $transactions->getOne($id); $description = substr('OrderID: ' . $orderId . ' ' . $transaction['description'], 0, 128); $transactions->update(array('id' => $id, 'description' => $description)); }