node-apple-receipt-verify
node-apple-receipt-verify copied to clipboard
Provide access to unmodified validated receipt object
Thanks for this package! I'm transitioning to this from an older alternative. I have large numbers of legacy records in my DB that use elements of Apple's receipt scheme as-is. However, currently the package renames various fields in the products
response object, e.g. transaction_id
becomes transactionId
.
While I can understand why you would do that stylistically, it would be useful to be able to access the parsed validated receipt object without any modifications, i.e. as shown in the debug line <Apple> Sandbox validation successful: {...}
when verbose is enabled.
(If there's already a way to access that, then I guess I missed it.)
Were you able to find a way to achieve this @stephent?
@michaelbutler1998 after digging around in my source code, I found I wrote this to work around it 🙄
const reverseFieldMapping = {
bundleId: 'bundle_id',
productId: 'product_id',
transactionId: 'transaction_id',
originalTransactionId: 'original_transaction_id',
purchaseDate: 'purchase_date_ms',
isTrialPeriod: 'is_trial_period',
originalPurchaseDate: 'original_purchase_date_ms',
applicationVersion: 'application_version',
originalApplicationVersion: 'original_application_version',
webOrderLineItemId: 'web_order_line_item_id'
}
function withOriginalFieldNames(product) {
let result = {}
for (const property in product) {
if (reverseFieldMapping[property]) {
result[reverseFieldMapping[property]] = product[property];
} else {
result[property] = product[property];
}
}
return result;
}
While there are more generic approaches, this seemed a slightly more controlled hack.
Thank you that's helpful!
If the purchase has expired, the plugin does not return any information about the purchase as no product is returned, but the log can see this information. I thought you might have come across this as you're working with legacy records
Do you know if I am missing a setting here? Or will this require adjustments to the library