Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mobile_b2c(self, product_name, consumers, callback=None):
reasons = PaymentService.REASON.values()
schema = Schema([
{
'name': And(str, len),
'phoneNumber': And(str, lambda s: validate_phone(s)),
'currencyCode': And(str, lambda s: len(s) == 3),
'amount': And(lambda f: float(f) > 0),
Optional('providerChannel'): And(str, len),
Optional('reason'): And(str, lambda s: s in reasons),
Optional('metadata'): And(dict)
}
])
consumers = schema.validate(consumers)
url = self._make_url('/mobile/b2c/request')
headers = dict(self._headers)
headers['Content-Type'] = 'application/json'
data = json.dumps({