Beispiel #1
0
 /**
  * @Then /^charge should be refunded$/
  */
 public function chargeShouldBeRefunded()
 {
     $chargeToBeRefunded = new Paymentwall_Charge($this->chargeId);
     if (!$chargeToBeRefunded->refund()->isRefunded()) {
         throw new Exception($chargeToBeRefunded->getPublicData());
     }
 }
 public function sendData($data)
 {
     // Initialise the PaymentWall configuration
     $this->setPaymentWallObject();
     // Create the charge object
     $charge = new \Paymentwall_Charge($data['sale_id']);
     $charge->refund();
     // Get the response data -- this is returned as a JSON string.
     $charge_data = json_decode($charge->getRawResponseData(), true);
     // Construct the response object
     $this->response = new Response($this, $charge_data);
     return $this->response;
 }
Beispiel #3
0
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']);
    }
}