-
Notifications
You must be signed in to change notification settings - Fork 1
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 #22 from astoria-tech/azlyth/stripe-sandbox
Integrate with Stripe (test mode)
- Loading branch information
Showing
15 changed files
with
1,135 additions
and
19 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,2 +1 @@ | ||
/.envrc | ||
**/.envrc | ||
.envrc |
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,115 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = new Collection({ | ||
"createRule": "@request.auth.id != ''", | ||
"deleteRule": "@request.auth.id = user.id", | ||
"fields": [ | ||
{ | ||
"id": "user_relation", | ||
"name": "user", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"cascadeDelete": true, | ||
"collectionId": "_pb_users_auth_", | ||
"maxSelect": 1, | ||
"minSelect": 1 | ||
}, | ||
{ | ||
"id": "stripe_payment_method", | ||
"name": "stripe_payment_method_id", | ||
"type": "text", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false | ||
}, | ||
{ | ||
"id": "last4", | ||
"name": "last4", | ||
"type": "text", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false | ||
}, | ||
{ | ||
"id": "brand", | ||
"name": "brand", | ||
"type": "text", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false | ||
}, | ||
{ | ||
"id": "exp_month", | ||
"name": "exp_month", | ||
"type": "number", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"min": 1, | ||
"max": 12, | ||
"onlyInt": true | ||
}, | ||
{ | ||
"id": "exp_year", | ||
"name": "exp_year", | ||
"type": "number", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"min": 2024, | ||
"onlyInt": true | ||
}, | ||
{ | ||
"id": "is_default", | ||
"name": "is_default", | ||
"type": "bool", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false | ||
}, | ||
{ | ||
"id": "created", | ||
"name": "created", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": false | ||
}, | ||
{ | ||
"id": "updated", | ||
"name": "updated", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": true | ||
} | ||
], | ||
"id": "payment_methods", | ||
"indexes": ["CREATE UNIQUE INDEX idx_unique_payment_method ON payment_methods (user, stripe_payment_method_id)"], | ||
"listRule": "@request.auth.id = user.id", | ||
"name": "payment_methods", | ||
"system": false, | ||
"type": "base", | ||
"updateRule": "@request.auth.id = user.id", | ||
"viewRule": "@request.auth.id = user.id" | ||
}); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("payment_methods"); | ||
return app.delete(collection); | ||
}) |
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,59 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_3527180448"); | ||
|
||
// add payment intent field | ||
collection.fields.addAt(collection.fields.length, new Field({ | ||
"id": "stripe_payment_intent", | ||
"name": "stripe_payment_intent_id", | ||
"type": "text", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"autogeneratePattern": "", | ||
"max": 0, | ||
"min": 0, | ||
"pattern": "", | ||
"primaryKey": false | ||
})); | ||
|
||
// add payment method relation | ||
collection.fields.addAt(collection.fields.length, new Field({ | ||
"id": "stripe_payment_method", | ||
"name": "payment_method", | ||
"type": "relation", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"collectionId": "payment_methods", | ||
"cascadeDelete": false, | ||
"maxSelect": 1, | ||
"minSelect": 0 | ||
})); | ||
|
||
// add payment status field | ||
collection.fields.addAt(collection.fields.length, new Field({ | ||
"id": "stripe_payment_status", | ||
"name": "payment_status", | ||
"type": "select", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"values": ["pending", "processing", "succeeded", "failed", "refunded"], | ||
"maxSelect": 1 | ||
})); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_3527180448"); | ||
|
||
// remove fields | ||
collection.fields.removeById("stripe_payment_intent"); | ||
collection.fields.removeById("stripe_payment_method"); | ||
collection.fields.removeById("stripe_payment_status"); | ||
|
||
return app.save(collection); | ||
}) |
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,65 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = new Collection({ | ||
"createRule": "@request.auth.id != ''", | ||
"deleteRule": "@request.auth.id = user.id", | ||
"fields": [ | ||
{ | ||
"id": "user_relation", | ||
"name": "user", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"cascadeDelete": true, | ||
"collectionId": "_pb_users_auth_", | ||
"maxSelect": 1, | ||
"minSelect": 1 | ||
}, | ||
{ | ||
"id": "stripe_customer", | ||
"name": "stripe_customer_id", | ||
"type": "text", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false | ||
}, | ||
{ | ||
"id": "created", | ||
"name": "created", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": false | ||
}, | ||
{ | ||
"id": "updated", | ||
"name": "updated", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": true | ||
} | ||
], | ||
"id": "stripe_customers", | ||
"indexes": ["CREATE UNIQUE INDEX idx_unique_customer ON stripe_customers (user, stripe_customer_id)"], | ||
"listRule": "@request.auth.id = user.id", | ||
"name": "stripe_customers", | ||
"system": false, | ||
"type": "base", | ||
"updateRule": "@request.auth.id = user.id", | ||
"viewRule": "@request.auth.id = user.id" | ||
}); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("stripe_customers"); | ||
return app.delete(collection); | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.