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();
}
Not sure why you want to go that way, but if you really want to why not just install it with composer in another location and then copy the files (including the composer autoload file) in your project.
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
Related
I'm developing an application where I started using Kohana and now Koseven, and I need to use an api that was available in the composer, I followed the steps to download the files I created a folder to sell inside the application, and put in the bootstrap.php code to call the autoload of the composer.
But after doing this when trying to use a class of this api error of "class not found" occurs.
I do not know what else to do, can you help me?
In order to use composer with Kohana or Koseven, you need to call composer's autoloader from within bootstrap.php.
After Kohana::modules($modules); and before Route::set, insert the following code:
/**
* Autoload composer libraries
*
*/
require APPPATH . 'vendor/autoload.php';
This assumes your composer install command is run the from the root of your app, and it uses the default vendor directory.
Probably you must add this to your composer.json. (Check inc composer doc.) I don't know, because in modules directory I have second instance.
"extra": {
"installer-paths": {
"modules/{$name}/": ["type:kohana-module"]
}
},
And enable module composer as first:
Kohana::modules(array(
'composer' => MODPATH.'composer', //
'auth' => MODPATH.'auth', // Basic authentication
'cache' => MODPATH.'cache', // Caching with multiple backends
It works for me ko3
I am working on a project in Yii2 where I need to integrate CKEditor. I used this to install it:
composer require 2amigos/yii2-ckeditor-widget
It downloads the library files under /vendor directory. When I copied the files from local to server and used this:
use dosamigos\ckeditor\CKEditor;
<?= $form->field($userSurveyConfig,
'survey_email_body')->widget(CKEditor::className(),
['options' => ['rows' => 6],'preset' => 'basic'])
?>
When I run the page, this error pops up:
> Class 'dosamigos\ckeditor\CKEditor' not found
What i am doing wrong here? Any help?
Copy composer.json file to server and run composer update on server.
I downloaded the yii2-jui in this link
yii2-jui
After that I put it under yiisoft folder
yiisoft\yii2-jui
when I run my application it gives me this error
PHP Fatal Error – yii\base\ErrorException
Class 'yii\jui\DatePicker' not found
How can I fixed this.where should I put the yii2-jui folder ?
Thank you in advance
I fixed the problem when I ran
sudo composer require --prefer-dist yiisoft/yii2-jui "*"
ONLY IN FOLDER basic, where are web, yii, models and etc.
Insert this in the view:
use yii\jui\DatePicker;
The best way is: run: php composer.phar require --prefer-dist yiisoft/yii2-jui "*" in your project
insert code:
'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.2',
'alias' =>
array (
'#yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
),
),
in yiisoft/extensions.php file
Stop creating duplicate questions.
And you do not just download something and copy it in a folder. Use composer to install it. the Yii2 that you copied is just a shell, you have to use composer to install the rest of it. Composer does more then just copy the files it creates an autoloader that tells yii where everything is.
I am attempting to use the thujohn/twitter package to get a live twitter feed on my site.
I got it working on my local server by using the tutorial found here but when I uploaded the changes to my digital Ocean server, I got the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Helpers' not found
Here are the steps I took - not much code:
I downloaded the package with artisan
config/app.php: added 'Thujohn\Twitter\TwitterServiceProvider', to the providers and 'Twitter' => 'Thujohn\Twitter\TwitterFacade' to the aliases
added app_path().'/classes', to the start/global.php file
I added a Helpers class to classes/helpers.php, which contains:
public static function twitterFeed($screen_name='screenName', $count='1', $include_retweets='false', $exclude_replies='true')
{
$twitterfeed = Cache::remember('twitterfeed', 30, function() use ($screen_name, $count, $include_retweets, $exclude_replies) {
return Twitter::getUserTimeline(
array(
'screen_name' => $screen_name,
'count' => $count,
'include_rts' => $include_retweets,
'exclude_replies' => $exclude_replies
)
);
})
;
if(!empty($twitterfeed)) {
return $twitterfeed;
}
else {
return array();
}
}
Put a view::share in my route file:
View::share('tweets', Helpers::twitterFeed('contractrsherpa', '1', false, true));
then looped through it in my view.
Finally, ran composer dump-autoload.
Seems pretty straightforward and works great locally. I uploaded everything to my liver server, ran composer dump-autoload, but still get the error "class 'Helpers' not found."
Any idea what I need to do to get this to work on the live site?
TIA
I need help regarding omnipay pin payments. i have no clue how to integrate this to cake php.
i tried this sample code but dint get success
$gateway = GatewayFactory::create('Pin');
$gateway->setSecretKey('your-secret-api-key');
$gateway->purchase([
'email' => 'customer#email.com',
'description' => 'Widgets',
'amount' => '4999',
'currency' => 'USD',
'card_token' => 'card_nytGw7koRg23EEp9NTmz9w',
'ip_address' => '1.2.3.4'
])->send();
Fatal error: Class 'GatewayFactory'
Please help me . Thanks in advance
You need to use Composer to install Omnipay. This is explained in the Omnipay Readme.
Make a file called composer.json in the root of your project directory:
{
"require": {
"omnipay/pin": "~2.0"
}
}
Then run the following commands in a terminal window:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
This will download the Omnipay files into your vendor/ directory.
Next, you will need to put the following line at the top of your index.php file, to register the composer autoloader:
require 'vendor/autoload.php';
Finally, you can use Omnipay in your project to create the Pin gateway:
$gateway = Omnipay\Omnipay::create('Stripe');