omnipay pin payments with cake php 2.0 - php

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

Related

Class 'yii\jui\DatePicker' not found (yii2 basic)

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.

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

Fatal error: Class 'OpenCloud\Rackspace' not found

For a custom application, I am trying to integrate Rackspace cloud files using php-opencloud library.
This is the link I followed for setup -https://github.com/srijanaravali/php-opencloud/blob/master/docs/getting-started.md
# Install Composer
curl -sS https://getcomposer.org/installer | php
# Require php-opencloud as a dependency
php composer.phar require rackspace/php-opencloud:dev-master
However, when I try to instantiate a client object, it throws an error:
Fatal error: Class 'OpenCloud\Rackspace' not found in /var/www/example/Project/sites/all/libraries/php-opencloud/test.php on line 7
Here is the code snippet:
<?php
require 'vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client.
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => getenv('Axxxxxxx'),
'apiKey' => getenv('abcxxxxxxxxxxxxxxxxxxxx')
));
print_r($client); die('!!');
Any pointers about whats missing?
Got it working. For some strange reason, php-opencloud library was empty under vendors/rackspace/php-opencloud.
Cloned one from github and created a symlink to it from above directory. It is working fine now.

Laravel: Helpers class not found on live site. Works locally

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

pin payment error - vendor/autoload.php not found

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

Categories