Skip to content
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
65 changes: 65 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
composer.lock
composer.phar
phpunit.xml
/.phpunit.result.cache
/build
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Windcave REST API (Hosted Payment Page) driver for the Omnipay PHP payment processing library**

[![Build Status](https://travis-ci.org/PatronBase/omnipay-windcave-hpp.png?branch=main)](https://app.travis-ci.com/github/PatronBase/omnipay-windcave-hpp)
![Build Status](https://github.com/PatronBase/omnipay-windcave-hpp/actions/workflows/main.yml/badge.svg?branch=main)
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/PatronBase/omnipay-windcave-hpp.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-windcave-hpp/code-structure)
[![Code Quality](https://img.shields.io/scrutinizer/g/PatronBase/omnipay-windcave-hpp.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-windcave-hpp/?branch=main)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
Expand All @@ -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

Expand Down
34 changes: 26 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"merchant",
"omnipay",
"pay",
"payment"
"payment",
"hosted",
"checkout",
"redirect"
],
"homepage": "https://github.com/PatronBase/omnipay-windcave-hpp",
"license": "MIT",
Expand All @@ -22,6 +25,10 @@
{
"name": "Aimal Muhammad",
"email": "[email protected]"
},
{
"name": "Leith Caldwell",
"email": "[email protected]"
}
],
"autoload": {
Expand All @@ -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
}
"prefer-stable": true,
"config": {
"allow-plugins": {
"php-http/discovery": false
}
}
}
30 changes: 30 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticProperties="false"
colors="true"
processIsolation="false"
stopOnFailure="false">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
32 changes: 32 additions & 0 deletions phpunit9.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
23 changes: 0 additions & 23 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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(
Expand Down
22 changes: 19 additions & 3 deletions src/Message/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -207,4 +223,4 @@ protected function getEndpoint($path = '')
$base = $this->getTestMode() ? self::ENDPOINT_TEST : self::ENDPOINT_LIVE;
return $base . '/' . $path;
}
}
}
8 changes: 4 additions & 4 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getData()
$data['currency'] = $this->getCurrency();
$data['callbackUrls'] = [];

if ( $this->getStoreCard() ) {
if ( (bool) $this->getCreateToken() ) {
$data['storeCard'] = true;
}

Expand All @@ -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()) ) {
Expand Down Expand Up @@ -100,4 +100,4 @@ public function sendData($data)

return $this->response = new PurchaseResponse($this, $responseData ?? []);
}
}
}
30 changes: 30 additions & 0 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Omnipay\WindcaveHpp;

use Omnipay\Tests\GatewayTestCase;

class GatewayTest extends GatewayTestCase
{
/** @var array */
protected $options;

public function setUp(): void
{
parent::setUp();

$this->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,
];
}
}