Skip to content

Commit cb18f5b

Browse files
committed
updating Checkout docs
1 parent 8df582e commit cb18f5b

File tree

2 files changed

+52
-226
lines changed

2 files changed

+52
-226
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ AI-native integrations for modern LLM applications
2626
- **Features**: MCP server offering 60+ commerce based tools
2727
- **Full guide**: [commerce-mcp/essentials-mcp/README.md](commerce-mcp/essentials-mcp/README.md)
2828

29+
### 📦 **Checkout**
30+
commercetools Checkout integration using Browser SDK
31+
- **Location**: `checkout/`
32+
- **Best for**: Prebuilt checkout component including payment integrations
33+
- **Features**: Full SDK access, type safety, complete control over API calls
34+
- **Full guide**: [checkout/README.md](checkout/README.md)
35+
2936
## 🚀 Quick Start
3037

3138
### For AI/LLM Applications
@@ -42,6 +49,16 @@ cd composable-commerce
4249
npm install
4350
```
4451

52+
### For precomposed Checkout
53+
```bash
54+
git clone https://github.com/commercetools/hackathon-starter-kit.git
55+
cd checkout
56+
npm run setup
57+
# Configure .env with your credentials and Checkout Application ID
58+
npm run build-client && npm run start-client
59+
npm run start-server
60+
```
61+
4562
## 💡 Sample Implementations & Use Cases
4663

4764
### 🎯 **AI-Powered Commerce Assistant** (Essentials + Developer MCP)
@@ -65,6 +82,18 @@ Traditional service layer applications with:
6582

6683
**Examples**: `composable-commerce/src/examples/`
6784

85+
### 💳 **Checkout Integration Example** (commercetools Checkout)
86+
Complete React e-commerce application with embedded checkout:
87+
- **Full Shopping Experience**: Product catalog, cart management, and checkout
88+
- **Embedded Payments**: Secure payment processing with commercetools Checkout
89+
- **Multiple Payment Methods**: Credit cards, PayPal, and more
90+
- **Order Completion**: Success pages and order confirmation
91+
- **Responsive Design**: Works on desktop and mobile
92+
- **Real-time Updates**: Cart and checkout state management
93+
94+
**Framework**: `checkout/`
95+
**Full guide**: [checkout/README.md](checkout-example/README.md)
96+
6897
## 🔑 Project Setup
6998

7099
### 1. Create or use a commercetools account

checkout/README.md

Lines changed: 23 additions & 226 deletions
Original file line numberDiff line numberDiff line change
@@ -34,62 +34,37 @@ This is the **critical step** - you must set up a Checkout application in Mercha
3434
- In the left sidebar: Settings → Checkout
3535
- If you don't see "Checkout", ensure your project has Checkout enabled
3636

37-
3. **Create New Checkout Application**
38-
- Click "Create Application"
39-
- Fill in application details:
40-
- **Name**: "Hackathon Checkout App" (or your preferred name)
41-
- **Description**: "Checkout app for hackathon project"
42-
- **Application URL**: `http://localhost:3000` (for development)
43-
- **Allowed Origins**: `http://localhost:3000, http://localhost:3001`
44-
37+
3. **Configure Checkout Application**
38+
- Use sample Checkout application
39+
- Change Origin URLs to "Allow all URLs to communicate to the checkout application" for testing purposes
40+
4541
4. **Configure Payment Methods**
4642
- In the Checkout application settings
47-
- Add payment methods (Credit Cards, PayPal, etc.)
48-
- For testing: Enable "Test Mode" payment processors
43+
- Configure Payment Integrations , install Sample payment connector
44+
- Add payment methods (card etc.) and enable them
4945

5046
5. **Copy Application ID**
51-
- After creation, copy the **Application ID**
47+
- After configuration, copy the **Application ID**
5248
- You'll need this for your `.env` file
5349

54-
### 3. Payment Integration Setup
55-
56-
#### For Testing (Recommended):
57-
1. **Enable Test Payment Processors**
58-
- In Checkout app settings → Payment Methods
59-
- Enable "Test Credit Card Processor"
60-
- No additional setup required for testing
61-
62-
#### For Production:
63-
1. **Configure Real Payment Processors**
64-
- Stripe: Add Stripe API keys
65-
- PayPal: Configure PayPal credentials
66-
- Adyen: Add Adyen credentials
67-
- Follow specific integration guides for each processor
68-
69-
2. **Webhook Configuration** (Optional but recommended)
70-
- Set webhook URL: `https://yourdomain.com/api/webhook/checkout`
71-
- Select events: `checkout.session.completed`, `payment.created`
72-
7350
## 🛠 Installation & Setup
7451

