简体   繁体   English

在没有Composer的情况下安装OmniPay

[英]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. 我不想使用作曲家安装Omnipay,而是使用传统的PHP包含来使用Stripe设置Omnipay。

How do i do this? 我该怎么做呢? I have extracted it to this folder: 我已将其提取到此文件夹:

www.mysite.com/payments/src

Stripe.php with example code is here: 带有示例代码的Stripe.php在这里:

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? 我需要在标头示例代码中包括哪些PHP文件?

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. 我在Windows上运行xampp,最初我也不想使用composer,但是一旦安装了composer,我要做的就是在项目目录中使用以下代码和cmd更改路径创建composer.json文件。到项目目录,然后输入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 / 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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