diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..2cc7ec0
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,65 @@
+name: "Build tests"
+
+on:
+ pull_request:
+ push:
+ branches:
+ - "main"
+
+jobs:
+ phpunit:
+ name: "PHPUnit tests"
+
+ runs-on: "ubuntu-latest"
+
+ strategy:
+ matrix:
+ dependencies:
+ - "highest"
+ php-version:
+ - "7.2"
+ - "7.3"
+ - "7.4"
+ - "8.0"
+ - "8.1"
+ - "8.2"
+ - "8.3"
+ - "8.4"
+
+ include:
+ - php-version: '7.2'
+ dependencies: "lowest"
+
+ steps:
+ - name: "Checkout"
+ uses: "actions/checkout@v4"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ coverage: "pcov"
+ php-version: "${{ matrix.php-version }}"
+ ini-values: memory_limit=-1
+ tools: composer:v2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ # Fixes any pubkeys failure (add a `composer diagnose` step to debug if necessary)
+ - name: "Composer force self-update"
+ run: "composer self-update"
+
+ - name: "Install lowest dependencies"
+ if: ${{ matrix.dependencies == 'lowest' }}
+ run: "composer update --prefer-lowest --no-interaction --no-progress"
+
+ - name: "Install highest dependencies"
+ if: ${{ matrix.dependencies == 'highest' }}
+ run: "composer update --no-interaction --no-progress"
+
+ - name: "Tests (PHPUnit 9)"
+ if: ${{ matrix.php-version <= '8.0' }}
+ run: "vendor/bin/phpunit --configuration phpunit9.xml.dist"
+
+ - name: "Tests (PHPUnit 10+)"
+ if: ${{ matrix.php-version >= '8.1' }}
+ run: "vendor/bin/phpunit"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..472a3b6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/vendor
+composer.lock
+composer.phar
+phpunit.xml
+/.phpunit.result.cache
+/build
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..ea026a7
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,10 @@
+# Contributing Guidelines
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a future version unintentionally.
+* Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files.
+* Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
+ style and that all tests pass.
+* Send the pull request.
+* Check that the CI build passed. If not, rinse and repeat.
diff --git a/README.md b/README.md
index d9f8ca5..f20a498 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
**Windcave REST API (Hosted Payment Page) driver for the Omnipay PHP payment processing library**
-[](https://app.travis-ci.com/github/PatronBase/omnipay-windcave-hpp)
+
[](https://scrutinizer-ci.com/g/PatronBase/omnipay-windcave-hpp/code-structure)
[](https://scrutinizer-ci.com/g/PatronBase/omnipay-windcave-hpp/?branch=main)
[](LICENSE.md)
@@ -11,8 +11,8 @@
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
-processing library for PHP 5.6+. This package implements GoCardless support for Omnipay. It includes
-support for the redirect (3-party) version of the gateway (Redirect Flow).
+processing library for PHP 7.2+. This package implements Windcave REST API support for Omnipay. It
+includes support for the redirect (3-party) version of the gateway (Hosted Payment Page).
## Installation
diff --git a/composer.json b/composer.json
index 91cb1de..3f81ced 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,10 @@
"merchant",
"omnipay",
"pay",
- "payment"
+ "payment",
+ "hosted",
+ "checkout",
+ "redirect"
],
"homepage": "https://github.com/PatronBase/omnipay-windcave-hpp",
"license": "MIT",
@@ -22,6 +25,10 @@
{
"name": "Aimal Muhammad",
"email": "aimal.azmi.13@gmail.com"
+ },
+ {
+ "name": "Leith Caldwell",
+ "email": "leith@codedruids.com"
}
],
"autoload": {
@@ -35,17 +42,28 @@
}
},
"require": {
- "omnipay/common": "^3",
- "php": "^7||^8"
+ "omnipay/common": "^3.1",
+ "php": "^7.2||^8"
},
"require-dev": {
- "omnipay/tests": "^3",
- "squizlabs/php_codesniffer": "^3.5"
+ "omnipay/tests": "^4.2",
+ "squizlabs/php_codesniffer": "^3.5",
+ "http-interop/http-factory-guzzle": "^1.1"
+ },
+ "scripts": {
+ "test": "phpunit",
+ "check-style": "phpcs -p --standard=PSR2 src/",
+ "fix-style": "phpcbf -p --standard=PSR2 src/"
},
"extra": {
"branch-alias": {
- "dev-master": "1.0.x-dev"
+ "dev-master": "1.1.x-dev"
}
},
- "prefer-stable": true
-}
\ No newline at end of file
+ "prefer-stable": true,
+ "config": {
+ "allow-plugins": {
+ "php-http/discovery": false
+ }
+ }
+}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..21263b8
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+ src/
+
+
+
+
+ tests
+
+
+
+
+
+
diff --git a/phpunit9.xml.dist b/phpunit9.xml.dist
new file mode 100644
index 0000000..5ab568e
--- /dev/null
+++ b/phpunit9.xml.dist
@@ -0,0 +1,32 @@
+
+
+
+
+ src/
+
+
+
+
+
+
+
+
+
+ tests
+
+
+
+
+
+
diff --git a/src/Gateway.php b/src/Gateway.php
index 5ee72a7..01dc0b2 100755
--- a/src/Gateway.php
+++ b/src/Gateway.php
@@ -68,14 +68,6 @@ public function purchase(array $parameters = [])
);
}
- public function createCard(array $parameters = [])
- {
- return $this->createRequest(
- PurchaseRequest::class,
- $parameters + ['store_card' => true]
- );
- }
-
/**
* Complete a purchase process
*
@@ -91,21 +83,6 @@ public function completePurchase(array $parameters = [])
);
}
- /**
- * Complete a purchase process and save card
- *
- * @param array $parameters
- *
- * @return Omnipay\WindcaveHpp\Message\CompletePurchaseRequest
- */
- public function completeCreateCard(array $parameters = [])
- {
- return $this->createRequest(
- CompletePurchaseRequest::class,
- $parameters
- );
- }
-
public function acceptNotification(array $parameters = [])
{
return $this->createRequest(
diff --git a/src/Message/BaseRequest.php b/src/Message/BaseRequest.php
index a9ede5c..a70e051 100644
--- a/src/Message/BaseRequest.php
+++ b/src/Message/BaseRequest.php
@@ -36,6 +36,16 @@ protected function getAuthorization()
return base64_encode($this->getApiUsername() . ':' . $this->getApiKey());
}
+ public function setCreateToken($value)
+ {
+ return $this->setParameter('createToken', $value);
+ }
+
+ public function getCreateToken()
+ {
+ return $this->getParameter('createToken');
+ }
+
// Merchant Reference
public function setMerchantReference($value)
{
@@ -125,14 +135,20 @@ public function getDeclineUrl()
return $this->getParameter('declineUrl');
}
+ /**
+ * @deprecated Alias. Use standard `setCreateToken()` instead
+ */
public function setStoreCard($value)
{
- return $this->setParameter('storeCard', $value);
+ return $this->setCreateToken($value);
}
+ /**
+ * @deprecated Alias. Use standard `getCreateToken()` instead
+ */
public function getStoreCard()
{
- return $this->getParameter('storeCard');
+ return $this->getCreateToken();
}
public function setStoredCardIndicator($value)
@@ -207,4 +223,4 @@ protected function getEndpoint($path = '')
$base = $this->getTestMode() ? self::ENDPOINT_TEST : self::ENDPOINT_LIVE;
return $base . '/' . $path;
}
-}
\ No newline at end of file
+}
diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php
index 3f43bab..51ddfcf 100644
--- a/src/Message/PurchaseRequest.php
+++ b/src/Message/PurchaseRequest.php
@@ -25,7 +25,7 @@ public function getData()
$data['currency'] = $this->getCurrency();
$data['callbackUrls'] = [];
- if ( $this->getStoreCard() ) {
+ if ( (bool) $this->getCreateToken() ) {
$data['storeCard'] = true;
}
@@ -41,8 +41,8 @@ public function getData()
$data['recurringFrequency'] = $this->getRecurringFrequency();
}
- if ( $this->getToken() ) {
- $data['cardId'] = $this->getToken();
+ if ( $this->getToken() || $this->getCardReference() ) {
+ $data['cardId'] = $this->getToken() ?? $this->getCardReference();
}
if ( is_array($this->getPaymentMethods()) ) {
@@ -100,4 +100,4 @@ public function sendData($data)
return $this->response = new PurchaseResponse($this, $responseData ?? []);
}
-}
\ No newline at end of file
+}
diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php
new file mode 100644
index 0000000..3dc7d8f
--- /dev/null
+++ b/tests/GatewayTest.php
@@ -0,0 +1,30 @@
+gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
+
+ $this->options = [
+ 'amount' => '1.45',
+ 'apiUsername' => 'Test_Merchant',
+ 'apiKey' => 'ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890',
+ 'currency' => 'NZD',
+ 'cancelUrl' => 'https://www.example.com/cancel',
+ 'notifyUrl' => 'https://www.example.com/notify',
+ 'returnUrl' => 'https://www.example.com/return',
+ 'transactionId' => '123abc',
+ 'testMode' => true,
+ ];
+ }
+}