7552
### 1. Clone and Install
7653

7754
```bash
7855
# From the hackathon-starter-kit root
79-
cd checkout-example
56+
cd checkout
8057

81-
# Install server dependencies
82-
npm install
58+
# Install server & client dependencies
59+
npm run setup
8360

84-
# Install client dependencies
85-
cd client && npm install && cd ..
86-
```
8761

8862
### 2. Environment Configuration
8963

9064
```bash
9165
# Copy environment template
9266
cp .env.example .env
67+
cp /client/.env.example /client/.env
9368
```
9469

9570
Edit `.env` with your credentials:
@@ -112,69 +87,32 @@ PORT=3001
11287
CLIENT_PORT=3000
11388
```
11489

115-
**⚠️ Critical**: The `CHECKOUT_APPLICATION_ID` must match the Application ID from your Merchant Center Checkout app.
116-
117-
### 3. Verify Setup
118-
119-
Check if everything is configured correctly:
90+
Edit client `.env` with your project:
12091

121-
```bash
122-
# Test API connection
123-
npm run server
124-
125-
# In another terminal, test the health endpoint
126-
curl http://localhost:3001/api/health
92+
```env
93+
REACT_APP_CTP_PROJECT_KEY=consulting
12794
```
12895

129-
Expected response:
130-
```json
131-
{
132-
"status": "OK",
133-
"timestamp": "2024-01-15T10:30:00.000Z",
134-
"environment": {
135-
"projectKey": "your-project-key",
136-
"checkoutAppId": "***configured***"
137-
}
138-
}
139-
```
14096

141-
### 4. Add Sample Products (Optional)
97+
## 🎯 Running the Application
14298

143-
If your project doesn't have products:
99+
### Development Mode
144100

145101
```bash
146-
# Go to composable-commerce example
147-
cd ../composable-commerce
148-
149-
# Run the import example to add sample products
150-
npm run import-product bulk
151-
152-
# Go back to checkout example
153-
cd ../checkout-example
102+
# Start server
103+
npm run start-server
154104
```
155105

156-
## 🎯 Running the Application
157-
158-
### Development Mode
159-
160106
```bash
161-
# Start both server and client concurrently
162-
npm run dev
107+
# Start client
108+
npm run build-client
109+
npm run start-client
163110
```
164111

165112
This starts:
166113
- **Backend server**: http://localhost:3001
167114
- **React client**: http://localhost:3000
168115

169-
### Production Build
170-
171-
```bash
172-
# Build the client
173-
npm run build
174-
175-
# Start production server
176-
npm start
177-
```
178116

179117
## 🧪 Testing the Checkout Flow
180118

@@ -191,8 +129,7 @@ npm start
191129
### 3. Complete Checkout
192130
- Fill in shipping/billing information
193131
- Use test card numbers for testing:
194-
- **Visa**: 4242424242424242
195-
- **Mastercard**: 5555555555554444
132+
- **Visa**: 4111111111111111
196133
- **Expiry**: Any future date
197134
- **CVV**: Any 3-digit number
198135

@@ -201,93 +138,6 @@ npm start
201138
- Order ID should be displayed
202139
- Cart should be cleared
203140

