PHP code example of pagarme / pagarmecoreapi

1. Go to this page and download the library: Download pagarme/pagarmecoreapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pagarme / pagarmecoreapi example snippets



$serviceRefererName = 'serviceRefererName';
$basicAuthUserName = 'basicAuthUserName'; // The username to use with basic authentication
$basicAuthPassword = 'basicAuthPassword'; // The password to use with basic authentication

$client = new PagarmeCoreApiLib\PagarmeCoreApiClient($serviceRefererName, $basicAuthUserName, $basicAuthPassword);

$subscriptions = $client->getSubscriptions();

function updateSubscriptionCard(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionCardRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionCard($subscriptionId, $body, $idempotencyKey);


function deleteUsage(
        $subscriptionId,
        $itemId,
        $usageId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$usageId = 'usage_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->deleteUsage($subscriptionId, $itemId, $usageId, $idempotencyKey);


function createDiscount(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new CreateDiscountRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->createDiscount($subscriptionId, $body, $idempotencyKey);


function createAnUsage(
        $subscriptionId,
        $itemId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->createAnUsage($subscriptionId, $itemId, $idempotencyKey);


function getUsages(
        $subscriptionId,
        $itemId,
        $page = null,
        $size = null,
        $code = null,
        $group = null,
        $usedSince = null,
        $usedUntil = null)

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$page = 69;
$size = 69;
$code = 'code';
$group = 'group';
$usedSince = date("D M d, Y G:i");
$usedUntil = date("D M d, Y G:i");

$result = $subscriptions->getUsages($subscriptionId, $itemId, $page, $size, $code, $group, $usedSince, $usedUntil);


function updateCurrentCycleStatus(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateCurrentCycleStatusRequest();
$idempotencyKey = 'idempotency-key';

$subscriptions->updateCurrentCycleStatus($subscriptionId, $body, $idempotencyKey);


function updateSubscriptionPaymentMethod(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionPaymentMethodRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionPaymentMethod($subscriptionId, $body, $idempotencyKey);


function deleteDiscount(
        $subscriptionId,
        $discountId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$discountId = 'discount_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->deleteDiscount($subscriptionId, $discountId, $idempotencyKey);


function getSubscriptionItems(
        $subscriptionId,
        $page = null,
        $size = null,
        $name = null,
        $code = null,
        $status = null,
        $description = null,
        $createdSince = null,
        $createdUntil = null)

$subscriptionId = 'subscription_id';
$page = 69;
$size = 69;
$name = 'name';
$code = 'code';
$status = 'status';
$description = 'description';
$createdSince = 'created_since';
$createdUntil = 'created_until';

$result = $subscriptions->getSubscriptionItems($subscriptionId, $page, $size, $name, $code, $status, $description, $createdSince, $createdUntil);


function createSubscriptionItem(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new CreateSubscriptionItemRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->createSubscriptionItem($subscriptionId, $body, $idempotencyKey);


function getSubscriptionItem(
        $subscriptionId,
        $itemId)

$subscriptionId = 'subscription_id';
$itemId = 'item_id';

$result = $subscriptions->getSubscriptionItem($subscriptionId, $itemId);


function updateSubscriptionItem(
        $subscriptionId,
        $itemId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$body = new UpdateSubscriptionItemRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionItem($subscriptionId, $itemId, $body, $idempotencyKey);


function getSubscriptions(
        $page = null,
        $size = null,
        $code = null,
        $billingType = null,
        $customerId = null,
        $planId = null,
        $cardId = null,
        $status = null,
        $nextBillingSince = null,
        $nextBillingUntil = null,
        $createdSince = null,
        $createdUntil = null)

$page = 160;
$size = 160;
$code = 'code';
$billingType = 'billing_type';
$customerId = 'customer_id';
$planId = 'plan_id';
$cardId = 'card_id';
$status = 'status';
$nextBillingSince = date("D M d, Y G:i");
$nextBillingUntil = date("D M d, Y G:i");
$createdSince = date("D M d, Y G:i");
$createdUntil = date("D M d, Y G:i");

$result = $subscriptions->getSubscriptions($page, $size, $code, $billingType, $customerId, $planId, $cardId, $status, $nextBillingSince, $nextBillingUntil, $createdSince, $createdUntil);


function createSubscription(
        $body,
        $idempotencyKey = null)

$body = new CreateSubscriptionRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->createSubscription($body, $idempotencyKey);


function cancelSubscription(
        $subscriptionId,
        $idempotencyKey = null,
        $body = null)

$subscriptionId = 'subscription_id';
$idempotencyKey = 'idempotency-key';
$body = new CreateCancelSubscriptionRequest();

$result = $subscriptions->cancelSubscription($subscriptionId, $idempotencyKey, $body);


function getSubscription($subscriptionId)

$subscriptionId = 'subscription_id';

$result = $subscriptions->getSubscription($subscriptionId);


function createIncrement(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new CreateIncrementRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->createIncrement($subscriptionId, $body, $idempotencyKey);


function getDiscountById(
        $subscriptionId,
        $discountId)

$subscriptionId = 'subscription_id';
$discountId = 'discountId';

$result = $subscriptions->getDiscountById($subscriptionId, $discountId);


function updateSubscriptionAffiliationId(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionAffiliationIdRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionAffiliationId($subscriptionId, $body, $idempotencyKey);


function updateSubscriptionMetadata(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateMetadataRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionMetadata($subscriptionId, $body, $idempotencyKey);


function deleteIncrement(
        $subscriptionId,
        $incrementId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$incrementId = 'increment_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->deleteIncrement($subscriptionId, $incrementId, $idempotencyKey);


function getIncrementById(
        $subscriptionId,
        $incrementId)

$subscriptionId = 'subscription_id';
$incrementId = 'increment_id';

$result = $subscriptions->getIncrementById($subscriptionId, $incrementId);


function getSubscriptionCycles(
        $subscriptionId,
        $page,
        $size)

$subscriptionId = 'subscription_id';
$page = 'page';
$size = 'size';

$result = $subscriptions->getSubscriptionCycles($subscriptionId, $page, $size);


function renewSubscription(
        $subscriptionId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->renewSubscription($subscriptionId, $idempotencyKey);


function getDiscounts(
        $subscriptionId,
        $page,
        $size)

$subscriptionId = 'subscription_id';
$page = 160;
$size = 160;

$result = $subscriptions->getDiscounts($subscriptionId, $page, $size);


function updateSubscriptionBillingDate(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionBillingDateRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionBillingDate($subscriptionId, $body, $idempotencyKey);


function deleteSubscriptionItem(
        $subscriptionId,
        $subscriptionItemId,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$subscriptionItemId = 'subscription_item_id';
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->deleteSubscriptionItem($subscriptionId, $subscriptionItemId, $idempotencyKey);


function getIncrements(
        $subscriptionId,
        $page = null,
        $size = null)

$subscriptionId = 'subscription_id';
$page = 160;
$size = 160;

$result = $subscriptions->getIncrements($subscriptionId, $page, $size);


function updateSubscriptionDueDays(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionDueDaysRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionDueDays($subscriptionId, $body, $idempotencyKey);


function updateSubscriptionStartAt(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionStartAtRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionStartAt($subscriptionId, $body, $idempotencyKey);


function updateLatestPeriodEndAt(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateCurrentCycleEndDateRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateLatestPeriodEndAt($subscriptionId, $body, $idempotencyKey);


function updateSubscriptionMiniumPrice(
        $subscriptionId,
        $body,
        $idempotencyKey = null)

$subscriptionId = 'subscription_id';
$body = new UpdateSubscriptionMinimumPriceRequest();
$idempotencyKey = 'idempotency-key';

$result = $subscriptions->updateSubscriptionMiniumPrice($subscriptionId, $body, $idempotencyKey);


function getSubscriptionCycleById(
        $subscriptionId,
        $cycleId)

$subscriptionId = 'subscription_id';
$cycleId = 'cycleId';

$result = $subscriptions->getSubscriptionCycleById($subscriptionId, $cycleId);


function getUsageReport(
        $subscriptionId,
        $periodId)

$subscriptionId = 'subscription_id';
$periodId = 'period_id';

$result = $subscriptions->getUsageReport($subscriptionId, $periodId);


function updateSplitSubscription(
        $id,
        $body)

$id = 'id';
$body = new UpdateSubscriptionSplitRequest();

$result = $subscriptions->updateSplitSubscription($id, $body);


$orders = $client->getOrders();

function getOrders(
        $page = null,
        $size = null,
        $code = null,
        $status = null,
        $createdSince = null,
        $createdUntil = null,
        $customerId = null)

$page = 160;
$size = 160;
$code = 'code';
$status = 'status';
$createdSince = date("D M d, Y G:i");
$createdUntil = date("D M d, Y G:i");
$customerId = 'customer_id';

$result = $orders->getOrders($page, $size, $code, $status, $createdSince, $createdUntil, $customerId);


function createOrder(
        $body,
        $idempotencyKey = null)

$body = new CreateOrderRequest();
$idempotencyKey = 'idempotency-key';

$result = $orders->createOrder($body, $idempotencyKey);


function deleteAllOrderItems(
        $orderId,
        $idempotencyKey = null)

$orderId = 'orderId';
$idempotencyKey = 'idempotency-key';

$result = $orders->deleteAllOrderItems($orderId, $idempotencyKey);


function createOrderItem(
        $orderId,
        $body,
        $idempotencyKey = null)

$orderId = 'orderId';
$body = new CreateOrderItemRequest();
$idempotencyKey = 'idempotency-key';

$result = $orders->createOrderItem($orderId, $body, $idempotencyKey);


function updateOrderItem(
        $orderId,
        $itemId,
        $body,
        $idempotencyKey = null)

$orderId = 'orderId';
$itemId = 'itemId';
$body = new UpdateOrderItemRequest();
$idempotencyKey = 'idempotency-key';

$result = $orders->updateOrderItem($orderId, $itemId, $body, $idempotencyKey);


function deleteOrderItem(
        $orderId,
        $itemId,
        $idempotencyKey = null)

$orderId = 'orderId';
$itemId = 'itemId';
$idempotencyKey = 'idempotency-key';

$result = $orders->deleteOrderItem($orderId, $itemId, $idempotencyKey);


function getOrderItem(
        $orderId,
        $itemId)

$orderId = 'orderId';
$itemId = 'itemId';

$result = $orders->getOrderItem($orderId, $itemId);


function closeOrder(
        $id,
        $body,
        $idempotencyKey = null)

$id = 'id';
$body = new UpdateOrderStatusRequest();
$idempotencyKey = 'idempotency-key';

$result = $orders->closeOrder($id, $body, $idempotencyKey);


function updateOrderMetadata(
        $orderId,
        $body,
        $idempotencyKey = null)

$orderId = 'order_id';
$body = new UpdateMetadataRequest();
$idempotencyKey = 'idempotency-key';

$result = $orders->updateOrderMetadata($orderId, $body, $idempotencyKey);


function getOrder($orderId)

$orderId = 'order_id';

$result = $orders->getOrder($orderId);


$plans = $client->getPlans();

function getPlan($planId)

$planId = 'plan_id';

$result = $plans->getPlan($planId);


function updatePlan(
        $planId,
        $body,
        $idempotencyKey = null)

$planId = 'plan_id';
$body = new UpdatePlanRequest();
$idempotencyKey = 'idempotency-key';

$result = $plans->updatePlan($planId, $body, $idempotencyKey);

autoload.php