|
| 1 | + # Bux.ph Dark SDK |
| 2 | + |
| 3 | + |
| 4 | +## Checkout API |
| 5 | +- Allows you to checkout |
| 6 | + |
| 7 | +All the parameters that can be used on Checkout Api in JSON |
| 8 | +```json |
| 9 | +{ |
| 10 | +"req_id": "TEST123d", |
| 11 | +"client_id": "0000001", // Set this up in your .env |
| 12 | +"amount": "50", |
| 13 | +"description": "test", |
| 14 | +"expiry": 2, |
| 15 | + |
| 16 | +"contact": "9161234567", |
| 17 | +"name": "Juan Dela Cruz", |
| 18 | +"notification_url": "https://example.ph/bux_notif/", |
| 19 | +"redirect_url": "https://example.ph/sample_redirect/", |
| 20 | +"param1": "referral link", |
| 21 | +"param2": "delivery address" |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +1. Set up .env |
| 28 | + |
| 29 | +for production use `https://api.bux.ph/v1/api` as your BUX_BASE_URL |
| 30 | + |
| 31 | +```toml |
| 32 | +BUX_API_KEY=api_key |
| 33 | +BUX_BASE_URL=https://api.bux.ph/v1/api/sandbox |
| 34 | +BUX_CLIENT_ID=0000000001 |
| 35 | +BUX_API_SECRET=secret |
| 36 | +``` |
| 37 | + |
| 38 | +Initialize dotenv on your main function |
| 39 | + |
| 40 | +```dart |
| 41 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; |
| 42 | +
|
| 43 | +Future<void> main() async { |
| 44 | + await dotenv.load(); |
| 45 | + runApp(MyApp()); |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +Add to Your pubspec.yaml |
| 50 | + |
| 51 | +```yaml |
| 52 | +flutter: |
| 53 | + assets: |
| 54 | + - .env |
| 55 | +``` |
| 56 | +
|
| 57 | +
|
| 58 | +2. Create CheckoutPayload |
| 59 | +
|
| 60 | +```dart |
| 61 | +import 'package:buxdotph/models/api/checkout_payload.dart'; |
| 62 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; |
| 63 | +... |
| 64 | + |
| 65 | + |
| 66 | +final CheckoutPayload payload = CheckoutPayload( |
| 67 | + amount: 1000, |
| 68 | + req_id: 'uuid_from_backend', |
| 69 | + client_id: dotenv.env['BUX_CLIENT_ID']!, |
| 70 | + description: 'subscription', |
| 71 | + notification_url: 'https://google.com', |
| 72 | + expiry: 2, |
| 73 | + |
| 74 | + contact: '09155555555', |
| 75 | + name: 'John Dela Cruz', |
| 76 | + redirect_url: 'https://goldcoders.dev', |
| 77 | + param1: 'username', |
| 78 | + param2: 'address', |
| 79 | + ); |
| 80 | +``` |
| 81 | + |
| 82 | +- Pass the Payload to Bux.checkout() |
| 83 | + |
| 84 | +```dart |
| 85 | +import 'package:buxdotph/buxdotph.dart'; |
| 86 | +
|
| 87 | +... |
| 88 | +await Bux.checkout(payload); |
| 89 | +``` |
| 90 | + |
| 91 | +the returned response is a `String?` type , you can `json_encode` it if there is no errors |
0 commit comments