How to identify when a dwolla transaction has cleared? - dwolla

Right now I'm using a transaction status webhook to update my app when a payment changes status. The other day, my web server was down when the webhook was triggered, so the status was never updated in my system, nor do I have any way to tell when the payment was marked "processed".
From the docs, when a webhook fails, it will immediately try the request another two times, but this is not helpful if my site is down for more than a few seconds.
I'd like to get the status on my own if possible, but there doesn't seem to be any info representing when the transaction was actually marked processed.
I'm guessing the "date" is the date the transaction was initiated and that "clearing date" is just an estimate of when it will be processed (and is not updated to reflect the actual date when the transaction is processed).

If you have a payment's Transaction ID, you can look it up using the Transactions/By ID method.
Which will give you this info about the payment:
{
"Success": true,
"Message": "Success",
"Response": {
"Amount": 1,
"Date": "8/31/2011 10:19:09 AM",
"DestinationId": "812-111-1111",
"DestinationName": "Bob",
"Id": 12345,
"SourceId": "812-111-2222",
"SourceName": "Alice",
"Type": "money_sent",
"UserType": "Dwolla",
"Status": "processed",
"ClearingDate": "",
"Notes": "Thank you for lunch!",
"Fees": [
{
"Id": 1646163,
"Amount": 0.1,
"Type": "Facilitator Fee"
}
]
}
}
The Response.Status field indicates a transaction's current status, which is what you're looking for.
Alternatively, you can use the Transaction/Listing method to list all the recent (and older) transactions under your account, with the same data about them shown above. You can filter the results and specify ranges by playing with the request parameters to narrow your search down and produce a list of transactions that occurred while your server was down.
You're right about the clearing date just being an estimate of when the payment will clear - it's not a guarantee.

Related

Purchase event has been uploaded via Offline Conversions API, but the Event Set does not show any data

I followed the guide here: https://developers.facebook.com/docs/marketing-api/offline-conversions
Unlike "regular" Event Sets, which includes a "Test Events" tab in its dashboard, offline event sets don't seem to have this feature. You must either upload a CSV or call the API.
However, the offline event set shows no data coming from the API at all; the history tab only shows the CSV uploads, which were "last received 10 days ago". It doesn't even include the test upload I made today.
Is this a bug? How long should I wait for the data to appear in the events manager for my offline event?
Sample call
POST https://graph.facebook.com/v15.0/<offline_event_set_id>/events?access_token=<system_user_access_token>
{
"upload_tag": "store_data",
"data": [
{
"match_keys": {
"em": "<hashed>",
"ph": "<hashed>"
},
"currency": "PHP",
"value": 100,
"event_id": "test",
"event_name": "Purchase",
"event_time": "1669633380",
"custom_data": {
"event_source": "in_store"
},
"action_source": "physical_store",
"order_id": "test",
"data_processing_options": []
}
]
}
The response is as follows:
{"id":"<offline_event_set_id>","num_processed_entries":1}
Which seems to indicate that the event was uploaded successfully. But that event never shows up in the Overview tab of that offline event set.
Would appreciate any insights/guides elsewhere/answers, I've spent a few days on this with no success.
The "error": I was encoding the event_time as a string, whereas Facebook expects this value to be an integer. After updating my POST body to correct that, the events started showing up within minutes in the Overview tab.
{
"upload_tag": "store_data",
"data": [
{
"match_keys": {
"em": "<hashed>",
"ph": "<hashed>"
},
"currency": "PHP",
"value": 100,
"event_id": "test",
"event_name": "Purchase",
"event_time": 1669633380, // <-- The only change was removing the quotes
"custom_data": {
"event_source": "in_store"
},
"action_source": "physical_store",
"order_id": "test",
"data_processing_options": []
}
]
}
I really wish Facebook had returned some kind of error or warning, but at least I found the issue. Be careful with your data types, people!

Facebook page insights lifetime metrics doesn't return results

I'm trying to get some insights on page I own, for example page_fans which is stated in https://developers.facebook.com/docs/graph-api/reference/v3.2/insights as having both "day" and "lifetime" periods. (This is NOT the only metric I want to get but for the sake of simplicity I'll give it as an example.)
Getting it by day works, but I only wa
nt to know the lifetime value, so instead of period=day I tried period=lifetime, and I get an empty data array.
This is the request I am sending:
{page_id}/insights?fields=&metric=page_fans&period=lifetime
Note, if I change to period=day I get a nice object:
"data": [
{
"name": "page_fans",
"period": "day",
"values": [
{
"value": 21578,
"end_time": "2019-02-24T08:00:00+0000"
},
{
"value": 21580,
"end_time": "2019-02-25T08:00:00+0000"
}
],
"title": "Lifetime Total Likes",
"description": "Lifetime: The total number of people who have liked your Page. (Unique Users)",
"id": "{page_id}/insights/page_fans/day"
}
],
Other metrics I want to get lifetime data for include:
"post_video_view_time_by_region_id",
"post_video_views_by_distribution_type",
"post_video_view_time_by_distribution_type",
"post_video_view_time_by_country_id"
According to the changelog for v3.2
Page Insights
These changes apply to v3.2+, and will apply to all versions on January 21, 2019.
Period parameters have been changed to day from lifetime for
the following metrics. The lifetime period parameter will return
an empty dataset.
page_fans
page_fans_city
page_fans_country
page_fans_gender_age
page_fans_locale
You can use /insights?metric=page_fans&date_preset=maximum

