-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from poozlehq/159-stripe
New integration: Stripe
- Loading branch information
Showing
56 changed files
with
5,179 additions
and
323 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ENGINE_VERSION=0.1.7-alpha | ||
ENGINE_VERSION=0.1.8-alpha | ||
|
||
# POSTGRES | ||
POSTGRES_USER=docker | ||
|
This file contains 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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"name": "@poozle/engine-idk", | ||
"version": "0.1.44", | ||
"version": "0.1.45", | ||
"description": "Used to develop integrations for Poozle", | ||
"license": "MIT", | ||
"author": "Poozle <[email protected]>", | ||
"main": "./idk/index.js", | ||
"module": "./idk/index.esm.js", | ||
"keywords": [], | ||
"keywords": [ ], | ||
"scripts": { | ||
"build": "rollup -c", | ||
"lint": "eslint --ext js,ts,tsx src", | ||
|
This file contains 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 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,90 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
export interface Address { | ||
city: string; | ||
country: string; | ||
line1: string; | ||
line2: string; | ||
postal_code: number; | ||
} | ||
|
||
export interface BillingDetails { | ||
address: Address; | ||
email: string; | ||
name: string; | ||
phone: string; | ||
} | ||
|
||
export interface PaymentMethod { | ||
type: PaymentMethodType; | ||
details: PaymentDetails; | ||
} | ||
|
||
export interface PaymentDetails { | ||
[key: string]: any; | ||
} | ||
|
||
export interface Outcome { | ||
network_status: string; | ||
reason: string; | ||
risk_level: string; | ||
seller_message: string; | ||
type: string; | ||
} | ||
|
||
export interface Charge { | ||
id: string; | ||
amount: string; | ||
amount_refunded: string; | ||
application: string; | ||
application_fee_amount: string; | ||
billing_details: BillingDetails; | ||
captured: boolean; | ||
created_at: string; | ||
currency: string; | ||
description: string; | ||
disputed: boolean; | ||
failure_code: string; | ||
failure_message: string; | ||
invoice: string; | ||
metadata: any; | ||
outcome: Outcome; | ||
paid: boolean; | ||
payment_method: PaymentMethod; | ||
email: string; | ||
contact: string; | ||
status: PaymentMethodStatus; | ||
} | ||
|
||
export enum PaymentMethodType { | ||
ach_credit_transfer = 'ach_credit_transfer', | ||
ach_debit = 'ach_debit', | ||
acss_debit = 'acss_debit', | ||
alipay = 'alipay', | ||
au_becs_debit = 'au_becs_debit', | ||
bancontact = 'bancontact', | ||
card = 'card', | ||
card_present = 'card_present', | ||
eps = 'eps', | ||
giropay = 'giropay', | ||
ideal = 'ideal', | ||
klarna = 'klarna', | ||
multibanco = 'multibanco', | ||
p24 = 'p24', | ||
sepa_debit = 'sepa_debit', | ||
sofort = 'sofort', | ||
stripe_account = 'stripe_account', | ||
wechat = 'wechat', | ||
netbank = 'netbank', | ||
wallet = 'wallet', | ||
emi = 'emi', | ||
upi = 'upi', | ||
} | ||
|
||
export enum PaymentMethodStatus { | ||
created = 'created', | ||
authorized = 'authorized', | ||
succeeded = 'succeeded', | ||
refunded = 'refunded', | ||
failed = 'failed', | ||
} |
This file contains 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,75 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
export interface Dispute { | ||
id: string; | ||
amount: string; | ||
charge_id: string; | ||
currency: string; | ||
reason: string; | ||
evidence: Evidence; | ||
status: string; | ||
priority: string; | ||
is_charge_refundable: boolean; | ||
created_at: string; | ||
} | ||
|
||
export interface Evidence { | ||
access_activity_log: string; | ||
billing_address: string; | ||
cancellation_policy: string[]; | ||
cancellation_policy_disclosure: string; | ||
cancellation_rebuttal: string; | ||
customer_communication: string[]; | ||
customer_email_address: string; | ||
customer_name: string; | ||
customer_purchase_ip: string; | ||
customer_signature: string[]; | ||
duplicate_charge_documentation: string[]; | ||
duplicate_charge_explanation: string; | ||
duplicate_charge_id: string; | ||
product_description: string; | ||
receipt: string[]; | ||
refund_policy: string[]; | ||
refund_policy_disclosure: string; | ||
refund_refusal_explanation: string; | ||
service_date: string; | ||
service_documentation: string[]; | ||
shipping_address: string; | ||
shipping_carrier: string; | ||
shipping_date: string; | ||
shipping_documentation: string[]; | ||
shipping_tracking_number: string; | ||
uncategorized_file: string[]; | ||
uncategorized_text: string; | ||
due_by: string; | ||
has_evidence: boolean; | ||
past_due: boolean; | ||
submission_count: string; | ||
} | ||
|
||
export enum DisputeReason { | ||
bank_cannot_process = 'bank_cannot_process', | ||
check_returned = 'check_returned', | ||
credit_not_processed = 'credit_not_processed', | ||
customer_initiated = 'customer_initiated', | ||
debit_not_authorized = 'debit_not_authorized', | ||
duplicate = 'duplicate', | ||
fraudulent = 'fraudulent', | ||
general = 'general', | ||
incorrect_account_details = 'incorrect_account_details', | ||
insufficient_funds = 'insufficient_funds', | ||
product_not_received = 'product_not_received', | ||
product_unacceptable = 'product_unacceptable', | ||
subscription_canceled = 'subscription_canceled', | ||
unrecognize = 'unrecognize', | ||
} | ||
|
||
export enum DisputeStatus { | ||
warning_needs_response = 'warning_needs_response', | ||
warning_under_review = 'warning_under_review', | ||
warning_closed = 'warning_closed', | ||
needs_response = 'needs_response', | ||
under_review = 'under_review', | ||
won = 'won', | ||
lost = 'lost', | ||
} |
This file contains 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,4 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
export * from './charges'; | ||
export * from './disputes'; |
This file contains 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 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 |
---|---|---|
|
@@ -138,6 +138,7 @@ Enum IntegrationType { | |
ACCOUNTING | ||
ATS | ||
STORAGE | ||
PAYMENTS | ||
} | ||
|
||
Ref: Workspace.userId > User.userId | ||
|
2 changes: 2 additions & 0 deletions
2
engine-server/prisma/migrations/20230817032902_add_payments/migration.sql
This file contains 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,2 @@ | ||
-- AlterEnum | ||
ALTER TYPE "IntegrationType" ADD VALUE 'PAYMENTS'; |
This file contains 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 |
---|---|---|
|
@@ -174,4 +174,5 @@ enum IntegrationType { | |
ACCOUNTING | ||
ATS | ||
STORAGE | ||
PAYMENTS | ||
} |
This file contains 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 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
61 changes: 61 additions & 0 deletions
61
engine-server/src/modules/categories/payments/models/charge/charge.controller.ts
This file contains 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,61 @@ | ||
/** Copyright (c) 2023, Poozle, all rights reserved. **/ | ||
|
||
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { IntegrationType } from '@prisma/client'; | ||
|
||
import { IntegrationAccount } from '@@generated/integrationAccount/entities'; | ||
|
||
import { GetIntegrationAccount } from 'common/decorators/integration_account.decorator'; | ||
|
||
import { AuthGuard } from 'modules/auth/auth.guard'; | ||
|
||
import { | ||
ChargeQueryParams, | ||
GetChargeQueryParams, | ||
PathParamsWithChargeId, | ||
ChargeResponse, | ||
ChargesResponse, | ||
} from './charge.interface'; | ||
import { ChargeService } from './charge.service'; | ||
|
||
@Controller({ | ||
version: '1', | ||
path: 'payments/charges', | ||
}) | ||
@ApiTags('Payments') | ||
export class ChargeController { | ||
constructor(private chargeService: ChargeService) {} | ||
|
||
@Get() | ||
@UseGuards(new AuthGuard()) | ||
async getCharges( | ||
@Query() query: ChargeQueryParams, | ||
@GetIntegrationAccount(IntegrationType.PAYMENTS) | ||
integrationAccount: IntegrationAccount, | ||
): Promise<ChargesResponse> { | ||
const chargeResponse = await this.chargeService.getCharges( | ||
integrationAccount, | ||
query, | ||
); | ||
|
||
return chargeResponse; | ||
} | ||
|
||
@Get(':charge_id') | ||
async getCharge( | ||
@Query() query: GetChargeQueryParams, | ||
@Param() | ||
params: PathParamsWithChargeId, | ||
@GetIntegrationAccount(IntegrationType.PAYMENTS) | ||
integrationAccount: IntegrationAccount, | ||
): Promise<ChargeResponse> { | ||
const chargeResponse = await this.chargeService.getCharge( | ||
integrationAccount, | ||
query, | ||
params, | ||
); | ||
|
||
return chargeResponse; | ||
} | ||
} |
Oops, something went wrong.