Skip to content

[Feature/dev 1557] Add capture #69

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -16,7 +16,7 @@
"pxpay",
"pxpost"
],
"homepage": "https://github.com/thephpleague/omnipay-paymentexpress",
"homepage": "https://github.com/onceit/omnipay-paymentexpress",
"license": "MIT",
"authors": [
{
Expand Down
57 changes: 57 additions & 0 deletions src/Message/PxPayCaptureRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Omnipay\PaymentExpress\Message;

/**
* PaymentExpress PxPay Capture Request
*/
class PxPayCaptureRequest extends PxPayAuthorizeRequest
{
public function getAction()
{
return $this->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;
}
}
10 changes: 9 additions & 1 deletion src/Message/PxPostAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion src/PxPayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}