How to use the africastalking.Payment.PaymentService.REASON.values function in africastalking

To help you get started, we’ve selected a few africastalking examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AfricasTalkingLtd / africastalking-python / africastalking / Payment.py View on Github external
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({