Patreon access is now given by tier instead of by price paid
This commit is contained in:
@@ -9,8 +9,8 @@ const getIdentity = function(accessToken, callback){
|
||||
Authorization: 'Bearer ' + accessToken,
|
||||
},
|
||||
qs: {
|
||||
'include': 'memberships',
|
||||
'fields[member]': 'currently_entitled_amount_cents',
|
||||
'include': 'memberships.currently_entitled_tiers',
|
||||
'fields[tier]': 'amount_cents,title',
|
||||
}
|
||||
}, callback);
|
||||
};
|
||||
@@ -61,9 +61,18 @@ const updateIdentity = Meteor.wrapAsync(function(accessToken, userId, callback){
|
||||
}
|
||||
try {
|
||||
let identity = JSON.parse(body);
|
||||
let membership = identity.included && identity.included[0];
|
||||
let entitledAmount = membership && membership.attributes
|
||||
.currently_entitled_amount_cents || 0;
|
||||
let entitledAmount = 0;
|
||||
if (identity && identity.included){
|
||||
identity.included.forEach(doc => {
|
||||
if (
|
||||
doc.type === 'tier' &&
|
||||
doc.attributes &&
|
||||
doc.attributes.amount_cents > entitledAmount
|
||||
){
|
||||
entitledAmount = doc.attributes.amount_cents;
|
||||
}
|
||||
});
|
||||
}
|
||||
writeEntitledCents(userId, entitledAmount);
|
||||
if (callback) callback();
|
||||
} catch(error) {
|
||||
|
||||
Reference in New Issue
Block a user