diff --git a/composer.json b/composer.json index 7342d56..1776e0a 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "omnipay/paymentexpress", + "name": "onceit/omnipay-paymentexpress", "type": "library", "description": "Payment Express (DPS) driver for the Omnipay payment processing library", "keywords": [ @@ -16,7 +16,7 @@ "pxpay", "pxpost" ], - "homepage": "https://github.com/thephpleague/omnipay-paymentexpress", + "homepage": "https://github.com/onceit/omnipay-paymentexpress", "license": "MIT", "authors": [ { diff --git a/src/Message/PxPayCaptureRequest.php b/src/Message/PxPayCaptureRequest.php new file mode 100644 index 0000000..7b79b1f --- /dev/null +++ b/src/Message/PxPayCaptureRequest.php @@ -0,0 +1,57 @@ +getParameter('action'); + } + + public function setAction($value) + { + return $this->setParameter('action', $value); + } + + public function getBillingId() + { + return $this->getParameter('billingId'); + } + + public function setBillingId($value) + { + return $this->setParameter('billingId', $value); + } + + public function getRecurringMode() + { + return $this->getParameter('recurringMode'); + } + + public function setRecurringMode($value) + { + return $this->setParameter('recurringMode', $value); + } + + public function getData() + { + $this->setAmount($this->getAmount() ? $this->getAmount() : '1.00'); + + + if ($this->getAction()) { + $this->action = $this->getAction(); + } + + $data = parent::getData(); + + $data->RecurringMode = $this->getRecurringMode(); + + $data->BillingId = $this->getBillingId(); + + return $data; + } +} diff --git a/src/Message/PxPostAuthorizeRequest.php b/src/Message/PxPostAuthorizeRequest.php index 115cc50..6f469b0 100644 --- a/src/Message/PxPostAuthorizeRequest.php +++ b/src/Message/PxPostAuthorizeRequest.php @@ -152,7 +152,15 @@ public function getData() } if ($this->getCardReference()) { - $data->DpsBillingId = $this->getCardReference(); + // Card references have previously been generated by Onceit, since we are now going to rely on + // paymentexpress to generate this which comes back as DpsBillingId, so if we are using a 16 digit + // integer we know it's a DpsBillingId, otherwise, it is a legacy BillingId. + $key = 'BillingId'; + if (preg_match('/^\d{16}$/', $this->getCardReference())) { + $key = 'DpsBillingId'; + } + + $data->$key = $this->getCardReference(); } elseif ($this->getCard()) { $this->getCard()->validate(); $data->CardNumber = $this->getCard()->getNumber(); diff --git a/src/PxPayGateway.php b/src/PxPayGateway.php index eb03986..6929805 100644 --- a/src/PxPayGateway.php +++ b/src/PxPayGateway.php @@ -6,6 +6,7 @@ use Omnipay\PaymentExpress\Message\PxPayAuthorizeRequest; use Omnipay\PaymentExpress\Message\PxPayCompleteAuthorizeRequest; use Omnipay\PaymentExpress\Message\PxPayPurchaseRequest; +use Omnipay\PaymentExpress\Message\PxPayCaptureRequest; use Omnipay\Omnipay; /** @@ -83,7 +84,7 @@ public function completeAuthorize(array $parameters = array()) public function purchase(array $parameters = array()) { if (!empty($parameters['cardReference']) && $this->getPxPostPassword() && $this->getPxPostUsername()) { - $gateway = Omnipay::create('PaymentExpress_PxPost'); + $gateway = Omnipay::create('PaymentExpress_PxPost', $this->httpClient, $this->httpRequest); $gateway->setPassword($this->getPxPostPassword()); $gateway->setUserName($this->getPxPostUsername()); return $gateway->purchase($parameters); @@ -105,4 +106,14 @@ public function completeCreateCard(array $parameters = array()) { return $this->completeAuthorize($parameters); } + + public function capture(array $parameters = array()) + { + return $this->createRequest('\Omnipay\PaymentExpress\Message\PxPayCaptureRequest', $parameters); + } + + public function completeCapture(array $parameters = array()) + { + return $this->completeAuthorize($parameters); + } }