# Generated by Django 2.1.7 on 2019-03-08 22:38

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='CardIdentifier',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
                ('first_name', models.CharField(max_length=100, verbose_name='First name')),
                ('last_name', models.CharField(max_length=100, verbose_name='Last name')),
                ('billing_address_1', models.CharField(max_length=255, verbose_name='Billing address 1')),
                ('billing_address_2', models.CharField(blank=True, max_length=255, null=True, verbose_name='Billing address 2')),
                ('billing_city', models.CharField(max_length=255, verbose_name='Billing city')),
                ('billing_country', models.CharField(choices=[('IE', 'Ireland'), ('GB', 'United Kingdom'), ('US', 'United States')], max_length=2, verbose_name='Billing country')),
                ('billing_postal_code', models.CharField(blank=True, help_text='Required for all countries except Ireland', max_length=12, null=True, verbose_name='Billing Postal/Zip Code')),
                ('billing_state', models.CharField(blank=True, choices=[('AL', 'Alabama')], help_text='Required only if country is United States', max_length=2, null=True, verbose_name='Billing state')),
                ('merchant_session_key', models.CharField(help_text='The merchant session key that was used to register the card identifier with Sage Pay.', max_length=100, verbose_name='Merchant session key')),
                ('card_type', models.CharField(help_text='The type of card reported by Sage Pay.', max_length=255, verbose_name='Card type')),
                ('last_four_digits', models.CharField(help_text='The last four digits of the card.', max_length=4, verbose_name='Last four digits')),
                ('expiry_date', models.CharField(help_text='The expiry date of the card, format "MMYY".', max_length=4, verbose_name='Expiry date')),
                ('card_identifier', models.CharField(help_text='The card identifier key sent back from Sage Pay.', max_length=100, verbose_name='Card identifier')),
                ('card_identifier_expiry', models.DateTimeField(help_text='The datetime in which a transaction must be submitted to Sage Pay by before the card identifier becomes invalid.', verbose_name='Card identifier expiry')),
            ],
        ),
        migrations.CreateModel(
            name='Transaction',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated at')),
                ('type', models.CharField(choices=[('Payment', 'Payment'), ('Deferred', 'Deferred'), ('Repeat', 'Repeat'), ('Refund', 'Refund')], help_text='Type of transaction, e.g "Payment".', max_length=8, verbose_name='Type')),
                ('vendor_tx_code', models.CharField(default=uuid.uuid4, help_text='The unique vendor tx code used for the transaction.', max_length=40, unique=True, verbose_name='Vendor tx code')),
                ('amount', models.IntegerField(help_text='The amount charged in the smallest currency unit. e.g 100 pence to charge £1.00.', verbose_name='Amount')),
                ('currency', models.CharField(choices=[('GBP', 'Pound Sterling')], help_text='Currency of transaction, e.g "Pounds Sterling".', max_length=3, verbose_name='Currency')),
                ('description', models.TextField(help_text='Description used against the transaction on Sage Pay.', verbose_name='Description')),
                ('status_code', models.CharField(blank=True, help_text='The current status code of the transaction on Sage Pay.', max_length=4, null=True, verbose_name='Status code')),
                ('status', models.CharField(blank=True, help_text='The current status of the transaction on Sage Pay.', max_length=50, null=True, verbose_name='Status')),
                ('status_detail', models.CharField(blank=True, help_text='The current status detail of the transaction on Sage Pay.', max_length=255, null=True, verbose_name='Status detail')),
                ('transaction_id', models.CharField(blank=True, help_text='The transaction id on Sage Pay.', max_length=36, null=True, verbose_name='Transaction id')),
                ('retrieval_reference', models.CharField(blank=True, help_text='Sage Pay unique Authorisation Code for a successfully authorised transaction. Only present if status is Ok.', max_length=20, null=True, verbose_name='Retrieval reference')),
                ('bank_authorisation_code', models.CharField(blank=True, help_text='The authorisation code returned from the merchant bank.', max_length=20, null=True, verbose_name='Bank authorisation code')),
                ('acs_url', models.URLField(blank=True, help_text='The url to redirect to for a transaction that requires 3-D authentication.', null=True, verbose_name='Acs url')),
                ('pareq', models.TextField(blank=True, help_text='A Base64 encoded, encrypted message that contains the transaction details. This needs to be passed to the issuing bank as part of the 3-D Secure authentication.', null=True, verbose_name='Pareq')),
                ('pares', models.TextField(blank=True, help_text='A Base64 encoded, encrypted message sent back by the issuing bank to your TermUrl at the end of the 3-D Secure authentication process.', null=True, verbose_name='Pares')),
                ('secure_status', models.CharField(blank=True, help_text='The 3-D Secure status of the transaction, if applied.', max_length=50, null=True, verbose_name='Secure status')),
                ('instruction', models.CharField(blank=True, db_index=True, help_text='The instruction to either release, abort or void a transaction.', max_length=10, null=True, verbose_name='Instruction')),
                ('instruction_created_at', models.DateTimeField(blank=True, help_text='The date in which the instruction was requested.', null=True, verbose_name='Instruction created at')),
                ('card_identifier', models.ForeignKey(help_text='The card identifier used for the transaction.', on_delete=django.db.models.deletion.PROTECT, related_name='transactions', to='sagepaypi.CardIdentifier', verbose_name='Card identifier')),
                ('reference_transaction', models.ForeignKey(blank=True, help_text='The referring transaction used when a "Repeat" transaction.', null=True, on_delete=django.db.models.deletion.CASCADE, to='sagepaypi.Transaction', verbose_name='Reference transaction')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='TransactionResponse',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
                ('step', models.CharField(max_length=100, verbose_name='Step')),
                ('status_code', models.IntegerField(null=True, verbose_name='Status code')),
                ('data', django.contrib.postgres.fields.jsonb.JSONField(default=dict, verbose_name='Data')),
                ('transaction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='responses', to='sagepaypi.Transaction', verbose_name='Transaction')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
    ]
