Not redirecting to payment page when payment created - laravel-5.5

I am trying to integrate laravel-mollie in my website using in the example that they are providing the example. When i'm creating new payment it should redirect me to payment page, But its not showing anything.. here is my code:
public function preparePayment($data, $orderId)
{
$payment = Mollie::api()->payments()->create([
'amount' => [
'currency' => 'EUR',
'value' => '100.00', // You must send the correct number of decimals, thus we enforce the use of strings
],
"description" => "My first API payment",
"redirectUrl" => route('mollie.payment.status'),
'webhookUrl' => route('webhooks.mollie'),
"metadata" => [
"order_id" => $orderId,
],
]);
$payment = Mollie::api()->payments()->get($payment->id);
// redirect customer to Mollie checkout page
return redirect($payment->getCheckoutUrl(), 303);
}
I printed the url. which is showing the link. But not redirecting to the payment page. What did i do wrong! can anyone point me out?

The $payment object looks ok, just double check if your param for the redirectUrl is correct.
Also if I'm not mistaken the redirect to an external URL in Laravel should be something like:
...
return redirect()->away($payment->getCheckoutUrl());

Related

How to extract special characters from route in Zend framework 3

I'm sending a url that has special characters in them.
/contacts?advanceSearch=true&advanceSearchType=rating&advanceSearchValue=A1A+
As you see the variable value of advanceSearchValue is A1A+
But when I retrieve this in controller
$this->params()->fromQuery("advanceSearchValue");
it shows me A1A. It adds space instead of +
This is my route config.
"contacts" => [
"type" => "segment",
"options" => [
"route" => "/contacts[/:action[/:id]]",
"defaults" => [
"controller" => Controller\ContactController::class,
"action" => "index",
],
],
],
This is because + has a special meaning in a URL and Zend knows this and correctly replaces it with a space.
To get a + character into the parsed data you need to URL escape it. This gives the value %2B.
So your full URL should be
/contacts?advanceSearch=true&advanceSearchType=rating&advanceSearchValue=A1A%2B
By the way, what is producing this URL, a web browser should be automatically converting the + character before sending it to the web server?
You need to encode your request-url :
You can encode it by php Or Javascript -
In javascript :
var url= "/contacts?advanceSearch=true&advanceSearchType=rating&advanceSearchValue=A1A+";
url= encodeURI(uri);
In php :
$url = urlencode('/contacts?advanceSearch=true&advanceSearchType=rating&advanceSearchValue=A1A+');
Then use this encoded Url in your ajax.

How to set and retrieve cookie in laravel 5.2

I am using laravel 5.2 and I have to create keep me logged in functionality.
I have used below code to set cookie:
$response->withCookie(cookie('email', $request['email'], 60));
for this I have included below namespace:
use Cookie;
After setting cookie I printed response and get something like below:
Response {#1028
+original: ""
+exception: null
+headers: ResponseHeaderBag {#1029
#computedCacheControl: array:1 [
"no-cache" => true
]
#cookies: array:1 [
"" => array:1 [
"/" => array:1 [
"email" => Cookie {#989
#name: "email"
#value: "abc#gmail.com"
#domain: null
#expire: 90012626276.0
#path: "/"
#secure: false
#httpOnly: true
}
]
]
]
But When I try retrieving this cookie using any of below code it returned 'null'
$request->cookie('email');
OR
echo cookie::get('email');
Searching on web didn't helped much as I don't have much time therefore posted it over here.
Also It would be great if someone can explain that would it be fine if I use setcookie php function to set cookie?
My colleague asked me to use laravel specific functions. So I am trying to implement -->
$response->withCookie(cookie('email', $request['email'], 60));
Thanks!!
To set a cookie you should use the following code without calling cookie() function:
$response->withCookie('email', $request['email'], 60);

How to create a user with the Admin Directory api using the google-api-ruby-client?

