-
Notifications
You must be signed in to change notification settings - Fork 4
Quickstart
Reindert edited this page Oct 14, 2022
·
7 revisions
We need a token to be able to connect to the Plug&Pay dashboard. To create a token navigate to the admin dashboard of Plug&Pay.
- Click on "Settings" in the sidebar
- Click on "Developers" In the tab "Integrations"
- Sign the "Developer Agreement"
- Click on "Add new API key"
- Enter a name for your API key
For more information about the client go to: Home.
use PlugAndPay\Sdk\Service\Client;
$client = new Client('your_access_token');
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\ProductService;
$client = new Client('your_access_token');
$productService = new ProductService($client);
$products = $productService->get();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\ProductService;
$client = new Client('your_access_token');
$productService = new ProductService($client);
$productId = 1;
$product = $productService->find($productId);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\ProductService;
use PlugAndPay\Sdk\Entity\Product;
$client = new Client('your_access_token');
$productService = new ProductService($client);
$product = (new Product())
->setTitle('Product Title')
->setPhysical(false);
$product = $productService->create($product);
$productId = $product->id();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\ProductService;
use PlugAndPay\Sdk\Entity\Product;
$client = new Client('your_access_token');
$productService = new ProductService($client);
$productId = 1;
$productService->update(
$productId,
fn(Product $product) => $product->setTitle('Updated Product Title')
);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\ProductService;
$client = new Client('your_access_token');
$productService = new ProductService($client);
$productId = 1;
$productService->delete($productId);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\OrderService;
$client = new Client('your_access_token');
$orderService = new OrderService($client);
$orders = $orderService->get();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\OrderService;
$client = new Client('your_access_token');
$orderService = new OrderService($client);
$orderId = 1;
$orders = $orderService->find($orderId);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\OrderService;
use PlugAndPay\Sdk\Service\TaxRateService;
use PlugAndPay\Sdk\Entity\Order;
use PlugAndPay\Sdk\Entity\OrderBilling;
use PlugAndPay\Sdk\Entity\Contact;
use PlugAndPay\Sdk\Entity\Address;
use PlugAndPay\Sdk\Entity\Payment;
use PlugAndPay\Sdk\Entity\Item;
use PlugAndPay\Sdk\Enum\CountryCode;
use PlugAndPay\Sdk\Enum\PaymentType;
use PlugAndPay\Sdk\Filters\TaxRateFilter;
$client = new Client('your_access_token');
$orderService = new OrderService($client);
$taxService = new TaxRateService($client);
$taxFilter = (new TaxRateFilter())->country(CountryCode::NL);
$taxRates = $taxService->get($taxFilter);
$item = (new Item)
->setAmount(10.50)
->setLabel('Label')
->setTaxByRateId($taxRates[0]->id());
$payment = (new Payment)
->setType(PaymentType::MANUAL);
$address = (new Address())
->setCountry(CountryCode::NL);
$contact = (new Contact())
->setFirstName('First')
->setLastName('Last')
->setEmail('[email protected]');
$billing = (new OrderBilling())
->setContact($contact)
->setAddress($address);
$order = (new Order())
->setBilling($billing)
->setPayment($payment)
->setItems([$item]);
$order = $orderService->create($order);
$orderId = $order->id();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\OrderService;
use PlugAndPay\Sdk\Entity\Order;
$client = new Client('your_access_token');
$orderService = new OrderService($client);
$orderId = 1;
$orderService->update(
$orderId,
fn(Order $order) => $order->setAmount(100)
);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\OrderService;
$client = new Client('your_access_token');
$orderService = new OrderService($client);
$orderId = 1;
$orderService->delete($orderId);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\SubscriptionService;
$client = new Client('your_access_token');
$subscriptionService = new SubscriptionService($client);
$subscriptions = $subscriptionService->get();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\SubscriptionService;
$client = new Client('your_access_token');
$subscriptionService = new SubscriptionService($client);
$subscriptionId = 1;
$subscription = $subscriptionService->find($subscriptionId);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\SubscriptionService;
use PlugAndPay\Sdk\Entity\Subscription;
use PlugAndPay\Sdk\Entity\SubscriptionBilling;
use PlugAndPay\Sdk\Entity\Contact;
use PlugAndPay\Sdk\Entity\Address;
use PlugAndPay\Sdk\Entity\SubscriptionPaymentOptions;
use PlugAndPay\Sdk\Entity\SubscriptionBillingSchedule;
use PlugAndPay\Sdk\Entity\SubscriptionPricing;
use PlugAndPay\Sdk\Entity\Tax;
use PlugAndPay\Sdk\Enum\Interval;
use PlugAndPay\Sdk\Enum\CountryCode;
use PlugAndPay\Sdk\Enum\PaymentType;
$client = new Client('your_access_token');
$subscriptionService = new SubscriptionService($client);
$tax = (new Tax())
->setAmount(10.00);
$pricing = (new SubscriptionPricing())
->setQuantity(10)
->setTax($tax);
$billingSchedule = (new SubscriptionBillingSchedule())
->setInterval(Interval::MONTHLY)
->setNextAt(new \DateTimeImmutable());
$paymentOptions = (new SubscriptionPaymentOptions())
->setType(PaymentType::MANUAL);
$address = (new Address())
->setCountry(CountryCode::NL);
$contact = (new Contact())
->setFirstName('Last')
->setLastName('Last')
->setEmail('[email protected]');
$billing = (new SubscriptionBilling())
->setContact($contact)
->setAddress($address)
->setPaymentOptions($paymentOptions)
->setSchedule($billingSchedule);
$subscription = (new Subscription())
->setBilling($billing)
->setPricing($pricing)
->setProductId(7);
$subscription = $subscriptionService->create($subscription);
$subscriptionId = $subscription->id();
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\SubscriptionService;
use PlugAndPay\Sdk\Entity\Subscription;
use PlugAndPay\Sdk\Enum\Mode;
$client = new Client('your_access_token');
$subscriptionService = new SubscriptionService($client);
$subscriptionId = 1;
$subscriptionService->update(
$subscriptionId,
fn(Subscription $subscription) => $subscription->setMode(Mode::TEST)
);
use PlugAndPay\Sdk\Service\Client;
use PlugAndPay\Sdk\Service\SubscriptionService;
use PlugAndPay\Sdk\Entity\Subscription;
$client = new Client('your_access_token');
$subscriptionService = new SubscriptionService($client);
$subscriptionId = 1;
$subscriptionService->delete($subscriptionId);