简体   繁体   中英

Install OmniPay without Composer

I don't want to use composer to install Omnipay but rather use traditional PHP includes to setup Omnipay with Stripe.

How do i do this? I have extracted it to this folder:

www.mysite.com/payments/src

Stripe.php with example code is here:

www.mysite.com/payments/Stripe.php

Where do i put the stripe payment gateway files? What PHP files do i need to include in the header example code?

I am using this example code:

include $_SERVER['DOCUMENT_ROOT']."/payments/src/Omnipay/Omnipay.php";

use Omnipay\Omnipay;

$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('abc123');

$formData = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

不知道为什么要这样做,但是如果真的要为什么不将它与composer一起安装在另一个位置,然后将文件(包括composer自动加载文件)复制到项目中。

I'm running xampp on Windows and initially I didn't want to use composer either but once composer is installed then all I needed to do was to create the composer.json file in the project directory with the code below and in cmd change path to the project directory and type composer install.

{
    "require": {
        "omnipay/stripe": "~2.0"
    }
}

I could then see why a manual installation is not documented because it automatically installed the all the following dependancies and configured the autoload files vendor/composer/:

vendor/autoload.php
vendor/composer
vendor/guzzle
vendor/omnipay/common
vendor/omnipay/stripe
vendor/symfony/event-dispatcher
vendor/symfony/http-foundation
vendor/symfony/polyfill-mbstring
composer.lock

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM