pin payment error - vendor/autoload.php not found - php

I have installed composer on my pc and running a pin payment script.
require_once __DIR__.'/vendor/autoload.php';
use Omnipay\Common\GatewayFactory;
$gateway = GatewayFactory::create('Pin');
$gateway->setSecretKey('1111111111');
$gateway->purchase(array(
'email' => 'abc.php2#gmail.com',
'description' => 'Widgets',
'amount' => '49.99',
'currency' => 'USD',
'card_token' => $_REQUEST['card_token'],
'ip_address' => $_REQUEST['ip_address']
))->send();
I am not sure about require_once _DIR_.'/vendor/autoload.php'; , where can i find the exact path for the same.

I think as you as "but where do I find the vendor" that you did not run the composer install command.
You have to run it in order to create the vendor dorectory and download the packages. Find out more in the documentation: http://getcomposer.org/doc/00-intro.md#using-composer
Basically, run:
composer install

Related

PAMI can't find class

I'm trying to install PAMI library
I installed it via pear:
# pear channel-discover pear.marcelog.name
# pear install marcelog/PAMI
and trying to use example.php
$pamiClientOptions = array(
'host' => '127.0.0.1',
'scheme' => 'tcp://',
'port' => 9999,
'username' => 'admin',
'secret' => 'mysecret',
'connect_timeout' => 10000,
'read_timeout' => 10000
);
use PAMI\Client\Impl\ClientImpl as PamiClient;
$pamiClient = new PamiClient($pamiClientOptions);
// Open the connection
$pamiClient->open();
// Close the connection
$pamiClient->close();
when I try to use this script I receive error:
Class 'PAMI\Client\Impl\ClientImpl' not found
It's first time, I see that classes are included like this (use).
I'm using debian Linux also. Please, help.
UPDATE
Also it's installed in /usr/share/php/PAMI/
Solved. I've found solution in "in_depth explanation"
You had to do this after pear installation
require_once '/usr/share/php/PAMI/Autoloader/Autoloader.php';
PAMI\Autoloader\Autoloader::register();
I put this two strings at top of my script and it works now. But it also receives strange
PHP Fatal error: Class 'Logger' not found in
I solve this by installing log4php:
$ pear channel-discover pear.apache.org/log4php
$ pear install pear.apache.org/log4php/Apache_log4php-2.1.0
And also you should put before first require_once -
require_once '/usr/share/php/log4php/Logger.php';

Integrate amazon AWS with yii 2.0

How do I integrate my Yii 2.0 project with Aws ?
I have installed it using composer
"aws/aws-sdk-php": "2.*",
and included the
require '../vendor/aws/aws-autoloader.php';
But when I try to instantiate my S3 client, it keeps telling me that Aws does not exist.
You can refer the following link on github
https://github.com/JDpawar/yii2-aws-s3-sdk
It has the exact details how to use the S3 SDK along with the Yii 2 App.
AWS SDK for Yii2 - Use Amazon Web Services in your Yii2 project
This extension provides the AWS SDK 3 integration for the Yii2 framework
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist fedemotta/yii2-aws-sdk "*"
or add
"fedemotta/yii2-aws-sdk": "*"
to the require section of your composer.json file.
Note: You can still use AWS version 2 if you specify fedemotta/yii2-aws-sdk "1.*"
Usage
To use this extension, simply add the following code in your application configuration:
<?php
return [
//....
'components' => [
'awssdk' => [
'class' => 'fedemotta\awssdk\AwsSdk',
'credentials' => [ //you can use a different method to grant access
'key' => 'your-aws-key',
'secret' => 'your-aws-secret',
],
'region' => 'your-aws-region', //i.e.: 'us-east-1'
'version' => 'your-aws-version', //i.e.: 'latest'
],
],
];
?>
Getting all balancer names from AWS:
<?php
$aws = Yii::$app->awssdk->getAwsSdk();
$elb = $aws->createElasticloadbalancing();
$load_balancers = $elb->describeLoadBalancers()->toArray();
if (isset($load_balancers['LoadBalancerDescriptions'])){
foreach ($load_balancers['LoadBalancerDescriptions'] as $balancer){
if (isset($balancer['LoadBalancerName'])){
echo $balancer['LoadBalancerName'];
}
}
}
?>
Download an object from S3:
<?php
//specify the region if it is different than the main configuration region
Yii::$app->awssdk->region = 'sa-east-1';
$aws = Yii::$app->awssdk->getAwsSdk();
//use s3
$s3 = $aws->createS3();
$result = $s3->listObjects(['Bucket' => 'your-bucket-id',
"Prefix" => "your-path"])->toArray();
//get the last object from s3
$object = end($result['Contents']);
$key = $object['Key'];
$file = $s3->getObject([
'Bucket' => 'your-bucket-id',
'Key' => $key
]);
//download the file
header('Content-Type: ' . $file['ContentType']);
echo $file['Body'];
?>
Run the Composer command to install s3 extension. composer require frostealth/yii2-aws-s3 ~1.0#stable
Open common/config/main.php file and add below code into "components" section. "s3bucket" => [ "class" => \frostealth\yii2\aws\s3\Storage::className(), "region" => "Your region", "credentials" => [ "key" => "your aws s3 key", "secret" => "your aws s3 secret", ], "bucket" => "your aws s3 bucket", "defaultAcl" => \frostealth\yii2\aws\s3\Storage::ACL_PUBLIC_READ, "debug" => false, // bool|array ],
Use below code to upload image on s3 $s3 = Yii::$app->get('s3bucket')->upload('upload image name', 'path of local folder where image located');
After uploading you get status code and image url. you can get like below $status = $s3["#metadata"]["statusCode"]; $imageUrl = $s3["#metadata"]["effectiveUri"];
I reimport my extension using composer,
and adding
require (\Yii::getAlias('#vendor/autoload.php'));
Somehow I got it working by adding 'autoload' in json composer
"autoload": {
"psr-4": {
"vendor\\aws\\" :""
}
}
and then run
php composer.phar dumpautoload
Was looking around for this for a few hours and only found other packages to solve the issue. Wanted to implement the AWS package directly. So from
Installed the latest aws-sdk via composer.
I am using
"aws/aws-sdk-php": "^3.259"
Make sure aws source and location is correct in the vendor/composer/autoload_psr4.php
'Aws\\' => array($vendorDir . '/aws/aws-sdk-php/src')
After that ran composer update as mentioned by #Karate_Dog
php composer.phar dumpautoload

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();
}
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

omnipay pin payments with cake php 2.0

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');

Symfony2 : Installation CCDNMessageMessageBundle

I'm trying to install the Symfony bundle CCDNMessageMessageBundle.
To do this I :
installed Symfony (2.0.17)
executed php bin/vendors install with git
followed the indications in here
The problem comes in step 4 of this documentation (Run vendors install script) :
There are many errors - this are the first lines :
Installing/Updating CCDNMessageMessageBundle f7ee2c184257011e2991b34ac5cfe9a8b01c6889
HEAD is now at f7ee2c1
Update documentation
PHP Fatal error: Class 'CCDNMessage\MessageBundle\CCDNMessageBundle' not found in
xxxxxxxxxxxx\app\AppKernel.php on line 20 ...
For information :
AppKernel.php, line 20 contains :
new CCDNMessage\MessageBundle\CCDNMessageBundle(),
as last element of array $bundles.
autoload.php contains this registerNamespaces :
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
'Monolog' => __DIR__.'/../vendor/monolog/src',
'Assetic' => __DIR__.'/../vendor/assetic/src',
'Metadata' => __DIR__.'/../vendor/metadata/src',
'CCDNMessage' => __DIR__.'/../vendor/bundles',
));
And at the end of deps I entered :
[CCDNMessageMessageBundle]
git=http://github.com/codeconsortium/CCDNMessage.git
target=/bundles/CCDNMessage/MessageBundle
version=v1.2
I think I did all the steps in the documentation !
Someone can help me to resolve this problem ?
The git url in deps is wrong, should be
[CCDNMessageMessageBundle]
git=git://github.com/codeconsortium/CCDNMessageMessageBundle.git
target=/bundles/CCDNMessage/MessageBundle
version=v1.2
or with HTTP
[CCDNMessageMessageBundle]
git=http://github.com/codeconsortium/CCDNMessageMessageBundle.git
target=/bundles/CCDNMessage/MessageBundle
version=v1.2

Categories