def RecordSubscription(client, obj_store, user_id, device_id, request, callback):
 def _OnRecord(verify_response, op):
  callback({'subscription': Subscription.CreateFromITunes(user_id, verify_response).MakeMetadataDict()})
 def _OnVerify(environment, verify_response):
  if ((environment == 'prod') and (verify_response.GetStatus() == VerifyResponse.SANDBOX_ON_PROD_ERROR)):
   ITunesStoreClient.Instance('dev').VerifyReceipt(receipt_data, partial(_OnVerify, 'dev'))
   return
  if (not verify_response.IsValid()):
   logging.warning('record_subscription: invalid signature; request: %r', request)
   raise web.HTTPError(400, 'invalid receipt signature')
  if (environment == 'prod'):
   op_request = {'headers': request['headers'], 'user_id': user_id, 'verify_response_str': verify_response.ToString()}
   Operation.CreateAndExecute(client, user_id, device_id, 'Subscription.RecordITunesTransactionOperation', op_request, partial(_OnRecord, verify_response))
  else:
   callback({'subscription': Subscription.CreateFromITunes(user_id, verify_response).MakeMetadataDict()})
 receipt_data = base64.b64decode(request['receipt_data'])
 ITunesStoreClient.Instance('prod').VerifyReceipt(receipt_data, partial(_OnVerify, 'prod'))

def RecordSubscription ( client , obj_store , user_id , device_id , request , callback ) : def _OnRecord ( verify_response , op ) : callback ( { 'subscription' : Subscription . CreateFromITunes ( user_id , verify_response ) . MakeMetadataDict ( ) } ) def _OnVerify ( environment , verify_response ) : if ( ( environment == 'prod' ) and ( verify_response . GetStatus ( ) == VerifyResponse . SANDBOX_ON_PROD_ERROR ) ) : ITunesStoreClient . Instance ( 'dev' ) . VerifyReceipt ( receipt_data , partial ( _OnVerify , 'dev' ) ) return if ( not verify_response . IsValid ( ) ) : logging . warning ( 'record_subscription: invalid signature; request: %r' , request ) raise web . HTTPError ( 400 , 'invalid receipt signature' ) if ( environment == 'prod' ) : op_request = { 'headers' : request [ 'headers' ] , 'user_id' : user_id , 'verify_response_str' : verify_response . ToString ( ) } Operation . CreateAndExecute ( client , user_id , device_id , 'Subscription.RecordITunesTransactionOperation' , op_request , partial ( _OnRecord , verify_response ) ) else : callback ( { 'subscription' : Subscription . CreateFromITunes ( user_id , verify_response ) . MakeMetadataDict ( ) } ) receipt_data = base64 . b64decode ( request [ 'receipt_data' ] ) ITunesStoreClient . Instance ( 'prod' ) . VerifyReceipt ( receipt_data , partial ( _OnVerify , 'prod' ) )
records an external subscription .