204-
## 🔧 Customization
205-
206-
### Styling
207-
Edit `client/src/App.css` to customize appearance:
208-
209-
```css
210-
/* Change primary color */
211-
.btn-primary {
212-
background-color: #your-brand-color;
213-
}
214-
215-
/* Customize checkout appearance */
216-
.checkout-embedded {
217-
/* Custom checkout styling */
218-
}
219-
```
220-
221-
### Checkout SDK Configuration
222-
In `CheckoutPage.js`, customize the SDK loading:
223-
224-
```javascript
225-
const checkout = await CheckoutAPI.loadCheckout({
226-
sessionId: session.sessionId,
227-
sessionUrl: session.sessionUrl,
228-
locale: 'en', // Change locale
229-
appearance: {
230-
theme: 'light', // 'light' or 'dark'
231-
colorPrimary: '#213547', // Your brand color
232-
borderRadius: '8px',
233-
fontFamily: 'Arial, sans-serif'
234-
}
235-
});
236-
```
237-
238-
### Adding Custom Fields
239-
Extend the checkout session creation in `server.js`:
240-
241-
```javascript
242-
const checkoutSessionData = {
243-
cartId: cartId,
244-
countryCode: cart.body.country || 'US',
245-
locale: locale,
246-
returnUrl: returnUrl,
247-
applicationId: process.env.CHECKOUT_APPLICATION_ID,
248-
// Add custom fields
249-
metadata: {
250-
source: 'hackathon-app',
251-
campaignId: 'summer2024'
252-
}
253-
};
254-
```
255-
256-
## 📊 Monitoring & Analytics
257-
258-
### Webhook Events
259-
The server includes webhook handling for:
260-
- `CheckoutSessionCompleted`: Payment successful
261-
- `CheckoutSessionExpired`: Session timed out
262-
- `PaymentCreated`: Payment object created
263-
264-
### Error Tracking
265-
Add error tracking service integration:
266-
267-
```javascript
268-
// In server.js
269-
const Sentry = require('@sentry/node');
270-
271-
app.use(Sentry.Handlers.errorHandler());
272-
```
273-
274-
### Order Analytics
275-
Track successful orders:
276-
277-
```javascript
278-
// In CheckoutSuccess.js
279-
useEffect(() => {
280-
if (orderId) {
281-
// Google Analytics
282-
gtag('event', 'purchase', {
283-
transaction_id: orderId,
284-
value: totalAmount,
285-
currency: 'USD'
286-
});
287-
}
288-
}, [orderId]);
289-
```
290-
291141
## 🚨 Troubleshooting
292142

293143
### Common Issues
@@ -331,63 +181,10 @@ useEffect(() => {
331181
- Use valid test card numbers
332182
- Check payment processor logs in Merchant Center
333183

334-
### Debug Mode
335-
336-
Enable detailed logging:
337-
338-
```bash
339-
# Set environment variable
340-
NODE_ENV=development npm run dev
341-
```
342-
343-
This enables:
344-
- Console logging for all API calls
345-
- Debug information in UI
346-
- Detailed error messages
347-
348-
### API Endpoints for Testing
349-
350-
Test backend functionality directly:
351-
352-
```bash
353-
# Health check
354-
curl http://localhost:3001/api/health
355-
356-
# Get products
357-
curl http://localhost:3001/api/products
358-
359-
# Create test cart
360-
curl -X POST http://localhost:3001/api/cart/create \
361-
-H "Content-Type: application/json" \
362-
-d '{"currency": "USD", "country": "US"}'
363-
```
364184

365185
## 📖 Additional Resources
366186

367187
### commercetools Documentation
368188
- [Checkout Documentation](https://docs.commercetools.com/checkout)
369189
- [Checkout Browser SDK](https://docs.commercetools.com/checkout/browser-sdk)
370-
- [Payment Integration Guide](https://docs.commercetools.com/checkout/payment-integrations)
371-
372-
### API References
373-
- [Platform API](https://docs.commercetools.com/api)
374-
- [Checkout API](https://docs.commercetools.com/checkout/api)
375-
376-
### Payment Processors
377-
- [Stripe Integration](https://docs.commercetools.com/checkout/payment-integrations/stripe)
378-
- [PayPal Integration](https://docs.commercetools.com/checkout/payment-integrations/paypal)
379-
- [Adyen Integration](https://docs.commercetools.com/checkout/payment-integrations/adyen)
380-
381-
## 🤝 Support
382-
383-
- **Documentation**: [docs.commercetools.com](https://docs.commercetools.com)
384-
- **Community**: [community.commercetools.com](https://community.commercetools.com)
385-
- **Support**: [support.commercetools.com](https://support.commercetools.com)
386-
387-
## 📄 License
388-
389-
This example is provided under the MIT License. See LICENSE file for details.
390-
391-
---
392-
393-
**Happy coding! 🚀** If you encounter any issues, refer to the troubleshooting section or reach out to the commercetools community.
190+
- [Payment Connectors](https://docs.commercetools.com/checkout/connectors-and-applications)

0 commit comments

Comments
 (0)