Skip to content

added migs refund support #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Message/ThreePartyRefundRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Omnipay\Migs\Message;

use Omnipay\Common\Exception\InvalidRequestException;

/**
* Migs Complete Purchase Request
*/
class ThreePartyRefundRequest extends AbstractRequest
{
protected $action = 'refund';
public function getData()
{
$this->validate('amount', 'returnUrl', 'transactionId');
$data = $this->getBaseData();
$data['vpc_SecureHash'] = $this->calculateHash($data);
$data['vpc_TransNo'] = $this->getParameter('transactionNo');
$data['vpc_User'] = $this->getUser();
$data['vpc_Password'] = $this->getPassword();
return $data;
}

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send();

return $this->response = new Response($this, $httpResponse->getBody());
}

public function getEndpoint()
{
return $this->endpoint.'vpcdps';
}
}
5 changes: 5 additions & 0 deletions src/ThreePartyGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public function completePurchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\Migs\Message\ThreePartyCompletePurchaseRequest', $parameters);
}

public function refund(array $parameters = array())
{
return $this->createRequest('\Omnipay\Migs\Message\ThreePartyRefundRequest', $parameters);
}
}
Empty file.
10 changes: 10 additions & 0 deletions tests/ThreePartyGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ public function testCompletePurchase()

$this->assertSame('10.00', $request->getAmount());
}

public function testRefund()
{
$request = $this->gateway->refund(array('amount' => '10.00', 'transactionNo' => '1112'));

$this->assertInstanceOf('\Omnipay\Migs\Message\ThreePartyRefundRequest', $request);

$this->assertSame('10.00', $request->getAmount());
}

}