Square connect ID vs TRANSACTION_ID? - square-connect

When Square payment is successful there are two IDs returned:
[id:protected] => 0cb1f61b-0f17-53b6-5048-58266ada510c
[transaction_id:protected] => 8f753779-ae34-5d7f-5e53-376022545a37
assuming the "transaction_id" is what it says - what is "id" for then?
is there a better way to retrieve the transaction id (please see below)?
$result['transaction']->getId();
Thank you very much

Are you looking at a tender or a refund? There are some objects that have their individual id's, and also display the transaction id that they are associated with.
You likely want to do something like
$result->getTransaction()->getId();

Related

Filter observable by key

I am trying to filter a list of observables based on whether a parent key contains a specific child key. The parent key is Supplier, each Supplier has a list of child keys representing Users. The following code works, except that it returns every Supplier that contains any child User keys - not just Suppliers that contain the specific User key (FBKey).
I realise the current filter condition is a bit silly, but it is just where I am at after much fiddling and looking on the web.
userIsSupplierAdministrator(FBKey: number): Observable<Supplier[]> {
const suppliers$ = this.af.database.list('supplier-administrators');
return suppliers$
.filter(supplier => !isUndefined(this.af.database.object(`suppliers/${supplier.$key}/${FBKey}`)))
.map(supplier => supplier.map(supp => this.af.database.object(`suppliers/${supp.$key}`)))
.flatMap(supplierObs => Observable.combineLatest(supplierObs))
.map(Supplier.fromJsonList);
}
I would really appreciate any suggestions on how to structure the filter so that it only returns Suppliers that contain the specific child key (FFBKey).
I am using Angular/Typescript/Firebase.
Regards Sean
I request you to go through this question, you will able to solve your problem.
The problem you have that is not related to the observables you are trying to fix the normal javascript problem.
The approach would be
get the json response from the observable
and filter the json using the below concepts
Filter the value in object when the keys differ in an array

Laravel pagination using infinite scroll

Can anyone help me by pointing me in the right direction on how to implement an infinite scroll in Laravel?
I'm familiar with Laravel's pagination tool and I'm also familiar with Javascript.
I just can't figure out what should i send via ajax to my controller?
By that i mean what url parameters and how would that dynamically change on scrolling?
Thanks in advance.
you do not have to send via ajax something special
just grab via JS the id of last post which already have been loaded and perform ajax.get to http://example.com/foo/100500
catch id in routes.php something like this Route::get('foo/{id}', 'BazController#bar'
then perform any logic in your controller as you wish just considering the id
for example select from database where id between id and id+20
UPDATED
considering #ugochimbo 's question
Let's say when we GET our page first time, we obtain something like
<div id="container">
<div id="post-30">Lorem impum dolor</div>
<div id="post-29">Lorem impum dolor</div>
<div id="post-28">Lorem impum dolor</div>
</div>
An event is happened e.g. ( scrollTop is more than some px )
Then we execute something like
Hey, jQuery! Gimme "id" of the last child of the #container //it will
be "post-28"
Considering the id, we perform an ajax query to a server.
I assume that for the simpliest implementation of infinity scrolling, we have to know just the "id" on the client side, nothing else.
Of course, in any real cases there is also a bunch of additional information, such as DESC or ASC or whatever else. It's all up to you.
Let's say we obtained on the server side via ajax query
{lastLoadedPostId: 'post-28', order: 'DESC', postsPerQuery: 3}
Of course, we have to make some preparations e.g. Cut "post-" from "lastLoadedPostId" etc
Then we ask our database
Hey, database! Gimme 3 posts, that have id less than 28, in desc order
If nonIncremental identificators are used in your database, and you obtain on the server side
{lastLoadedPostId: 'qwertyuid', order: 'DESC', postsPerQuery: 3}
In that case you should perform one extra query to database
Hey, database! Tell me when "qwertyuid" was created
Hey, database! Gimme 3 posts that were created earlier than "timestamp
of qwertyuid"
For this purpose you may use commands like LIMIT, OFFSET or whatever your database provided, but it's already other question

How to best create sorted sets with Redis

I'm still a bit lost when it comes to Sorted Sets and how to best construct them. Currently I have a simple set of activity on my site. Normally it will display things like User Followed, User liked, User Post etc. The JSON looks something like...
id: 2808697,
activity_type: "created_follower",
description: "Bob followed this profile",
body: null,
user: "Bob",
user_id: 99384,
user_profile_id: 233007,
user_channel_id: 2165811,
user_cube_url: "bob-anerson",
user_action: "followed this profile",
buddy: "http://s3.amazonaws.com/stuff/ju-logo.jpg",
affected: "Bill Anerson is following Jon Denver.",
created_at: "2014-06-24T20:34:11-05:00",
created_ms: 1403660051902,
profile_id: 232811,
channel_id: 2165604,
cube_url: "jondenver",
type: "profiles",
So if the activity type can be multiple things (IE Created Follow, Liked Event, Posted News, ETC) how would I go about putting this all in a sorted set? I'm already sure I want the score to be the created_ms but the question is, can I do multiple values in a sorted set that all have keys as fields? Should most of this be in a hash? I realize this is a fairly open question but after trying to wrap my head around all the tutorials Im just concerned about setting up the data structure before had so I dont get caught to deep in the weeds.
A sorted set is useful if you want to... keep stuff sorted! ;)
So, I assume you're interested in keeping the activities sorted by their creation time (ms). As for storing the actual data, you have two options:
Use the sorted set itself to store the data, even in native JSON format. Note that with this approach you'll only be able to fetch the entire JSON and you'll have to parse it at the client.
Alternatively, use the sorted to store "pointers" to hashes - i.e. the values will be key names in which you'll store the data. From your description, this appears the preferable approach.

Parse.com : PFRelation With accept or denied

Hello everyone I would like to know if it 'possible to create pfrelation inserting a chance' to accept or reject the report. P.S. I am following message destructive app thanks
Ps I'm using parse.com
This is an instance where you would need to create a join table/class manually, e.g.:
[SubmittedProjects]
SubmittedBy: relation->User
SubmittedTo: relation->User
Project: relation->Project
Status: string ("pending", "approved", "rejected")
You could then easily find all records given a number of parameters, e.g.
All projects waiting for my approval:
SubmittedTo = me
Status = "pending"
People I need to nag to approve/reject my projects:
SubmittedFrom = me
Status = "pending"
List of all approved projects:
Status = "approved"
Hmm, thinking about it now, these could just be extra fields on your Project table if you only have need of one record for each project.
Your question has very little information so please expand it if this isn't what you meant.

Twitter Ruby Gem - get friends names and ids, nothing more

Is it possible to simply get the people you are following with just an id and full name? I do not need any of the additional data, it's a waste of bandwidth.
Currently the only solution I have is:
twitter_client = Twitter::Client.new
friend_ids = twitter_client.friend_ids['ids']
friends = twitter_client.users(friend_ids).map { |f| {:twitter_id => f.id, :name => f.name} }
is there anyway to just have users returned be an array of ids and full names? better way of doing it than the way depicted above? preferably a way to not filter on the client side.
The users method uses the users/lookup API call. As you can see on the page, the only param available is include_entities. The only other method which helps you find users has the same limitation. So you cannot download only the needed attributes.
The only other thing I'd like to say is that you could directly use the friends variable, I don't see any benefit of running the map on it.

Resources