Matt Sagen
Matt Sagen

Reputation: 13

Missing Classes from Silverstripe Omnipay

On a fresh scotch box https://box.scotch.io/ (which I generally recommend)

and with this composer:

{
    "name": "silverstripe/installer",
    "description": "The SilverStripe Framework Installer",
    "require": {
        "php": ">=5.3.3",
        "silverstripe/cms": "3.5.1",
        "silverstripe/framework": "3.5.1",
        "silverstripe/reports": "3.5.1",
        "silverstripe/siteconfig": "3.5.1",
        "silverstripe-themes/simple": "3.1.*",
        "silverstripe/silverstripe-omnipay": "^2.1",
        "omnipay/paymentexpress": "^2.2",
        "firebase/php-jwt": "^4.0"
    },
    "require-dev": {
        "phpunit/PHPUnit": "~3.7@stable"
    },
    "extra": {
        "branch-alias": {
            "3.x-dev": "3.5.x-dev"
        }
    },
    "config": {
        "process-timeout": 600
    },
    "prefer-stable": true,
    "minimum-stability": "dev"
}

And using payment.yml from https://github.com/silverstripe/silverstripe-omnipay

Silverstripe builds Payments, but none of the Omnipay classes are included. I have used Omnipay before with SS with no problems.

Anybody know what is going on?

Upvotes: 1

Views: 233

Answers (3)

Michael Mitchell
Michael Mitchell

Reputation: 91

silverstripe-omnipay makes use of php namespaces for many of its files, it just so happens that ServiceFactory is one of them so in order for SilverStripe to find the correct file to include you must specify its use at the top of files you intend to use ServiceFactory.

<?php use SilverStripe\Omnipay\Service\ServiceFactory; ...

It is not entirely obvious because modules made for SilverStripe rarely make use of namespaces fo and silverstripe-omnipay makes no mention that ServiceFactory is namespaced in its examples.

Upvotes: 0

theruss
theruss

Reputation: 1746

Make sure you run the following on the command-line:

$> ./framework/sake dev/build flush=all

Also always worth just blowing away the contents of SS' cache (You're using Vagrant, so assuming this is a Dev env) which is usually located in /tmp if you're using the F/S and not memcache or some such, then running dev/build again. This will both clear and rebuild your cache, and in the process tell SS about all the new classes it has available to it.

Upvotes: 1

mylesthe.dev
mylesthe.dev

Reputation: 9685

What errors do you get? and how are you trying to access the classes?

You should be able to call the classes like this (depending on the Omnipay version)

<?php
use Omnipay\Omnipay;

class PaymentPage extends Page
{
    function ...
    {
        try {
            $response = $gateway->purchase([...
    } 
}

Upvotes: 0

Related Questions