-
Notifications
You must be signed in to change notification settings - Fork 0
Karim camara/payment integration #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
KarimJC
wants to merge
8
commits into
main
Choose a base branch
from
Karim-Camara/Payment-Integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0dff6eb
Created stripe client and tests. Also started working on db intergration
KarimJC 25cf6c7
Integrated account creation into orgnaizations and org fixed tests
KarimJC 8561617
refactored event occurrences to include price
KarimJC ef788e1
Fixing tests, added functionality for guardians and payment methods
KarimJC 74f8a2d
Added stripe client interface and fixed guardian tests
KarimJC b809828
added tests for guardian payment methods and payment method routes
KarimJC c211054
tests pass except for Stripe tests - a lot of functionality needs man…
KarimJC eefcc7c
removed current_branch and cli-latest
KarimJC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package models | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/google/uuid" | ||
| ) | ||
|
|
||
| type GuardianPaymentMethod struct { | ||
| ID uuid.UUID `json:"id" db:"id"` | ||
| GuardianID uuid.UUID `json:"guardian_id" db:"guardian_id"` | ||
| StripePaymentMethodID string `json:"stripe_payment_method_id" db:"stripe_payment_method_id"` | ||
| CardBrand *string `json:"card_brand,omitempty" db:"card_brand"` | ||
| CardLast4 *string `json:"card_last4,omitempty" db:"card_last4"` | ||
| CardExpMonth *int `json:"card_exp_month,omitempty" db:"card_exp_month"` | ||
| CardExpYear *int `json:"card_exp_year,omitempty" db:"card_exp_year"` | ||
| IsDefault bool `json:"is_default" db:"is_default"` | ||
| CreatedAt time.Time `json:"created_at" db:"created_at"` | ||
| UpdatedAt time.Time `json:"updated_at" db:"updated_at"` | ||
| } | ||
|
|
||
| type CreateGuardianPaymentMethodInput struct { | ||
| Body struct { | ||
| GuardianID uuid.UUID `json:"guardian_id" doc:"Guardian ID"` | ||
| StripePaymentMethodID string `json:"stripe_payment_method_id" doc:"Stripe payment method ID (pm_...)"` | ||
| CardBrand *string `json:"card_brand,omitempty" doc:"Card brand (visa, mastercard, etc.)"` | ||
| CardLast4 *string `json:"card_last4,omitempty" doc:"Last 4 digits of card"` | ||
| CardExpMonth *int `json:"card_exp_month,omitempty" doc:"Card expiration month" minimum:"1" maximum:"12"` | ||
| CardExpYear *int `json:"card_exp_year,omitempty" doc:"Card expiration year" minimum:"2026"` | ||
| IsDefault bool `json:"is_default" doc:"Whether this is the default payment method"` | ||
| } | ||
| } | ||
|
|
||
| type CreateGuardianPaymentMethodOutput struct { | ||
| Body GuardianPaymentMethod `json:"body" doc:"Created payment method"` | ||
| } | ||
|
|
||
| type GetGuardianPaymentMethodsByGuardianIDInput struct { | ||
| GuardianID uuid.UUID `path:"guardian_id" doc:"Guardian ID"` | ||
| } | ||
|
|
||
| type GetGuardianPaymentMethodsByGuardianIDOutput struct { | ||
| Body []GuardianPaymentMethod `json:"body" doc:"List of guardian's payment methods"` | ||
| } | ||
|
|
||
| type DeleteGuardianPaymentMethodInput struct { | ||
| ID uuid.UUID `path:"id" doc:"Payment method ID"` | ||
| } | ||
|
|
||
| type DeleteGuardianPaymentMethodOutput struct { | ||
| Body struct { | ||
| Message string `json:"message" doc:"Success message"` | ||
| } | ||
| } | ||
|
|
||
| type SetDefaultPaymentMethodInput struct { | ||
| GuardianID uuid.UUID `path:"guardian_id" doc:"Guardian ID"` | ||
| PaymentMethodID uuid.UUID `path:"payment_method_id" doc:"Payment method ID to set as default"` | ||
| } | ||
|
|
||
| type SetDefaultPaymentMethodOutput struct { | ||
| Body GuardianPaymentMethod `json:"body" doc:"Updated payment method"` | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package models | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/google/uuid" | ||
| "github.com/stripe/stripe-go/v84" | ||
| ) | ||
|
|
||
| type CreateOrgStripeAccountInput struct { | ||
| Body struct { | ||
| OrganizationID uuid.UUID `json:"organization_id" doc:"UUID of the existing organization"` | ||
| } | ||
| } | ||
|
|
||
| type CreateOrgStripeAccountOutput struct { | ||
| Body struct { | ||
| Account stripe.V2CoreAccount `json:"account" doc:"Stripe account details"` | ||
| } | ||
| } | ||
|
|
||
| type CreateStripeOnboardingLinkInput struct { | ||
| Body struct { | ||
| AccountID string `json:"account_id" doc:"Stripe account ID (e.g., acct_123)"` | ||
| RefreshURL string `json:"refresh_url" doc:"URL to redirect if onboarding is exited early"` | ||
| ReturnURL string `json:"return_url" doc:"URL to redirect after successful onboarding"` | ||
| } | ||
| } | ||
|
|
||
| type CreateStripeOnboardingLinkOutput struct { | ||
| Body struct { | ||
| OnboardingURL string `json:"onboarding_url" doc:"Stripe-hosted onboarding page URL"` | ||
| } | ||
| } | ||
|
|
||
| type CreateSetupIntentInput struct { | ||
| GuardianID uuid.UUID `path:"guardian_id" doc:"Guardian ID"` | ||
| } | ||
|
|
||
| type CreateSetupIntentOutput struct { | ||
| Body struct { | ||
| ClientSecret string `json:"client_secret" doc:"Stripe SetupIntent client_secret for frontend"` | ||
| } | ||
| } | ||
|
|
||
| type CreateOrgLoginLinkInput struct { | ||
| OrganizationID uuid.UUID `path:"organization_id" doc:"Organization ID"` | ||
| } | ||
|
|
||
| type CreateOrgLoginLinkOutput struct { | ||
| Body struct { | ||
| LoginURL string `json:"login_url" doc:"Stripe Express dashboard login URL"` | ||
| } | ||
| } | ||
|
|
||
| type CreatePaymentIntentInput struct { | ||
| Body struct { | ||
| RegistrationID uuid.UUID `json:"registration_id" doc:"Registration/booking ID"` | ||
| GuardianID uuid.UUID `json:"guardian_id" doc:"Guardian ID"` | ||
| ProviderOrgID uuid.UUID `json:"provider_org_id" doc:"Provider organization ID"` | ||
| Amount int64 `json:"amount" doc:"Total amount in cents" minimum:"1"` | ||
| Currency string `json:"currency" doc:"Currency code (e.g., thb, usd)" pattern:"^[a-z]{3}$"` | ||
| EventDate time.Time `json:"event_date" doc:"Event date and time"` | ||
| PaymentMethodID *string `json:"payment_method_id,omitempty" doc:"Stripe payment method ID (required for bookings)"` | ||
|
|
||
| GuardianStripeID string | ||
| OrgStripeID string | ||
| } | ||
| } | ||
|
|
||
| type CreatePaymentIntentOutput struct { | ||
| Body struct { | ||
| PaymentIntentID string `json:"payment_intent_id" doc:"Stripe payment intent ID"` | ||
| ClientSecret string `json:"client_secret" doc:"Client secret for frontend to confirm payment"` | ||
| Status string `json:"status" doc:"Payment intent status"` | ||
| TotalAmount int `json:"total_amount" doc:"Total amount in cents"` | ||
| ProviderAmount int `json:"provider_amount" doc:"Amount provider receives in cents"` | ||
| PlatformFeeAmount int `json:"platform_fee_amount" doc:"Platform fee in cents"` | ||
| Currency string `json:"currency" doc:"Currency code"` | ||
| } | ||
| } | ||
|
|
||
| type CancelPaymentIntentInput struct { | ||
| PaymentIntentID string `json:"payment_intent_id" doc:"Stripe payment intent ID to cancel/refund"` | ||
| StripeAccountID string `json:"stripe_account_id" doc:"Organization's Stripe account ID"` | ||
| } | ||
|
|
||
| type CancelPaymentIntentOutput struct { | ||
| Body struct { | ||
| PaymentIntentID string `json:"payment_intent_id" doc:"Cancelled payment intent ID"` | ||
| Status string `json:"status" doc:"Payment intent status after cancellation"` | ||
| Amount int64 `json:"amount" doc:"Amount that was cancelled/refunded in cents"` | ||
| Currency string `json:"currency" doc:"Currency code"` | ||
| } `json:"body" doc:"Cancellation result"` | ||
| } | ||
|
|
||
| type CapturePaymentIntentInput struct { | ||
| PaymentIntentID string `json:"payment_intent_id" doc:"Stripe payment intent ID to capture"` | ||
| StripeAccountID string `json:"stripe_account_id" doc:"Organization's Stripe account ID"` | ||
| } | ||
|
|
||
| type CapturePaymentIntentOutput struct { | ||
| Body struct { | ||
| PaymentIntentID string `json:"payment_intent_id" doc:"Captured payment intent ID"` | ||
| Status string `json:"status" doc:"Payment intent status (should be 'succeeded')"` | ||
| Amount int64 `json:"amount" doc:"Amount captured in cents"` | ||
| Currency string `json:"currency" doc:"Currency code"` | ||
| } `json:"body" doc:"Capture result"` | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to store any of this card info or can it be pulled from stripe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice to have to show on the frontend and reduce calls to the API