Flawless transfer on PayPal classic does nothing

Everyhing works flawlessly with my PayPal classic implementation in the sandbox. (Marked as deprecated from jan 17 but still supported.) But it simply does not transfer money from the customer to the merchant.
"payment": {
"intent": "sale",
"transactions": [
{
"amount": {
"total": "1.21",
"currency": "EUR",
"details": {
"subtotal": "1.08",
"tax": "0.02",
"handling_fee": "0.11"
}
},
"description": "Description content."
}
]
}
After the customer agrees and executes the payment I receive an authorization:
"onAuthorize": {
"paymentToken": "EC-024873345P059811F",
"orderID": "EC-024873345P059811F",
"payerID": "4M6QNG7UDS626",
"paymentID": "PAY-7W7465253T270972NLO5EG6A",
"intent": "sale",
"returnUrl": "https://www.sandbox.paypal.com/?paymentId=PAY-7W7465253T270972NLO5EG6A&token=EC-024873345P059811F&PayerID=4M6QNG7UDS626"
}
I expect that the money transfer took place but nothing shows. No transactions, no errors, no nothing. As if nothing happened. I also expect that I get a notification if the transaction is not executed due to its deprecation. That is not the case. I am clueless.
I wasn't using the deprecated classic after all but the new Client Side Rest: https://developer.paypal.com/demo/checkout/#/pattern/client
It is close to classic, I only needed to add ...
return actions.payment.execute();
Then the actual transfer takes place. I am a happy coder now.

REST: update a resource with different fields requiring different user permissions

I have an endpoint /groups
I can create a group by POSTing some info to /groups
A single group can be read by /groups/{id}
I can update some fields in the group by POSTing to /group/{id}
HOWEVER I have different fields that are needed to be updated by users with different permissions, for instance: A group might have the structure
{
"id": 1,
"name": "some name",
"members": [
{
"user_id": 456,
"known_as": "Name 1",
"user": { /* some user object */},
"status": "accepted",
"role": "admin",
"shared": "something"
},
{
"user_id": 999227,
"known_as": "Name 1",
"user": { /* some user object */},
"status": "accepted",
"role": "basic",
"shared": "something"
},
{
"user_id": 9883,
"known_as": "Name 1",
"user": { /* some user object */},
"status": "requested",
"role": "basic",
"shared": "something"
}
],
"link": "https://some-link"
}
As an example I have the following 3 operations for the /group/{id}/members/{id} endpoint:
I want only the user to be able to update his own known_as field
I want only group admins to be able to update each member's role and status fields.
I want both the user and the admin to be able to update the shared field
My options are this:
Should I allow all updates to be done by POSTing to /group/{id}/members/{id} with a subset of the fields for a member and throw an unauthorized error if they try to update a field that they aren't allowed to update?
Or should I break each operation into say /group/{id}/members/{id}/role, /group/{id}/members/{id}/shared and /group/{id}/members/{id}/status? The problem with this is that I don't want to have to make lots of requests to update all the fields (I imagine that there will end up being quite a lot of them).
So just for clarification my question is: Is it considered proper REST to do my option 1 where I can post updates to an endpoint that may fail if you try to change a field that you aren't allowed to?
In my opinion, option 1 is much better than option 2.
As you said option 2 is a waste of bandwidth.
More importantly, with option 1 you can easily implement an atomic update (update "all-or-nothing"). It should either complete successfully or fail entirely. There should never be a partial update.
With option 2 it's very likely the update can be implemented to complete some request successfully and reject another request, even if the two requests are considered a single operation.

Facebook Marketing API Campaign spend_cap field returns inconsistently

I'm trying to pull data for each of my Ad Campaigns from the Facebook Marketing API.
In the Ads Insights API there is only a 'spend' field that returns how much of the budget for that campaign has been spent so within the specified date range parameter. This is documented at
developers.facebook.com/docs/marketing-api/insights/fields/v2.9
I would like to get the 'spend_cap' field that's specified in the Reference section of the Marketing API located in the link below. One thing I noted was that there are no parameters available to this node, that may be why the spend_cap is not returning. This is documented at
developers.facebook.com/docs/marketing-api/reference/ad-campaign-group
I am using the following url to request the data.
https://graph.facebook.com/v2.9/{act_id}/campaigns?fields=name,spend_cap&access_token={access_token}
However, it returns the spend_cap field inconsistently, as shown below. I've only included a couple examples but I'm certain that all my campaigns are set up with spending caps.
data:[
{
"id": "##############",
"name": "name1",
"start_time": "2016-06-24T14:47:34-0400",
"stop_time": "2016-07-03T14:47:34-0400"
},
{
"id": "##############",
"name": "name2",
"spend_cap": "30000",
"start_time": "2016-05-16T11:57:10-0400"
},
{
"id": "##############",
"name": "name3",
"spend_cap": "15000",
"start_time": "2016-05-16T11:44:06-0400",
"stop_time": "2017-04-01T00:00:00-0400"
},
{
"id": "##############",
"name": "name4",
"start_time": "2016-05-13T15:34:41-0400",
"stop_time": "2017-05-13T09:46:44-0400"
}
]
The spend_cap at the campaign level is an optional field which is why it is only returned for some of the campaigns.
In general within the Graph API, if a field contains no data, this field will be omitted from the response.
Our SDKs abstract this for you so you can always access a field of an object, regardless of whether it was in the response, so if you're not using one of our SDKs, you'll have to do the same.