Skip to content

PB-22e: stripe database functionality - #57

Draft
stianjsu wants to merge 9 commits into
PB-22-add-payment-info-stripefrom
pb-22e-stripe-database-functionality
Draft

PB-22e: stripe database functionality#57
stianjsu wants to merge 9 commits into
PB-22-add-payment-info-stripefrom
pb-22e-stripe-database-functionality

Conversation

@stianjsu

@stianjsu stianjsu commented Oct 16, 2023

Copy link
Copy Markdown
Collaborator

Adds stripe customer table in a 1:1 relationship with a slack_organization.

Contains fields:

  • customer_id (from stripe)
  • team_id (slack_org/workspace)
  • created_at
  • is_premium (boolean)
  • premium_from
  • premium_to

Run the backend docker container and in its terminal run flask db upgrade to run the migration

image

@stianjsu
stianjsu marked this pull request as draft October 16, 2023 21:32
@stianjsu

Copy link
Copy Markdown
Collaborator Author

possible name conflict, backend gets stacktrace. Draft until fixed

Comment thread application/backend/app/services/stripe_customer_service.py
Comment thread application/backend/app/models/stripe_customer.py Outdated
Comment thread application/backend/app/services/stripe_customer_service.py
Comment thread application/backend/app/services/stripe_customer_service.py
Comment thread application/backend/app/services/stripe_customer_service.py
@stianjsu
stianjsu marked this pull request as ready for review October 19, 2023 09:46
@stianjsu
stianjsu requested a review from JacobTheisen October 19, 2023 09:47

@JacobTheisen JacobTheisen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm🚀🚀

update: trekker det midlertidig tilbake

@JacobTheisen JacobTheisen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Får en bug i StripeCustomerRepository.get_by_id(customer_id) i get_by_customer_id() i update i stripe_customer_service. Hverken jeg eller gjengen i chatgpt har helt skjønt hva den kommer fra enda.

Eksempelet:

                stripe_customer:StripeCustomer = stripe_service.get_by_customer_id(stripe_customer_id)

                stripe_customer.is_premium = True

                stripe_customer_dict = stripe_customer.__dict__
                print(type(stripe_customer_dict))
                print(stripe_customer_dict)

                stripe_customer_dict.pop("_sa_instance_state", None)
                stripe_customer_dict['created_at'] = stripe_customer_dict['created_at'].isoformat()

                try:
                    t = stripe_service.update(data=stripe_customer_dict, customer_id=stripe_customer.customer_id)
                except Exception as e:
                    print(e)

gir:
StripeCustomerRepository' object has no attribute '_sa_instance_state'

Mulig å se i pb-22d-stripe-webhook-functionality for mer logs og mer fullstendig eksempel.

Kan det komme av noe feil med migrations? (var jo noe knot der)

@stianjsu

Copy link
Copy Markdown
Collaborator Author

Får en bug i StripeCustomerRepository.get_by_id(customer_id) i get_by_customer_id() i update i stripe_customer_service. Hverken jeg eller gjengen i chatgpt har helt skjønt hva den kommer fra enda.

Eksempelet:

                stripe_customer:StripeCustomer = stripe_service.get_by_customer_id(stripe_customer_id)

                stripe_customer.is_premium = True

                stripe_customer_dict = stripe_customer.__dict__
                print(type(stripe_customer_dict))
                print(stripe_customer_dict)

                stripe_customer_dict.pop("_sa_instance_state", None)
                stripe_customer_dict['created_at'] = stripe_customer_dict['created_at'].isoformat()

                try:
                    t = stripe_service.update(data=stripe_customer_dict, customer_id=stripe_customer.customer_id)
                except Exception as e:
                    print(e)

gir: StripeCustomerRepository' object has no attribute '_sa_instance_state'

Mulig å se i pb-22d-stripe-webhook-functionality for mer logs og mer fullstendig eksempel.

Kan det komme av noe feil med migrations? (var jo noe knot der)

hmm, ja kk. Håper dette ikke er en case av "dette funker på min maskin". Jeg skal sjekke det ut, men får nok ikke tid til det før onsdag

@stianjsu
stianjsu requested a review from JacobTheisen November 4, 2023 17:29
Comment thread application/backend/app/services/stripe_customer_service.py Outdated

@annabjorgo annabjorgo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏👏👏 bra jobba!

@sergiosja sergiosja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM sjef 🚀 bare en liten ting jeg undret på👇🏼



class StripeCustomerRepository(StripeCustomer, CrudMixin):
pass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvorfor trenger vi klassen om den ikke gjør noe? Fungerer den som et slags tomt mellomlag?

@stianjsu

Copy link
Copy Markdown
Collaborator Author

Error with foreign key constraint on delete. Moving to draft for now
image

@stianjsu
stianjsu marked this pull request as draft November 16, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants