Esempio n. 1
0
def create_paystack_customer(sender, instance, *args, **kwargs):
    customer = Customer.create(
        first_name=instance.first_name,
        last_name=instance.last_name,
        email=instance.email,
        phone=instance.phone,
    )
    def test_create(self):
        """Method defined to test customer creation."""
        httpretty.register_uri(
            httpretty.POST,
            "https://api.paystack.co/customer",
            content_type='text/json',
            body='{"status": true, "contributors": true}',
            status=201,
        )

        response = Customer.create(
            first_name='samuel', last_name='james',
            email='*****@*****.**', phone='00000000000')
        self.assertTrue(response['status'])
Esempio n. 3
0
    def test_create(self):
        """Method defined to test customer creation."""
        httpretty.register_uri(
            httpretty.POST,
            self.endpoint_url("/customer"),
            content_type='text/json',
            body='{"status": true, "contributors": true}',
            status=201,
        )

        response = Customer.create(first_name='samuel',
                                   last_name='james',
                                   email='*****@*****.**',
                                   phone='00000000000')
        self.assertTrue(response['status'])
    def test_create(self):
        """Method defined to test customer creation."""
        with mock.patch('paystackapi.customer.Customer.create') as mock_create:
            mock_create.return_value = {
                'status': True, 'message': 'Customer created',
                'data': {'customer_code': 'CUS_jemg85nfijhrp1s',
                         'first_name': 'samuel', 'last_name': 'james',
                         'domain': 'test', 'integration': 100384,
                         'phone': '00000000000',
                         'updatedAt': '2016-02-12T12:25:19.960Z',
                         'id': 4013, 'email': '*****@*****.**',
                         'createdAt': '2016-02-12T12:25:19.960Z'}
            }

            response = Customer.create(
                'samuel', 'james', '*****@*****.**', '00000000000')
            self.assertTrue(response['status'])