Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

fix: Fix iOS redundant payment error #4163

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ecommerce/extensions/iap/api/v1/ios_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def validate(self, receipt, configuration, basket=None): # pylint: disable=unus
try:
validation_result = validator.validate(
receipt.get('purchase_token', receipt.get('purchaseToken')),
exclude_old_transactions=False # if True, include only the latest renewal transaction
exclude_old_transactions=True # if True, include only the latest renewal transaction
)
except InAppPyValidationError as ex:
# handle validation error
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/extensions/iap/processors/base_iap.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def parse_ios_response(self, response, product_id):
purchases = response['receipt'].get('in_app', [])
for purchase in purchases:
if purchase['product_id'] == product_id and \
response['receipt']['receipt_creation_date_ms'] == purchase['purchase_date_ms']:
response['receipt']['original_purchase_date_ms'] == purchase['original_purchase_date_ms']:

response['receipt']['in_app'] = [purchase]
break
Expand Down
4 changes: 3 additions & 1 deletion ecommerce/extensions/iap/tests/processors/test_ios_iap.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,20 @@ def setUp(self):
'in_app_ownership_type': 'PURCHASED',
'original_transaction_id': 'old_purchase_id',
'product_id': 'org.edx.mobile.test_product3',
'purchase_date_ms': '1676562544000',
'purchase_date_ms': '1676562978000',
'transaction_id': 'old_purchase_id'
},
{
'in_app_ownership_type': 'PURCHASED',
'original_transaction_id': 'original_test_id',
'product_id': self.product_sku,
'purchase_date_ms': '1676562978000',
'original_purchase_date_ms': '1676562978005',
'transaction_id': 'test_id'
}
],
'receipt_creation_date_ms': '1676562978000',
'original_purchase_date_ms': '1676562978005'
}
}
self.transaction_id = self.mock_validation_response['receipt']['in_app'][2]['transaction_id']
Expand Down
Loading