Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
P
php-stpp
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
common
php-stpp
Commits
3df22172
Commit
3df22172
authored
Nov 28, 2013
by
David Weston
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tested as working (of sorts)
parent
72b4b00a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
150 additions
and
12 deletions
+150
-12
README.md
README.md
+74
-2
objects/stppaddressableobject.php
objects/stppaddressableobject.php
+10
-0
objects/stppmerchant.php
objects/stppmerchant.php
+1
-1
objects/stppobject.php
objects/stppobject.php
+3
-0
objects/stppoperation.php
objects/stppoperation.php
+11
-0
objects/stppresponse.php
objects/stppresponse.php
+13
-1
stapi.php
stapi.php
+38
-8
No files found.
README.md
View file @
3df22172
php-stpp
php-stpp
--------
--------
Currently in development. Not properly tested at the moment, so do not expect it to work right now.
This masterpiece is currently in development, however, it's doing things
properly as it should - including 3D Secure support, however awkward that
may be.
Licenced under MIT, I'll put in the
*actual*
licence file in here some time.
I've tried to make this as versatile as possible, matching various different
\ No newline at end of file
coding patterns, as well, as a developer I know annoying it can be to adjust to
someone else's patterns when you think your own is superior.
Note: Amounts do not match the scheme applied to Secure Trading's API, as I
think placing orders in pence for things that are usually in pounds is somewhat
counter intuitive. (GBP; stirling pounds as opposed to pence)
Note: There's no validation as of yet. I intend to add validation in whenever
I get the chance.
Example
-------
<?php
$stapi = new STAPI("127.0.0.1", 5000);
$stapi->setAlias("test_typefish0000");
$stapi->setOperationSiteReference("test_typefish0000")
->setOperationAccountTypeDescription("ECOM");
$billing = $this->stapi->getBilling();
$billing->setAmount(12.50)
->setCurrency("GBP")
->setPaymentType("VISA")
->setPaymentCardNumber("4111111111111111")
->setPaymentExpiryDate(
[
10, 2016
]
)
->setPaymentSecurityCode(123);
# set billing information
$billing->setNamePrefix("Mr")
->setFirstName("David")
->setLastName("Weston")
->setPremise("No 789")
->setStreet("Test Street")
->setTown("Corby")
->setCounty("Northamptonshire")
->setPostcode("TE45 6ST")
->setCountry("GB");
$response = $stapi->call("auth");
if($response->isSuccessful())
echo "Success!";
else
echo "Failure - ".$response->getErrorMessage();
Licence
-------
Copyright (C) 2013, David Weston
<php-stpp@typefish.co.uk>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
objects/stppaddressableobject.php
View file @
3df22172
...
@@ -79,6 +79,16 @@ abstract class STPPAddressable extends STPPObject
...
@@ -79,6 +79,16 @@ abstract class STPPAddressable extends STPPObject
}
}
/**
* Set the country of this addressable object.
*/
public
function
setCountry
(
$country
)
{
$this
->
options
[
"country"
]
=
$country
;
return
$this
;
}
/**
/**
* Set the first name of the person referenced in this addressable object.
* Set the first name of the person referenced in this addressable object.
*/
*/
...
...
objects/stppmerchant.php
View file @
3df22172
...
@@ -50,7 +50,7 @@ class STPPMerchant extends STPPObject
...
@@ -50,7 +50,7 @@ class STPPMerchant extends STPPObject
/**
/**
* Set the terminating URL - for use in 3DSecure transactions.
* Set the terminating URL - for use in 3DSecure transactions.
*/
*/
public
function
set
3DSecure
TermUrl
(
$url
)
public
function
setTermUrl
(
$url
)
{
{
$this
->
options
[
"termurl"
]
=
$url
;
$this
->
options
[
"termurl"
]
=
$url
;
return
$this
;
return
$this
;
...
...
objects/stppobject.php
View file @
3df22172
...
@@ -31,6 +31,9 @@ abstract class STPPObject
...
@@ -31,6 +31,9 @@ abstract class STPPObject
foreach
(
$this
->
options
as
$option
=>
$value
)
foreach
(
$this
->
options
as
$option
=>
$value
)
{
{
if
(
$value
===
null
)
continue
;
$method
=
"compile"
.
$option
;
$method
=
"compile"
.
$option
;
if
(
method_exists
(
$this
,
$method
))
if
(
method_exists
(
$this
,
$method
))
...
...
objects/stppoperation.php
View file @
3df22172
...
@@ -62,4 +62,15 @@ class STPPOperation extends STPPObject
...
@@ -62,4 +62,15 @@ class STPPOperation extends STPPObject
$this
->
options
[
"pareq"
]
=
$value
;
$this
->
options
[
"pareq"
]
=
$value
;
return
$this
;
return
$this
;
}
}
/**
* Set the 3DSecure PaRes (payer authentication response) value.
* Based on values sent back from ST.
*/
public
function
set3DSecurePaRes
(
$value
)
{
$this
->
options
[
"pares"
]
=
$value
;
return
$this
;
}
}
}
\ No newline at end of file
objects/stppresponse.php
View file @
3df22172
...
@@ -25,7 +25,7 @@ class STPPResponse
...
@@ -25,7 +25,7 @@ class STPPResponse
/**
/**
* Called when the response has been constructed.
* Called when the response has been constructed.
*/
*/
public
function
__construct
(
$response
)
public
function
__construct
(
$response
=
null
,
$request
=
null
)
{
{
$this
->
feed
=
simplexml_load_string
(
$response
);
$this
->
feed
=
simplexml_load_string
(
$response
);
return
true
;
return
true
;
...
@@ -53,6 +53,18 @@ class STPPResponse
...
@@ -53,6 +53,18 @@ class STPPResponse
}
}
/**
* Retrieves the error message.
*/
public
function
getErrorMessage
()
{
if
(
$this
->
isSuccessful
())
return
null
;
return
(
array
)
$this
->
feed
->
response
->
error
;
}
/**
/**
* Retrieves the transaction reference that applies to this
* Retrieves the transaction reference that applies to this
* transaction.
* transaction.
...
...
stapi.php
View file @
3df22172
...
@@ -50,7 +50,8 @@ class STAPI
...
@@ -50,7 +50,8 @@ class STAPI
*/
*/
public
function
__construct
(
$address
=
"127.0.0.1"
,
$port
=
5000
)
public
function
__construct
(
$address
=
"127.0.0.1"
,
$port
=
5000
)
{
{
# $this->connect($address, $port);
if
(
$address
!=
null
)
$this
->
connect
(
$address
,
$port
);
}
}
...
@@ -59,7 +60,7 @@ class STAPI
...
@@ -59,7 +60,7 @@ class STAPI
*/
*/
public
function
__destruct
()
public
function
__destruct
()
{
{
#
$this->disconnect();
$this
->
disconnect
();
}
}
...
@@ -83,7 +84,10 @@ class STAPI
...
@@ -83,7 +84,10 @@ class STAPI
*/
*/
protected
function
disconnect
()
protected
function
disconnect
()
{
{
return
fclose
(
$this
->
connection
);
if
(
$this
->
connection
)
return
fclose
(
$this
->
connection
);
return
true
;
}
}
...
@@ -276,6 +280,8 @@ class STAPI
...
@@ -276,6 +280,8 @@ class STAPI
* calling conventions.
* calling conventions.
*
*
* Otherwise, the correct value will be returned unmolested.
* Otherwise, the correct value will be returned unmolested.
*
* @todo: Fix this so that stuff like setOperation3DSecure... works.
*/
*/
public
function
__call
(
$method
,
$arguments
)
public
function
__call
(
$method
,
$arguments
)
{
{
...
@@ -311,22 +317,46 @@ class STAPI
...
@@ -311,22 +317,46 @@ class STAPI
}
}
/**
* Some __get abuse - if there is an object getter, call it and
* return its value.
*/
public
function
__get
(
$property
)
{
$caller
=
"get"
.
ucfirst
(
$property
);
if
(
!
method_exists
(
$this
,
$caller
))
return
null
;
return
$this
->
$caller
();
}
/**
/**
* Used to push a request off to the SecureTrading endpoint.
* Used to push a request off to the SecureTrading endpoint.
*/
*/
public
function
call
(
$type
)
public
function
call
(
$type
)
{
{
$
request
=
$this
->
compile
(
$type
)
->
asXML
(
);
$
failure
=
new
STPPResponse
(
"<responseblock></responseblock>"
);
if
(
!
fwrite
(
$this
->
connection
,
$request
,
strlen
(
$request
)))
if
(
!
$this
->
connection
)
return
false
;
return
$failure
;
$request
=
$this
->
compile
(
$type
);
$outbound
=
$request
->
asXML
()
.
"
\r\n
"
;
if
(
!
fwrite
(
$this
->
connection
,
$outbound
,
strlen
(
$outbound
)))
return
$failure
;
$response
=
""
;
$response
=
""
;
while
((
$chunk
=
fread
(
$this
->
connection
,
4096
))
!=
=
false
)
while
((
$chunk
=
fread
(
$this
->
connection
,
4096
))
!=
false
)
$response
.=
$chunk
;
$response
.=
$chunk
;
return
new
STPPResponse
(
$response
);
if
(
!
$response
)
return
$failure
;
return
new
STPPResponse
(
$response
,
$request
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment