Code Monkey home page Code Monkey logo

php-stpp's Introduction

php-stpp

This masterpiece is currently in development, however, it's doing things properly as it should - including 3D Secure support, however awkward that may be.

I've tried to make this as versatile as possible, matching various different 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();

php-stpp's People

Contributors

westie avatar

Watchers

 avatar James Cloos avatar

php-stpp's Issues

stppbilling setAmount bug

There's a strange rounding issue with php floats cast to integers.

The line:
$this->options["amount"]["value"] = (integer) ($amount * 100);

If the amount provided = 10.04, the final value becomes 1003

floor(10.04 * 100) also gives 1003

number_format((10.04 * 100), 0, '.', '') seems to be the only reliable solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.