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

Commit

Permalink
feat: Fix iOS redundant payment error (#4163)
Browse files Browse the repository at this point in the history
LEARNER-9999
  • Loading branch information
jawad-khan authored May 20, 2024
1 parent 5d62a7b commit c211842
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit c211842

Please sign in to comment.