1

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?

Piotr Dawidiuk
  • 2,961
  • 1
  • 24
  • 33
Matt Sagen
  • 13
  • 2
  • After you do `composer install`, there should be an `omnipay` folder (the silverstripe-omnipay module) and the phpleague omnipay classes should be in `vendor`… isn't that the case? – bummzack Feb 01 '17 at 08:32
  • Yes @bummzack, all the files are there. Echoing at the top of any of them doesn't do anything, they are being ignored. I had hoped for a way to trace the process of ClassManifest getting built so I could see if it was permissions or policies or something... just stumped. – Matt Sagen Feb 01 '17 at 22:41
  • Can you post some example code that fails and the error message you get when running that code? – bummzack Feb 03 '17 at 20:04

3 Answers3

1

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.

theruss
  • 1,690
  • 1
  • 12
  • 18
  • Hey @theruss, this happened on a fresh Vagrant box, so I am not sure how anything would be cached ... is command line dev/build flush=all any different than calling it via URL? Have done several times... – Matt Sagen Feb 01 '17 at 22:35
  • 1
    OK, so we've established you have a clear cache, you've run composer install, but did you run composer update? When you run composer install, it takes the contents of the composer.lock file, but composer.lock won't have been updated with your omnipay package data unless you run composer update. Better still is not to edit the composer.json manually _at all_, preferring instead to use composer require /. – theruss Feb 02 '17 at 02:44
0

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([...
    } 
}
mylesthe.dev
  • 9,565
  • 4
  • 23
  • 34
  • I get errors like "Fatal error: Class 'ServiceFactory' not found" - your example looks like it is using Omnipay without Silverstripe-Omnipay, as you are including "use Omnipay\Omnipay" which hasn't been necessary in my other implementation, because we never call Omnipay directly, but only through the SS "Payment" and "PurchaseService" classes. – Matt Sagen Feb 01 '17 at 22:49
  • Yeah, seriously. Using composer require instead of manually hacking composer.json will probably fix this. If it were anything else, you'd see it on the forums with others having the same problem. (I haven't looked thought, but it's unlikely an issue like that would go long without being fixed. – theruss Feb 02 '17 at 08:02
0

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.