コード例 #1
0
 /**
  * Tests Services_Paymill_Refunds->getOne()
  */
 public function testGetUnknownOne()
 {
     try {
         $refund = $this->_refunds->getOne('refund_b12c9470e4603paymill');
     } catch (Exception $e) {
         $this->assertInstanceOf('Services_Paymill_Exception', $e);
         $this->assertEquals(404, $e->getCode());
     }
 }
コード例 #2
0
 /**
  * Returns the store of the transaction overview
  */
 public function loadStoreAction()
 {
     $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
     $apiKey = trim($swConfig->get("privateKey"));
     $apiEndpoint = "https://api.paymill.com/v2/";
     $orderId = $this->Request()->getParam("orderId");
     $modelHelper = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper();
     $orderNumber = $modelHelper->getOrderNumberById($orderId);
     $success = true;
     $result = array();
     $preAuthId = $modelHelper->getPaymillPreAuthorization($orderNumber);
     $transactionId = $modelHelper->getPaymillTransactionId($orderNumber);
     $refundId = $modelHelper->getPaymillRefund($orderNumber);
     $cancelled = $modelHelper->getPaymillCancelled($orderNumber);
     if ($preAuthId !== "" && $preAuthId !== null) {
         //List PreAuth
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Preauthorizations.php';
         $preAuthObj = new Services_Paymill_Preauthorizations($apiKey, $apiEndpoint);
         $response = $preAuthObj->getOne($preAuthId);
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['created_at']), 'description' => 'PreAuthorization ' . $response['id'], 'amount' => $response['amount'] / 100 . ' ' . $response['currency']);
     }
     if ($transactionId !== "" && $transactionId !== null) {
         //List Transaction
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Transactions.php';
         $transactionObj = new Services_Paymill_Transactions($apiKey, $apiEndpoint);
         $response = $transactionObj->getOne($transactionId);
         $currency = $response['currency'];
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['created_at']), 'description' => 'Transaction ' . $response['id'], 'amount' => $response['origin_amount'] / 100 . ' ' . $currency);
     }
     if ($refundId !== "" && $refundId !== null) {
         //List Refund
         require_once dirname(dirname(dirname(__FILE__))) . '/lib/Services/Paymill/Refunds.php';
         $refundObj = new Services_Paymill_Refunds($apiKey, $apiEndpoint);
         $response = $refundObj->getOne($refundId);
         $result[] = array('entryDate' => date('d.M.Y H:i:s', $response['updated_at']), 'description' => 'Refund ' . $response['id'], 'amount' => $response['amount'] / 100 . ' ' . $currency);
     }
     $this->View()->assign(array('success' => $success, 'data' => $result, 'debug' => var_export($refundId, true)));
 }
コード例 #3
0
 /**
  * Eventhandler for refund actions
  */
 public function refundAction()
 {
     $type = $this->_request['type'];
     $refundId = $this->_request['event_resource']['id'];
     $this->requireRefunds();
     $refunds = new Services_Paymill_Refunds($this->_privateKey, $this->_apiUrl);
     $refund = $refunds->getOne($refundId);
     if ($this->getWebhookState($type) && isset($refund['id'])) {
         $this->_request['action'] = 'Refund';
         $this->updateOrderStatus();
     } else {
         $this->successAction();
     }
 }