一个django应用程序,为信用卡提供数据库和表单字段。
django-credit-cards的Python项目详细描述
Django信用卡
一个django应用程序,为信用卡提供数据库和表单字段。
兼容性
django
>;=1.8python
>;=3
快速启动
安装Django信用卡:
pip install django-credit-cards
然后将其添加到您的模型中:
fromcreditcards.modelsimportCardNumberField,CardExpiryField,SecurityCodeFieldclassPayment(models.Model):cc_number=CardNumberField(_('card number'))cc_expiry=CardExpiryField(_('expiration date'))cc_code=SecurityCodeField(_('security code'))
或您的表格:
fromcreditcards.formsimportCardNumberField,CardExpiryField,SecurityCodeFieldclassPaymentForm(forms.Form):cc_number=CardNumberField(label='Card Number')cc_expiry=CardExpiryField(label='Expiration Date')cc_code=SecurityCodeField(label='CVV/CVC')
信用卡类型检测
fromcreditcardsimporttypesasserttypes.get_type('4444333322221111')==types.CC_TYPE_VISAasserttypes.get_type('343434343434343')==types.CC_TYPE_AMEXasserttypes.get_type('0000000000000000')==types.CC_TYPE_GENERIC
许可证
版权所有(c)2018 Mihail Mishakin根据BSD许可证发布(见许可证)