<?php

namespace Omnipay\Migs\Message;

/**
 * Migs Purchase Request
 */
class ThreePartyPurchaseRequest extends AbstractRequest {

    protected $action = 'pay';

    public function getData() {
        $this->validate('amount', 'returnUrl', 'transactionId');

        $data = $this->getBaseData();
        $data['vpc_SecureHash'] = $this->calculateHash($data);

        return $data;
    }

    public function sendData($data) {
        $redirectUrl = $this->getEndpoint() . '?' . http_build_query($data);

        return $this->response = new ThreePartyPurchaseResponse($this, $data, $redirectUrl);
    }

    public function getEndpoint() {
        return $this->endpoint . 'vpcpay';
    }

}
