CI Merchant no output - codeigniter

I am trying to use CI Merchant library for codeignator
here is my code:
$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = array(
'username' => 'api.sandbox.paypal.com',
'password' => 'AQHaXxDW3dlKDRDJ7lDtGr4w8-reNNfvPFUKmEr9npMzYjZ2WIbfqqI3VL2C',
'signature' => 'EMbUfhBCqBZw8hhH6q8VZT_53-xwoOs6_lotS68I7qrY5iyHPLgDitrsAZj5',
'test_mode' => true);
$this->merchant->initialize($settings);
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout');
$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
echo '</pre>';
but when I run it local here is result:
Merchant_response Object
(
[_status:protected] => failed
[_message:protected] => error setting certificate verify locations:
CAfile: C:\xampp\htdocs\egyptianornaments\application\config/cacert.pem
CApath: none
[_reference:protected] =>
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
and when I run on the server I get a blank page
so what I am doing wrong?

Looks like your code is setup to use a certificate instead of the signature method, but your servers don't have the SSL cert installed and configured to work with PayPal, which is really sort of a pain to deal with anyway. I would recommend switching to the signature method and then you won't have to mess with that at all.
I'm not familiar with the library you're using, but there must be some way to set that. You might also want to take a look at my own CodeIgniter library for PayPal that is pretty popular.
I've actually stopped maintenance of that CI specific library, though, because I now have my general PHP library for PayPal updated for PHP 5.3+ and working with Composer / Packagist, which allow you to use it in CodeIgniter or any other framework.
As of today, the CI specific library isn't far behind, but again, I'm not updating it anymore. I'm only maintaining the general version now since it works everywhere.
Anyway, it makes every PayPal API call very simple for you.

Related

How to change programmatically Laravel Omnipay object?

Currently, I am handling stripe payments with Omnipay's Stripe library. Similar with the example below:
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey("sk_test_xHGgkZtGOlTwxi4d8GYOHifZ");
$formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '123');
$response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send();
However, there are too much different payment gateways. Let's assume, I've both Paypal and Stripe packages of omnipay. How can I handle the omnipay package that selected as a default on db. I don't know what to do. Ofcourse, You could say simply use if and else. But, it's not a good in practice. What sticks my mind and bother me is implementing this idea with a generic way with the S.O.L.I.D. principles in Laravel.

Laravel passport 500 internal server error when using subdomain

Using laravel passport on my local machine and domain http://myapp.test, I have no problem.
When I push the code to my server on my main domain https://myapp.com, again no problem.
However, I have a sudomain used for my live test (pre-production) before to push to the main domain in production. If I use https://dev.myapp.com, then I get a 500 internal server error.
Any idea how to fix it?
This is the guzzle call I'm doing:
$http = new GuzzleHttp\Client;
$response = $http->post('https://dev.myapp.com/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 'client_id',
'client_secret' => 'client_secret_key',
'username' => 'john#example.com',
'password' => '123456',
'scope' => '',
],
]);
return $response;
If I change the url to my local or production website (changing the passport key and making sure the same user exists), it works properly.
My bad. Just forgot to run that command on the server for that specific domain as specified in the documentation. This command generates the encryption keys Passport needs in order to generate access token.
php artisan passport:keys

Laravel - Payone

Is there an easy wrapper for the payone(https://www.payone.de/) API for Laravel? I only found one company who sells a package but nothing that is open source. I would appreciate any help.
You should consider Omnipay: http://omnipay.thephpleague.com/
Because:
It is gateway independent.
It is framework independent. It works well with Laravel but also Symfony, Yii, etc.
There is an Omnipay plugin for PayOne: https://github.com/academe/OmniPay-Payone
The code to make a purchase via Omnipay is pretty much the same regardless of the gateway. Here is some sample code that should work, although you should check the details of the Payone classes for other information that you need to send. The Payone gateway can work in multiple different ways depending on how your account is set up.
$gateway = Omnipay::create('Payone_ShopServer');
$card = new CreditCard(array(
'firstName' => 'Example',
'lastName' => 'User',
'number' => '4111111111111111',
// ... etc
));
$transaction = $gateway->purchase(array(
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'card' => $card,
));
$response = $transaction->send();
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
}
// At this point you should get $response->getTransactionReference()
// and store that or something similar.

Using Laravel Facades outside Laravel

I have a Laravel application which I use as an API to a much larger application built in Joomla. I really love using Laravel and decided to use Eloquent within the Joomla application. I got this working by importing the bootstrap\autoload.php file in the Laravel application and creating a Capsule
require JPATH_ROOT.'/../laravel_app/bootstrap/autoload.php';
$capsule = new Capsule();
$config = new JConfig();
$capsule->addConnection([
'driver' => 'mysql',
'host' => $config->host,
'database' => $config->db,
'username' => $config->user,
'password' => $config->password,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => $config->dbprefix,
'strict' => false
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
This works great and I can use Eloquent. It loads the Eloquent models from the app directly.
What I want to know is how I get the rest of the Laravel app working inside my Joomla app, including using Facades.
For example I have the use of Config.get('key') within one of the Eloquent models, works fine when called in Laravel, but throws and error when called in Joomla.
Fatal error: Class 'Config' not found in laravel_app/app/Model.php on line 192
I have looked at laravel_site/public/index.php to see how it initiates the application and so far so good this seems to be a working solution:
require JPATH_ROOT.'/../laravel_site/bootstrap/autoload.php';
$app = require_once JPATH_ROOT.'/../laravel_site/bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
//$response->send();
//$kernel->terminate($request, $response);
Facades now appear to be working fine. I've purposely left out $response->send(); and $kernel->terminate($request, $response); so that the routing does not take place and override Joomla's own routing.
I also no longer need to instantiate the Capsule as Laravel is doing that for me now.
I haven't tested this fully so I do not know how robust it is or what features will work but all is good so far.

Paypal API for codeigniter

I need a paypal library for codeigniter (without redirecting to paypal site), I used angell eye paypal library but it had some issues.
If you have any suggestion which library should i use but i dont want to redirect to paypal site. I have Username, password and signature.
this is my code
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout');
$this->load->library('merchant');
$this->merchant->load('paypal_pro');
$this->load->helper('language');
$settings = array(
'username' => 'sandbo_1215254764_biz_api1.angelleye.com',
'password' => '1215254774',
'signature' => 'AiKZhEEPLJjSIccz.2M.tbyW5YFwAb6E3l6my.pY9br1z2qxKx96W18v',
'test_mode' => true);
$this->merchant->initialize($settings);
$response = $this->merchant->purchase_return($params);
print"<pre>";
print_r($response);die;
Thank You
Try CI-Merchant payments API
In that you need to use PayPal Website Payments Pro
EDIT:
$this->load->library('merchant');
$this->merchant->load('paypal_pro');
Express check out will take you to Paypal site for payment. Paypal pro will process payments in your server.
** Make sure you are running the code in test/production server(public accessible) but not local machine

Categories

Resources