laravel wont set header during gopay payment integration - laravel

I have a problem with payment integration to my laravel project. It is a GOPAY REST API.
It should by default set request headers with Accept, Content-type and Authorization where the token is stored. Problem is that it doesnt set my request headers. I used the same thing in a normal script which included the SDK and it worked correctly. However in my laravel project it just doesnt work. The SDK uses Curl to set headers and i think there is somewhere the problem.
I also didnt find any similar problem, and i definitely didnt google anyone who integrated GoPay into Laravel.
Pay method in my controller
//minimal configuration
$gopay = GoPay\payments([
'goid' => '8583340073',
'clientId' => '1162442589',
'clientSecret' => 'eDxNQ3ru',
'isProductionMode' => false,
'scope' => GoPay\Definition\TokenScope::ALL,
'language' => GoPay\Definition\Language::CZECH],
['logger' => new GoPay\Http\Log\PrintHttpRequest()]);
$response = $gopay->createPayment([
'payer' => [
'default_payment_instrument' => PaymentInstrument::BANK_ACCOUNT,
'allowed_payment_instruments' => [PaymentInstrument::BANK_ACCOUNT],
'default_swift' => BankSwiftCode::FIO_BANKA,
'allowed_swifts' => [BankSwiftCode::FIO_BANKA, BankSwiftCode::MBANK],
'contact' => [
'first_name' => 'Zbynek',
'last_name' => 'Zak',
'email' => 'test#test.cz',
'phone_number' => '+420777456123',
'city' => 'C.Budejovice',
'street' => 'Plana 67',
'postal_code' => '373 01',
'country_code' => 'CZE',
],
],
'target' => ['type' => 'ACCOUNT', 'goid' => '8583340073'],
'currency' => Currency::CZECH_CROWNS,
'order_number' => '001',
'order_description' => 'pojisteni01',
'items' => [
['name' => 'item01', 'amount' => 50],
['name' => 'item02', 'amount' => 100],
],
'recurrence' => [
'recurrence_cycle' => Recurrence::DAILY,
'recurrence_period' => "7",
'recurrence_date_to' => '2016-12-31'
],
'additional_params' => [
array('name' => 'invoicenumber', 'value' => '2015001003')
],
'callback' => [
'return_url' => 'http://www.hume.cz/public',
'notification_url' => 'http://www.hume.cz/public'
]
]);
I think that somehow laravel changes the headers and doesnt allow the SDK to do it. If you know anything please help me. If you need any extra information, please just ask.
Thank you very much!!

There is a package for handling GoPay payments with Laravel. Install, update config with your credentials and start using GoPay facade to createPayment or another function from official SDK.
I have eshop in production with this my own package and everything works fine.
https://github.com/hazestudio/laravel-gopay-sdk

Related

How to use laravel cashier charge with `withMetaData` and `create`

I am new to laravel cashier, and I am stuck here.
For my games, users can subscribe. I have 3 subscription methods.
Monthly
Yearly
One-time.
For monthly and Yearly subscriptions, I have used the below code and it works perfectly.
$subscription = $user->newSubscription($subscriptionName, $plan->stripe_id)->withMetaData(['game' => $game->name])->create(null, [
'email' => $user->email,
'name' => $user->name,
['metadata' => ['game' => $game->name]],
], $subscriptionOptions);
But for the one-time subscription, I have used the below code
$subscription = $user->charge(2500, 'pm_1IpuT.....')->withMetaData(['game' => $game->name])->create(null, [
'email' => $user->email,
'name' => $user->name,
['metadata' => ['game' => $game->name]],
], $subscriptionOptions);
for this, I am and getting the below error
Error
Call to undefined method Laravel\Cashier\Payment::withMetaData()
Can anyone help to solve this?
As they mention here you pass the metadata as a third argument in the charge method
$user->charge(100, $paymentMethod, [
'custom_option' => $value,
]);
so in your example, you need to edit it like this
$subscription = $user->charge(2500, 'pm_1IpuT.....', [
'metadata' => [
'game' => $game->name,
'email' => $user->email,
'name' => $user->name,
]
]);
for more additional data to pass check stripe docs

can i use stripe checkout with destination charges?

