-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
898 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@coinbase-platform/commerce": minor | ||
--- | ||
|
||
feat: add `commerce` package |
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,7 @@ | ||
# Create charge - Commerce | ||
|
||
Run | ||
|
||
```sh | ||
$ bun run index.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,21 @@ | ||
import { | ||
type CreateChargeParameters, | ||
createCharge, | ||
} from "@coinbase-platform/commerce"; | ||
|
||
const apiKey = process.env.API_KEY; | ||
if (!apiKey) throw new Error("API_KEY not found"); | ||
|
||
const parameters: CreateChargeParameters = { | ||
name: "Nvidia RTX 4080", | ||
description: "Graphic Card", | ||
pricing_type: "fixed_price", | ||
local_price: { | ||
amount: "1000.00", | ||
currency: "USD", | ||
}, | ||
}; | ||
|
||
const response = await createCharge(parameters, apiKey); | ||
|
||
console.log(JSON.stringify(response, null, 2)); |
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,16 @@ | ||
{ | ||
"name": "@examples/commerce_create-charge", | ||
"private": true, | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@coinbase-platform/commerce": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false | ||
} | ||
} |
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,7 @@ | ||
# Create checkout - Commerce | ||
|
||
Run | ||
|
||
```sh | ||
$ bun run index.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,23 @@ | ||
import { | ||
type CreateCheckoutParameters, | ||
createCheckout, | ||
} from "@coinbase-platform/commerce"; | ||
|
||
const apiKey = process.env.API_KEY; | ||
if (!apiKey) throw new Error("API_KEY not found"); | ||
|
||
const parameters: CreateCheckoutParameters = { | ||
name: "Nvidia RTX 4080", | ||
description: "Graphic Card", | ||
pricing_type: "fixed_price", | ||
local_price: { | ||
amount: "1000.00", | ||
currency: "USD", | ||
}, | ||
logo_url: "", | ||
requested_info: [], | ||
}; | ||
|
||
const response = await createCheckout(parameters, apiKey); | ||
|
||
console.log(JSON.stringify(response, null, 2)); |
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,16 @@ | ||
{ | ||
"name": "@examples/commerce_create-checkout", | ||
"private": true, | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@coinbase-platform/commerce": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false | ||
} | ||
} |
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,7 @@ | ||
# Get charge - Commerce | ||
|
||
Run | ||
|
||
```sh | ||
$ bun run index.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,13 @@ | ||
import { getCharge, getCharges } from "@coinbase-platform/commerce"; | ||
|
||
const apiKey = process.env.API_KEY; | ||
if (!apiKey) throw new Error("API_KEY not found"); | ||
|
||
// Get a charge by id | ||
const chargeId = "fb86d331-1db8-44f2-a96c-235d2a855ad3"; | ||
const charge = await getCharge(chargeId, apiKey); | ||
console.log(JSON.stringify(charge, null, 2)); | ||
|
||
// Get all charges | ||
const charges = await getCharges(apiKey); | ||
console.log(JSON.stringify(charges, null, 2)); |
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,16 @@ | ||
{ | ||
"name": "@examples/commerce_get-charges", | ||
"private": true, | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@coinbase-platform/commerce": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false | ||
} | ||
} |
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,7 @@ | ||
# Get checkout - Commerce | ||
|
||
Run | ||
|
||
```sh | ||
$ bun run index.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,13 @@ | ||
import { getCheckout, getCheckouts } from "@coinbase-platform/commerce"; | ||
|
||
const apiKey = process.env.API_KEY; | ||
if (!apiKey) throw new Error("API_KEY not found"); | ||
|
||
// Get a checkout by id | ||
const checkoutId = "a6e9fdd6-877d-4b2d-9d2e-70e810211b52"; | ||
const checkout = await getCheckout(checkoutId, apiKey); | ||
console.log(JSON.stringify(checkout, null, 2)); | ||
|
||
// Get all checkouts | ||
const checkouts = await getCheckouts(apiKey); | ||
console.log(JSON.stringify(checkouts, null, 2)); |
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,16 @@ | ||
{ | ||
"name": "@examples/commerce_get-checkouts", | ||
"private": true, | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@coinbase-platform/commerce": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false | ||
} | ||
} |
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,7 @@ | ||
# Get events - Commerce | ||
|
||
Run | ||
|
||
```sh | ||
$ bun run index.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,13 @@ | ||
import { getEvent, getEvents } from "@coinbase-platform/commerce"; | ||
|
||
const apiKey = process.env.API_KEY; | ||
if (!apiKey) throw new Error("API_KEY not found"); | ||
|
||
// Get an event by id | ||
const eventId = "400ecd4e-9952-412b-9726-bdb173762b05"; | ||
const event = await getEvent(eventId, apiKey); | ||
console.log(JSON.stringify(event, null, 2)); | ||
|
||
// Get all events | ||
const events = await getEvents(apiKey); | ||
console.log(JSON.stringify(events.data, null, 2)); |
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,16 @@ | ||
{ | ||
"name": "@examples/commerce_get-events", | ||
"private": true, | ||
"module": "index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@coinbase-platform/commerce": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false | ||
} | ||
} |
Oops, something went wrong.