function paymentwallbrick_refund($params) { if (!class_exists("Paymentwall_Config")) { require_once dirname(__FILE__) . "/paymentwallbrick/lib/paymentwall.php"; } if ($params["test_mode"] == "on") { Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['test_public_key'], 'private_key' => $params['test_private_key'])); } else { Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['public_key'], 'private_key' => $params['private_key'])); } $charge = new Paymentwall_Charge($params['transid']); $charge->get(); if ($charge->amount != $params["amount"]) { return array('status' => 'error', 'rawdata' => "Only full refunds are supported"); } $charge->refund(); if ($charge->isRefunded()) { return array('status' => 'success', 'transid' => $charge->id); } else { $response = $charge->getPublicData(); $errors = json_decode($response, true); return array('status' => 'error', 'rawdata' => $errors['error']['message']); } }