Suggestion
I would like to suggest a new API endpoint that provides a history of charges for your campaign.
Background
Currently you get data like this:
https://api.patreon.com/oauth2/api/campaigns/XXXX/pledges
{
"attributes": {
"amount_cents": 2000,
"created_at": "2017-06-28T03:46:43.822702+00:00",
"declined_since": "2017-07-09T13:15:50+00:00",
"patron_pays_fees": false,
"pledge_cap_cents": 2000
},
"id": "XXX",
...
}
With this API, you can kind of reverse engineer that the above user has had no successful payments, if you wait until the 5th of the month or so when payments are complete. That requires a number of assumptions about when charges are attempted, and you can’t grant rewards as charges are made (you have to wait until all charges are done for the month to know for sure there was a decline).
In the case of a successful payment:
{
"attributes": {
"amount_cents": 500,
"created_at": "2017-06-10T11:15:45.253492+00:00",
"declined_since": null,
"patron_pays_fees": false,
"pledge_cap_cents": 500
},
"id": "YYY",
...
}
You don’t actually know for sure that a payment was charged, just that one hasn’t been declined. If you wait long enough, it’s probably safe to trust this data, but again, there’s a lot of assumptions involved.
Business Justification
I have an external website that uses the OAuth integration to link our accounts with customers’ Patreon accounts. Currently I am using the CSV export to determine charge status each month and sync the user database based on Patreon e-mail. This technique is fine, however, it has these down sides:
- Manual CSV process means chance for error (uploading wrong CSV to backend, etc)
- Works okay for once-per-month syncs, but patrons want offsite rewards right away. Even as a small dev, I already have had four requests in the past month to switch to instant-charge as users want the offsite rewards instantly.
- Customers have to wait until a human is available to do the CSV upload.
Suggested Charge History API Example
https://api.patreon.com/oauth2/api/campaigns/XXXX/chargeHistory
Parameters: An optional parameter will limit the history of charges to the most recent X days. For performance, this could default to 90 days, but ideally a full history could be requested. Pagination could also be supported for large Patreon projects.
[
{
"patron_id": "YYY",
"history": [{
"amount_cents": 2000,
"attempted_on": "2017-07-01T03:46:43.822702+00:00",
"result": "CHARGED"
},
{
"amount_cents": 2000,
"attempted_on": "2017-06-01T03:46:43.822702+00:00",
"result": "CHARGED"
},
{
"amount_cents": 2000,
"attempted_on": "2017-05-01T03:46:43.822702+00:00",
"result": "CHARGED"
}
]
},
{
"patron_id": "XXX",
"history": [{
"amount_cents": 2000,
"attempted_on": "2017-07-01T03:46:43.822702+00:00",
"result": "DECLINED"
}]
}
]
Possible charge results: CHARGED, DECLINED, PENDING, CHARGEBACK, etc
Thank you for your consideration.