Skip to content

Commit

Permalink
purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Oct 12, 2024
1 parent 10931c7 commit 4b4ecd0
Show file tree
Hide file tree
Showing 14 changed files with 643 additions and 147 deletions.
20 changes: 3 additions & 17 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Omnipay\Gomypay;

use Omnipay\Common\AbstractGateway;
use Omnipay\Gomypay\Message\AuthorizeRequest;
use Omnipay\Gomypay\Message\PurchaseRequest;

/**
* Gomypay Gateway
Expand All @@ -18,26 +18,12 @@ public function getName()
public function getDefaultParameters()
{
return [
'key' => '',
'testMode' => false,
];
}

public function getKey()
public function purchase(array $options = [])
{
return $this->getParameter('key');
}

public function setKey($value)
{
return $this->setParameter('key', $value);
}

/**
* @return Message\AuthorizeRequest
*/
public function authorize(array $options = [])
{
return $this->createRequest(AuthorizeRequest::class, $options);
return $this->createRequest(PurchaseRequest::class, $options);
}
}
37 changes: 4 additions & 33 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,17 @@
*/
abstract class AbstractRequest extends BaseAbstractRequest
{
protected $liveEndpoint = 'https://api.example.com';
protected $liveEndpoint = 'https://n.gomypay.asia/ShuntClass.aspx';

protected $testEndpoint = 'https://api-test.example.com';

public function getKey()
{
return $this->getParameter('key');
}

public function setKey($value)
{
return $this->setParameter('key', $value);
}
protected $testEndpoint = 'https://n.gomypay.asia/TestShuntClass.aspx';

public function sendData($data)
{
$url = $this->getEndpoint().'?'.http_build_query($data, '', '&');
$response = $this->httpClient->request('GET', $url);

$data = json_decode($response->getBody(), true);

return $this->createResponse($data);
}

protected function getBaseData()
{
return [
'transaction_id' => $this->getTransactionId(),
'expire_date' => $this->getCard()->getExpiryDate('mY'),
'start_date' => $this->getCard()->getStartDate('mY'),
];
return $this->response = new PurchaseResponse($this, $data);
}

protected function getEndpoint()
public function getEndpoint()
{
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
}

protected function createResponse($data)
{
return $this->response = new Response($this, $data);
}
}
7 changes: 7 additions & 0 deletions src/Message/AbstractResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Omnipay\Gomypay\Message;

use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse;

abstract class AbstractResponse extends BaseAbstractResponse {}
19 changes: 0 additions & 19 deletions src/Message/AuthorizeRequest.php

This file was deleted.

Loading

0 comments on commit 4b4ecd0

Please sign in to comment.