I've been trying a few combinations but can't seem to come up with something that works. More information about the API I'm asking about can be found here https://developers.google.com/admin-sdk/directory/v1/reference/users/insert . I have a feeling I'm just not setting up the request correctly. The following bit of code is known to work. I use it to set up the client that is able to query all the users.
client = Google::APIClient.new(:application_name => "myapp", :version => "v0.0.0")
client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => "https://www.googleapis.com/auth/admin.directory.user",
:issuer => issuer,
:signing_key => key,
:person => user + "#" + domain)
client.authorization.fetch_access_token!
api = client.discovered_api("admin", "directory_v1")
When I try to use the following code
parameters = Hash.new
parameters["password"] = "ThisIsAPassword"
parameters["primaryEmail"] = "tstacct2#" + domain
parameters["name"] = {"givenName" => "Test", "familyName" => "Account2"}
parameters[:api_method] = api.users.insert
response = client.execute(parameters)
I always get back the same error "code": 400, "message": "Invalid Given/Family Name: FamilyName"
I've observed a few things while looking into this particular API. If I print out the parameters for both the list and the insert functions e.g
puts "--- Users List ---"
puts api.users.list.parameters
puts "--- Users Insert ---"
puts api.users.insert.parameters
Only the List actually displays the parameters
--- Users List ---
customer
domain
maxResults
orderBy
pageToken
query
showDeleted
sortOrder
--- Users Insert ---
This leaves me wondering if the ruby client is unable to retrieve the api and therefore unable to submit the request correctly or if I'm just doing something completely wrong.
I'd appreciate any idea's or direction that might help set me on the right path.
Thank you,
James
You need to supply an Users resource in the request body, which is also the reason why you don't see it in the params.
So the request should look like:
# code dealing with client and auth
api = client.discovered_api("admin", "directory_v1")
new_user = api.users.insert.request_schema.new({
'password' => 'aPassword',
'primaryEmail' => 'testAccount#myDomain.mygbiz.com',
'name' => {
'familyName' => 'John',
'givenName' => 'Doe'
}
})
result = client.execute(
:api_method => api.users.insert,
:body_object => new_user
)

How can I retrieve a user using a query string from drupal using REST?

