Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/examples export-ignore
/tests export-ignore
/phpstan.neon.dist export-ignore
/.php-cs-fixer.dist.php export-ignore
/MIGRATION.md export-ignore
/CHANGELOG.md export-ignore
2 changes: 1 addition & 1 deletion examples/api/account_balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

$balance = $chip->getBalance();
$balance = $chip->account->balance();

echo "<pre><code>" . json_encode($balance, JSON_PRETTY_PRINT) . "</code></pre>";
4 changes: 2 additions & 2 deletions examples/api/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

# Use SDK instead of raw curl
$publicKey = $chip->getPublicKey();
# Get public key via SDK
$publicKey = $chip->publicKey->get();

$post = file_get_contents('php://input');
$headers = getallheaders();
Expand Down
6 changes: 3 additions & 3 deletions examples/api/client_crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
$client->email = 'client@example.com';
$client->full_name = 'John Doe';

$created = $chip->createClient($client);
$created = $chip->clients->create($client);
echo "<h2>Created Client</h2>";
echo "<pre><code>" . json_encode($created, JSON_PRETTY_PRINT) . "</code></pre>";

# Get all clients
$clients = $chip->getClients();
$clients = $chip->clients->list();
echo "<h2>All Clients</h2>";
echo "<pre><code>" . json_encode($clients, JSON_PRETTY_PRINT) . "</code></pre>";

# Update client
$clientId = $created->id;
$client->full_name = 'Jane Doe';
$updated = $chip->updateClient($clientId, $client);
$updated = $chip->clients->update($clientId, $client);
echo "<h2>Updated Client</h2>";
echo "<pre><code>" . json_encode($updated, JSON_PRETTY_PRINT) . "</code></pre>";
2 changes: 1 addition & 1 deletion examples/api/create_purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$purchase->failure_redirect = $config['basedUrl'] . '/api/redirect.php?success=0';
$purchase->success_callback = $config['basedUrl'] . '/api/callback.php';

$result = $chip->createPurchase($purchase);
$result = $chip->purchases->create($purchase);

if ($result && $result->checkout_url) {
// Redirect user to checkout
Expand Down
2 changes: 1 addition & 1 deletion examples/api/get_purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$purchaseId = ''; # ID of the purchase: $purchase->id;

$purchase = $chip->getPurchase($purchaseId);
$purchase = $chip->purchases->get($purchaseId);

header('Content-Type: application/json');
echo json_encode($purchase, JSON_PRETTY_PRINT);
2 changes: 1 addition & 1 deletion examples/api/payment_methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

$methods = $chip->getPaymentMethods();
$methods = $chip->paymentMethods->list('MYR');

echo "<pre><code>" . json_encode($methods, JSON_PRETTY_PRINT) . "</code></pre>";
2 changes: 1 addition & 1 deletion examples/api/public_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

# Get public key via SDK
$publicKey = $chip->getPublicKey();
$publicKey = $chip->publicKey->get();

header('Content-Type: application/json');
echo json_encode(['public_key' => $publicKey]);
19 changes: 11 additions & 8 deletions examples/api/purchase_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

# Use PurchaseBuilder for a simpler API
$purchase = \Chip\Builder\PurchaseBuilder::new()
->withBrandId($config['brand_id'])
->withProduct('Test Product', 100, 1)
->withClient('test@example.com', 'John Doe')
->withSuccessRedirect($config['basedUrl'] . '/api/redirect.php?success=1')
->withFailureRedirect($config['basedUrl'] . '/api/redirect.php?success=0')
->withSuccessCallback($config['basedUrl'] . '/api/callback.php')
$purchase = \Chip\Builder\PurchaseBuilder::create()
->brandId($config['brand_id'])
->currency('MYR')
->language('en')
->clientEmail('test@example.com')
->clientFullName('John Doe')
->addProduct('Test Product', 100)
->successRedirect($config['basedUrl'] . '/api/redirect.php?success=1')
->failureRedirect($config['basedUrl'] . '/api/redirect.php?success=0')
->successCallback($config['basedUrl'] . '/api/callback.php')
->build();

$result = $chip->createPurchase($purchase);
$result = $chip->purchases->create($purchase);

echo "<h2>Purchase Created via Builder</h2>";
echo "<pre><code>" . json_encode($result, JSON_PRETTY_PRINT) . "</code></pre>";
Expand Down
4 changes: 2 additions & 2 deletions examples/api/statements.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

# List all statements
$statements = $chip->listStatements();
$statements = $chip->statements->list();
echo "<h2>Statements</h2>";
echo "<pre><code>" . json_encode($statements, JSON_PRETTY_PRINT) . "</code></pre>";

# Schedule a new statement
$statement = new \Chip\Model\CompanyStatement();
$statement->format = 'json';

$scheduled = $chip->scheduleStatement($statement);
$scheduled = $chip->statements->schedule($statement);
echo "<h2>Scheduled Statement</h2>";
echo "<pre><code>" . json_encode($scheduled, JSON_PRETTY_PRINT) . "</code></pre>";
2 changes: 1 addition & 1 deletion examples/api/webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$xSignature = $headers['X-Signature'];

# Get public key via SDK
$publicKey = $chip->getPublicKey();
$publicKey = $chip->publicKey->get();

$verify = \Chip\ChipApi::verify($post, $xSignature, $publicKey);

Expand Down
12 changes: 6 additions & 6 deletions examples/api/webhook_management.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
$chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);

# List all webhooks
$webhooks = $chip->listWebhooks();
$webhooks = $chip->webhooks->list();
echo "<h2>Webhooks</h2>";
echo "<pre><code>" . json_encode($webhooks, JSON_PRETTY_PRINT) . "</code></pre>";

# Create a webhook
$webhook = new \Chip\Model\Webhook();
$webhook->url = $config['basedUrl'] . '/api/webhook.php';
$webhook->event_type = 'purchase.paid';
$webhook->title = 'My Webhook';
$webhook->callback = $config['basedUrl'] . '/api/webhook.php';

$created = $chip->createWebhook($webhook);
$created = $chip->webhooks->create($webhook);
echo "<h2>Created Webhook</h2>";
echo "<pre><code>" . json_encode($created, JSON_PRETTY_PRINT) . "</code></pre>";

# Update webhook
$webhookId = $created->id;
$webhook->url = $config['basedUrl'] . '/api/callback.php';
$updated = $chip->updateWebhook($webhookId, $webhook);
$webhook->callback = $config['basedUrl'] . '/api/callback.php';
$updated = $chip->webhooks->update($webhookId, $webhook);
echo "<h2>Updated Webhook</h2>";
echo "<pre><code>" . json_encode($updated, JSON_PRETTY_PRINT) . "</code></pre>";