@@ -16,6 +16,7 @@ import {
16
16
import { ChargeContent , ChargeSchema , isChargeContent } from "./types" ;
17
17
import { chargeTemplate , getChargeTemplate } from "./templates" ;
18
18
19
+ const url = "https://api.commerce.coinbase.com/charges" ;
19
20
interface ChargeRequest {
20
21
name : string ;
21
22
description : string ;
@@ -27,8 +28,6 @@ interface ChargeRequest {
27
28
}
28
29
29
30
export async function createCharge ( apiKey : string , params : ChargeRequest ) {
30
- const url = "https://api.commerce.coinbase.com/charges" ;
31
-
32
31
try {
33
32
const response = await fetch ( url , {
34
33
method : "POST" ,
@@ -44,7 +43,6 @@ export async function createCharge(apiKey: string, params: ChargeRequest) {
44
43
}
45
44
46
45
const data = await response . json ( ) ;
47
- console . log ( "Charge created successfully:" , data ) ;
48
46
return data . data ;
49
47
} catch ( error ) {
50
48
console . error ( "Error creating charge:" , error ) ;
@@ -54,8 +52,6 @@ export async function createCharge(apiKey: string, params: ChargeRequest) {
54
52
55
53
// Function to fetch all charges
56
54
export async function getAllCharges ( apiKey : string ) {
57
- const url = "https://api.commerce.coinbase.com/charges" ;
58
-
59
55
try {
60
56
const response = await fetch ( url , {
61
57
method : "GET" ,
@@ -81,10 +77,10 @@ export async function getAllCharges(apiKey: string) {
81
77
82
78
// Function to fetch details of a specific charge
83
79
export async function getChargeDetails ( apiKey : string , chargeId : string ) {
84
- const url = `https://api.commerce.coinbase.com/charges/ ${ chargeId } ` ;
80
+ const getUrl = `${ url } ${ chargeId } ` ;
85
81
86
82
try {
87
- const response = await fetch ( url , {
83
+ const response = await fetch ( getUrl , {
88
84
method : "GET" ,
89
85
headers : {
90
86
"Content-Type" : "application/json" ,
@@ -99,7 +95,6 @@ export async function getChargeDetails(apiKey: string, chargeId: string) {
99
95
}
100
96
101
97
const data = await response . json ( ) ;
102
- console . log ( `Fetched charge details for ID ${ chargeId } :` , data ) ;
103
98
return data ;
104
99
} catch ( error ) {
105
100
console . error (
@@ -344,19 +339,16 @@ export const getChargeDetailsAction: Action = {
344
339
state,
345
340
template : getChargeTemplate ,
346
341
} ) ;
347
- console . log ( "context " , context ) ;
348
342
const chargeDetails = await generateObjectV2 ( {
349
343
runtime,
350
344
context,
351
345
modelClass : ModelClass . SMALL ,
352
346
schema : ChargeSchema ,
353
347
} ) ;
354
- console . log ( chargeDetails ) ;
355
348
if ( ! isChargeContent ( chargeDetails . object ) ) {
356
349
throw new Error ( "Invalid content" ) ;
357
350
}
358
351
const charge = chargeDetails . object as ChargeContent ;
359
- console . log ( "charge " , charge ) ;
360
352
if ( ! charge . id ) {
361
353
callback (
362
354
{
0 commit comments