What I'd like
I want to be able to reset a users password without emailing them. I also need to do this via REST (it's for a kiosk system).
So I need to:
Get user with a specific username
Reset the password of that user
Try as I might, I can't get the user with a username.
The problem
After I've logged in using the admin user via REST I do:
GET on http://mydomain.com/rest/user?name=user.
According to REST documentation, this should get the user with name user.
I get a 200 response, but nothing is returned in the body.
What I've Tried
Get node from ID
Once I've logged in as admin, I can do:
GET on http://mydomain.com/rest/user/1
This works, returning the details of user 1 in the response. But I need to search for a user by username.
Different GETs
GET on http://mydomain.com/rest/user/admin
GET on http://mydomain.com/rest/user/account/name/admin
GET on http://mydomain.com/rest/user?account[name]=admin
GET on http://mydomain.com/rest/user?uid=1
GET on http://mydomain.com/rest/user/retrieve?uid=1
GET on http://mydomain.com/rest/user?account[uid]=1
All these fail.
Nodes instead of users
GET on http://mydomain.com/rest/node/1 works, but http://mydomain.com/rest/node?nid=1 gives me a 200 response with nothing in the body.
List of all users
GET on http://mydomain.com/rest/user/ doesn't show a list of all users either. I get a 200 with empty body again.
Further Details
I'm working with a Drupal 6.22 install.
I've installed the services module (3.0 RC1) and REST Server (2.0 beta 1).
I've got the session authentication module installed.
I've tried the above with the session authentication switched on and with it off.
I've enabled all node resources and user resources for the REST endpoint I've set up.
I've tried the above with and without clean URLs and nothing seems to make a difference.
Question
How do I get a user with a specific username? What am I doing wrong?
Update
I've uninstalled then reinstalled Services module, I've done the same with the REST server. I've also rolled back my version of CTools to the latest recommended one. I've added a brand new service in case it was corrupted. Nothing I do works. Frustrating!
Update 2
I've found the problem, but would like a more permanent solution. It turns out it was an error because of table naming. See my current accepted answer.
Im sorry this is so frustrating for you. Im the maintainer for services module and were really working on the documentation but I thought I would answer here to just get you moving along.
The reason you are not getting any of the data you want is because the parameters you are passing are wrong.
If you look at user_resource.inc index is defined as follows
'index' => array(
'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/user_resource'),
'callback' => '_user_resource_index',
'args' => array(
array(
'name' => 'page',
'optional' => TRUE,
'type' => 'int',
'description' => 'The zero-based index of the page to get, defaults to 0.',
'default value' => 0,
'source' => array('param' => 'page'),
),
array(
'name' => 'fields',
'optional' => TRUE,
'type' => 'string',
'description' => 'The fields to get.',
'default value' => '*',
'source' => array('param' => 'fields'),
),
array(
'name' => 'parameters',
'optional' => TRUE,
'type' => 'array',
'description' => 'Parameters',
'default value' => array(),
'source' => array('param' => 'parameters'),
),
),
'access arguments' => array('access user profiles'),
'access arguments append' => FALSE,
),
Notice the third argument, parameters.
You can do all sorts of fun stuff with the index query as long as it is turned on, but what you havnt tried is ?parameters[name]=user Example below
When I make a request to http://test/api/user?parameters[name]=gdsfgsdfgsdfg&fields=name,uid
I get returned
[
{
"name":"gdsfgsdfgsdfg",
"uid":"36",
"uri":"http:\/\/test\/api\/user\/36"
}
]
Notice i also added some fields, uid and name. Obviously these are optional but it shows you the power of the index query. The same applies to nodes.
I hope this helps.
Try something like:
GET on http://mydomain.com/rest/user?parameters[name]=admin
This worked for me in Drupal7. Not sure if it'll be the same for 6. But I also had no issues with getting the index of all users using GET on http://mydomain.com/rest/user/
I found the issue. It's an error/bug with the Services module in the setup I have.
From the services.module file
449 // Now implode that array into an actual WHERE clause.
450 $where = !empty($where) ? ' WHERE '. implode(' AND ', $where) : '';
451 // Run through db_rewrite_sql to make sure proper access checks are applied.
// **** Error logged for this next line ****
452 $sql = "SELECT $fields FROM {$table} $where ORDER BY $order"; // <-- Error was logged for this line
453 $sql = db_rewrite_sql($sql);
454 $result = db_query_range($sql, $parameters, $page * 20, 20);
455 return $result;
The error
Table '<REDACTED>_drup1.users' doesn't exist query: SELECT * FROM users ORDER BY created DESC LIMIT 0, 20 in /<REDACTED>/sites/all/modules/services/services.module on line 455.
The users table in my installation is called drup_users. When I change line 452 to
452 $sql = "SELECT $fields FROM drup_{$table} $where ORDER BY $order";
It works. I'd be interested in knowing how I can have a more permanent solution. I ran update.php several times and it didn't fix this.

Client of web service in Perl

I am the client - I wish to call methods of a web service.
I have a web service address (.svc suffix) and I have the method's name, return value and their argument.
The service is implemented with WCF (HTML end point). I wish to call those methods by SOAP::Lite. What should I write for the URI, proxy and how exactly do I call the methods?
You set
the proxy to the endpoint and
the uri (or in the most recent version ns) to the namespace in the method definition.
One of the easiest ways to do this is simply to use the WSDL URI and create a SOAP::Schema object with it, like so:
my $schema = SOAP::Schema->new( schema_url => $destination_URL )->parse();
my $services = $schema->services();
And dump those two objects.
You can look for
my $method_def = $service->{ $method_name };
my $uri = $method_def->{namespace};
my $proxy = $method_def->{endpoint}->value();
And use those values, if everything is there.
I had to dig through a lot of SOAP::Lite dumps in order to get my SOAP client architecture working. You should know how to debug and dump Perl objects if you want to shoot all your troubles.
I'll show you an anonymized dump of a service:
$services = {
ServiceName => {
MethodName => {
endpoint => bless( {
_attr => {},
_name => 'location',
_signature => [],
_value => [
# v-- This value you pass to SOAP::Lite->proxy
'http://some.domain.com/WebServices/SOAPEndpoint.asmx'
]
}, 'SOAP::Custom::XML::Data'
),
# v-- This value you pass to uri/default_ns/ns
namespace => 'http://some.domain.com/',
parameters => [ ... ]
...
}
}
};