Skip to content

Support Apple Pay #5

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 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a10d6fd
GP-860 - WIP Apple Pay support
NoelLH Nov 26, 2017
024a507
Copy .gitignore and Travis config from CR Hosted adapter. Update Comp…
NoelLH Nov 26, 2017
2c6a74e
GP-860 - remove composer.lock for consistency with other adapters
Nov 28, 2017
39f1cf8
GP-860 - ignore future `composer.lock`s for consistency with other ad…
Nov 28, 2017
5581fe7
GP-860 - explicitly test `ApplePayCreditCard::getBrand()`
Nov 28, 2017
14d1a58
Update PHP minimum version
Nov 28, 2017
4d2da2a
GP-860 - change name to `comicrelief` for Packagist for dev branch
Nov 28, 2017
76b19c2
GP-860 - Create Apple Pay payload in correct format. Unit test Apple …
Nov 28, 2017
fd72689
Code style updates
Nov 28, 2017
59bbf86
GP-860 - Define `composer test` for Travis, including PSR2 style chec…
Nov 28, 2017
48f56d9
GP-860 - separately unit test getters from loaded Apple Pay mock succ…
Nov 28, 2017
6fa7b81
Merge pull request #1 from comicrelief/GP-860-apple-pay
NoelLH Nov 28, 2017
caa6f21
Return Composer name & home to `teaandcode` org, to enable merging to…
Nov 28, 2017
ee6e58d
GP-860 - Port features from `comicrelief/omnipay-worldpay-cg-hosted`:
Nov 29, 2017
4ed3a94
GP-860 - use constants for statuses
Nov 29, 2017
33b6dea
GP-860 - fix element order and don't add `cardAddress` for Apple Pay
Nov 29, 2017
ff47537
Merge pull request #2 from comicrelief/GP-860-support-username
NoelLH Nov 29, 2017
5c39a61
Merge branch 'master' into apple-pay-for-upstream
Nov 29, 2017
97758c6
Make applicationData optional to reflect Apple and Worldpay properties
Dec 1, 2017
9717a74
Merge pull request #3 from comicrelief/optional-apple-application-data
NoelLH Dec 1, 2017
27d0181
GP-860 - fix Apple Pay processing breaking due to blank attributes on…
Dec 4, 2017
b09b211
Merge pull request #4 from comicrelief/GP-860-fix-apple-pay-session-e…
ayanozturk Dec 4, 2017
b99c473
Merge remote-tracking branch 'origin/master' into apple-pay-for-upstream
Dec 4, 2017
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vendor/
.idea/

# Ignore version lock file as lib's not standalone
composer.lock
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'

install:
- composer install

script:
- composer test

git:
depth: 3

cache:
directories:
- $HOME/.composer/cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**WorldPay XML Direct driver for the Omnipay PHP payment processing library**

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic,
multi-gateway payment processing library for PHP 5.3+. This package implements
multi-gateway payment processing library for PHP 5.6+. This package implements
WorldPay XML Direct support for Omnipay.

## Installation
Expand Down
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,39 @@
{
"name": "Dave Nash",
"email": "[email protected]"
},
{
"name": "Noel Light-Hilary",
"email": "[email protected]"
}
],
"autoload": {
"psr-0": { "Omnipay\\WorldPayXML\\" : "src/" }
},
"require": {
"php": "^5.6|^7",
"guzzle/plugin-cookie": "~3.7",
"omnipay/common": "~2.3"
},
"require-dev": {
"omnipay/tests": "~2.0"
},
"scripts": {
"test": [
"phpunit",
"@lint"
],
"lint": [
"phpcs --standard=PSR2 --encoding=utf-8 src tests"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
}
}
20 changes: 20 additions & 0 deletions src/Omnipay/WorldPayXML/ApplePayCreditCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Omnipay\WorldPayXML;

use Omnipay\Common\CreditCard;

/**
* Class ApplePayCreditCard
* @package Omnipay\WorldPayXML
*
* Pseudo credit card for Apple Pay - allows us to get an appropriate 'brand' without checking the card
* number pattern, since we don't have a card number.
*/
class ApplePayCreditCard extends CreditCard
{
public function getBrand()
{
return 'apple';
}
}
30 changes: 26 additions & 4 deletions src/Omnipay/WorldPayXML/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public function getName()
*/
public function getDefaultParameters()
{
return array(
return [
'installation' => '',
'merchant' => '',
'password' => '',
'testMode' => false,
);
];
}

/**
Expand Down Expand Up @@ -134,6 +134,28 @@ public function setPaResponse($value)
return $this->setParameter('pa_response', $value);
}


/**
* Get the separate username if configured (more secure approach for basic auth) or fallback to merchant if not
*
* @return string
*/
public function getUsername()
{
return $this->parameters->get('username', $this->getParameter('merchant'));
}

/**
* Set basic auth username
*
* @param string $value
* @return Gateway
*/
public function setUsername($value)
{
return $this->setParameter('username', $value);
}

/**
* Get password
*
Expand Down Expand Up @@ -286,10 +308,10 @@ public function setUserIP($value)
* @access public
* @return \Omnipay\WorldPayXML\Message\PurchaseRequest
*/
public function purchase(array $parameters = array())
public function purchase(array $parameters = [])
{
return $this->createRequest(
'\Omnipay\WorldPayXML\Message\PurchaseRequest',
\Omnipay\WorldPayXML\Message\PurchaseRequest::class,
$parameters
);
}
Expand Down
Loading