I'm wondering if there is any way to charge some kind of fee on transactions using the new Stripe Checkout system. In this particular instance I am using Laravel 8 with Livewire. In my component I have a function tied to a button called setStripeSession.
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => 'Custom Media',
],
'unit_amount' => $this->toPennies($price),
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'http://e68ec3e6b8b2.ngrok.io/',
'cancel_url' => 'http://e68ec3e6b8b2.ngrok.io/',
],['stripe_account_id'=>$this->stripe_account_id]);
$this->stripe_session_id = $session->id;
Message::where('id',$message_id)->update(['stripe_session_id'=>$this->stripe_session_id ]);
$this->emit('PayonStripe',['ssid'=>$session->id]);
}
I imagined adding something like the below code but the variables are not recognized by the stripe API during the rquest.
'transfer_data' => [
'destination' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
],
Yes! You can set these within the payment_intent_data parameter:
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [...],
'mode' => 'payment',
'success_url' => 'http://example.com/success',
'cancel_url' => 'http://example.com/cancel',
'payment_intent_data' => [
'application_fee_amount' => 100, // optional
'transfer_data' => [
'destination' => 'acct_123',
],
],
]);
A number of parameters are exposed this way in Checkout, such as metadata for the payment intent and similar data for subscription mode under subscription_data.

How to disable elfinder delete and edit option?

Hello I am using elfinder in my laravel application. I am not able to disable delete option from elfinder. Any help is hugely appreciated.
Here is my config file:
<?php
return array(
'dir' => ['assets/uploads/news_upload'],
'disks' => [
],
'route' => [
'prefix' => 'elfinder',
'middleware' => array('web', 'auth'), //Set to null to disable middleware filter
],
'access' => 'Barryvdh\Elfinder\Elfinder::checkAccess',
'roots' => null,
'options' => array(),
'root_options' => array(
),
);
?>
I am not able to disable delete option.
I got the solution after 3 hour of research. And yes it is so simple, just put this code in your config file. Hope this answer will help somebody some day.
'root_options' => array(
'defaults' => array('read' => true, 'write' => true,'locked'=>true),
),

How to get authenticated users cached on drupal with or without authcache

