Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkarpetin committed Feb 26, 2024
1 parent d5bfaee commit 7a53787
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions examples/purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Rebilly\Sdk\Model\PlanFormulaFlatRate;
use Rebilly\Sdk\Model\PostTransactionRequest;
use Rebilly\Sdk\Model\Product;
use Rebilly\Sdk\Model\SubscriptionOrder;
use Rebilly\Sdk\Model\Subscription;
use Rebilly\Sdk\Model\SubscriptionOrderPlanRecurringInterval;
use Rebilly\Sdk\Model\Website;
use Rebilly\Sdk\UsersService;
Expand Down Expand Up @@ -108,9 +108,9 @@ function printEntity(mixed $entity): void
echo 'Plan: ' . $plan->getId() . PHP_EOL;
printEntity($plan);

// Create subscription order
// Create subscription

$order = SubscriptionOrder::from()
$subscription = Subscription::from()
->setWebsiteId($websiteId)
->setCustomerId($customer->getId())
->setItems([
Expand All @@ -122,15 +122,15 @@ function printEntity(mixed $entity): void
->setQuantity(1),
]);

printEntity($order);
printEntity($subscription);

/** @var SubscriptionOrder $order */
$order = $coreService->subscriptions()->create($order);
/** @var Subscription $subscription */
$subscription = $coreService->subscriptions()->create($subscription);

echo 'Order: ' . $order->getId() . PHP_EOL;
printEntity($order);
echo 'Subscription: ' . $subscription->getId() . PHP_EOL;
printEntity($subscription);

$invoice = $coreService->invoices()->get($order->getInitialInvoiceId());
$invoice = $coreService->invoices()->get($subscription->getInitialInvoiceId());

echo 'Initial invoice: ' . $invoice->getId() . PHP_EOL;
printEntity($invoice);
Expand Down Expand Up @@ -177,9 +177,9 @@ function printEntity(mixed $entity): void
echo 'Transaction: ' . $transaction->getId() . PHP_EOL;
printEntity($transaction);

$order = $coreService->subscriptions()->get($order->getId());
$subscription = $coreService->subscriptions()->get($subscription->getId());

printEntity($order);
printEntity($subscription);
} catch (DataValidationException $e) {
var_dump($e->getValidationErrors());
}

0 comments on commit 7a53787

Please sign in to comment.