Could use some help. I have a drupal6 install that im having trouble with in terms of caching for authenticated users. Boost is handling the none authenticated caching very well. With my current setup, sessions cannot be created at all, when attempting to login the result is "You are not authorized to view this page". Memcache and apc are installed on the server and working according to phpinfo. Here is my current setup (without cacherouter):
include_once('./sites/all/modules/memcache/memcache.inc');
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['session_inc'] = './sites/all/modules/memcache/memcache-session.inc';
$conf['memcache_servers'] = array(
'127.0.0.1:11211' => 'default',
'127.0.0.1:11212' => 'block',
'127.0.0.1:11213' => 'content',
'127.0.0.1:11214' => 'filter',
'127.0.0.1:11215' => 'form',
'127.0.0.1:11216' => 'menu',
'127.0.0.1:11217' => 'page',
'127.0.0.1:11218' => 'update',
'127.0.0.1:11219' => 'views',
'127.0.0.1:11221' => 'session',
'127.0.0.1:11222' => 'users'
);
$conf['memcache_bins'] = array(
'cache' => 'default',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_update' => 'update',
'cache_views' => 'views',
'session' => 'session',
'users' => 'users'
);
Before this setup, I was using cacherouter with authcache and had apc as the engine. Users could log in, but there was no actual caching happening for authenticated users. I have been reading everything I could find on this to get it going, doing various test and changing configurations, but without success. Here was the previous setup:
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc',
'server' => array('127.0.0.1:11211'),
'shared' => TRUE,
'prefix' => '',
'path' => 'storage_bin/filecache',
'static' => FALSE
),
);
$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
$conf['memcache_servers'] = array(
'127.0.0.1:11211' => 'default',
'127.0.0.1:11212' => 'block',
'127.0.0.1:11213' => 'content',
'127.0.0.1:11214' => 'filter',
'127.0.0.1:11215' => 'form',
'127.0.0.1:11216' => 'menu',
'127.0.0.1:11217' => 'page',
'127.0.0.1:11218' => 'update',
'127.0.0.1:11219' => 'views'
);
$conf['memcache_bins'] = array(
'cache' => 'default',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_update' => 'update',
'cache_views' => 'views'
);
The site is visible at www.thewildside.com. Any help on this would be greatly appreciated.
If anyone else runs into this, my solution was to ditch cacherouter (did not perform as expected), authcache(too beta), and boost (simply to avoid hitting apache at all for cached pages)… proceeding with Memcache API (the drupal module), memcache (the caching system), apc and varnish (3.0). Memcache API allows me to cache both to RAM via memcache and to the drupal db as backup in case memcache is not available (via memcache.db.inc). Benchmark to determine how much RAM to use for each cache component. I can also keep session info in memcache, but I have not noticed a great performance gain with this, so you may choose not to include memcache-session.inc. Create memcache instances for each drupal cache db (or use one default instance). Setup a cache bin for each instance you've created, and throw in reverse proxy settings and default ttl. Here is my whats in my setting.php file;
$conf = array(
'cache_inc' => './sites/all/modules/memcache/memcache.db.inc',
'memcache_key_prefix' => 'ws',
'session_inc' => './sites/all/modules/memcache/memcache-session.inc',
'memcache_servers' => array(
'unix:///var/run/memcached/memcached_wildside.sock' => 'default',
'unix:///var/run/memcached/memcached_wildside_apachesolr.sock' => 'apachesolr',
'unix:///var/run/memcached/memcached_wildside_block.sock' => 'block',
'unix:///var/run/memcached/memcached_wildside_content.sock' => 'content',
'unix:///var/run/memcached/memcached_wildside_filter.sock' => 'filter',
'unix:///var/run/memcached/memcached_wildside_form.sock' => 'form',
'unix:///var/run/memcached/memcached_wildside_media_youtube_status.sock' => 'media_youtube_status',
'unix:///var/run/memcached/memcached_wildside_menu.sock' => 'menu',
'unix:///var/run/memcached/memcached_wildside_objects.sock' => 'objects',
'unix:///var/run/memcached/memcached_wildside_page.sock' => 'page',
'unix:///var/run/memcached/memcached_wildside_path.sock' => 'path',
'unix:///var/run/memcached/memcached_wildside_rules.sock' => 'rules',
'unix:///var/run/memcached/memcached_wildside_update.sock' => 'update',
'unix:///var/run/memcached/memcached_wildside_views.sock' => 'views',
'unix:///var/run/memcached/memcached_wildside_views_data.sock' => 'views_data',
'unix:///var/run/memcached/memcached_wildside_session.sock' => 'session',
'unix:///var/run/memcached/memcached_wildside_users.sock' => 'users'),
'memcache_bins' => array(
'cache' => 'default',
'cache_apachesolr' => 'apachesolr',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_media_youtube_status' => 'media_youtube_status',
'cache_menu' => 'menu',
'cache_objects' => 'objects',
'cache_page' => 'page',
'cache_path' => 'path',
'cache_rules' => 'rules',
'cache_update' => 'update',
'cache_views' => 'views',
'cache_views_data' => 'views_data',
'session' => 'session',
'users' => 'users'),
);
$conf['https'] = TRUE;
$conf['mimedetect_magic'] = '/usr/share/file/magic';
$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])){
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS']='on';
}else{
$_SERVER['HTTPS']='';
}
}
/* 1 day cache lifetime = 86400 */
$conf['cache_lifetime'] = 86400;
$conf['page_cache_maximum_age'] = 86400;
When setting up Varnish's config file (.vcl), just be sure that the syntax you use corresponds to the version of varnish you have installed.

Kohana 3.2 : Error reading session data

I'm working on a module (a simple cms) with Kohana 3.2 and i'm getting this exception "Error reading session data."
I'm using native session and the funny thing is if i set a "default" group database connection the error isn't showed... (i'm using a custom connection group and i've set this database connection group to the user,role and user_token models).
here's my config file
auth.php
return array(
'driver' => 'orm',
'hash_method' => 'sha256',
'hash_key' => 'just a test 1',
'lifetime' => 1209600,
'session_type' => 'native',
'session_key' => 'just a test 2',
// Username/password combinations for the Auth File driver
'users' => array(
// 'luca' => 'e12afe0d3ead3d36191d86229d27057d96d9f2e063fe6f3e86699aaab5310d42'
// 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
),
);
session.php
return array(
'native' => array(
'name' => 'session_native',
'lifetime' => 43200,
),
'cookie' => array(
'name' => 'session_cookie',
'encrypted' => TRUE,
'lifetime' => 43200,
),
'database' => array(
'name' => 'session_database',
'encrypted' => TRUE,
'lifetime' => 43200,
'group' => Pencil::db_group(),
'table' => 'sessions',
'columns' => array(
'session_id' => 'session_id',
'last_active' => 'last_active',
'contents' => 'contents'
),
'gc' => 500,
),
);
You set encrypted to true, so you need an encrypt key. In your config/encrypt.php add this:
<?php
return array(
'default' => array(
'key' => 'MY_RANDOM_KEY_I_MADE_UP_ALL_BY_MYSELF',
),
);
I would keep session_key set to 'auth_user' instead of your random key as well. I think key in that circumstance is not the same as a hash key.
Check your logs in application/logs to see if anything else is missing.

Resources