los/mundiapi

Mundipagg API

1.0.0 2017-08-30 15:57 UTC

This package is auto-updated.

Last update: 2024-10-26 03:55:50 UTC


README

Mundipagg API

How to Build

The generated code has dependencies over external libraries like UniRest. These dependencies are defined in the composer.json file that comes with the SDK. To resolve these dependencies, we use the Composer package manager which requires PHP greater than 5.3.2 installed in your system. Visit https://getcomposer.org/download/ to download the installer file for Composer and run it in your system. Open command prompt and type composer --version. This should display the current version of the Composer installed if the installation was successful.

  • Using command line, navigate to the directory containing the generated files (including composer.json) for the SDK.
  • Run the command composer install. This should install all the required dependencies and create the vendor directory in your project directory.

Building SDK - Step 1

[For Windows Users Only] Configuring CURL Certificate Path in php.ini

CURL used to include a list of accepted CAs, but no longer bundles ANY CA certs. So by default it will reject all SSL certificates as unverifiable. You will have to get your CA's cert and point curl at it. The steps are as follows:

  1. Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
  2. Add curl.cainfo = "PATH_TO/cacert.pem" to your php.ini file located in your php installation. “PATH_TO” must be an absolute path containing the .pem file.
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =

How to Use

The following section explains how to use the MundiAPI library in a new project.

1. Open Project in an IDE

Open an IDE for PHP like PhpStorm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

Open project in PHPStorm - Step 1

Click on Open in PhpStorm to browse to your generated SDK directory and then click OK.

Open project in PHPStorm - Step 2

2. Add a new Test Project

Create a new directory by right clicking on the solution name as shown below:

Add a new project in PHPStorm - Step 1

Name the directory as "test"

Add a new project in PHPStorm - Step 2

Add a PHP file to this project

Add a new project in PHPStorm - Step 3

Name it "testSDK"

Add a new project in PHPStorm - Step 4

Depending on your project setup, you might need to include composer's autoloader in your PHP code to enable auto loading of classes.

require_once "../vendor/autoload.php";

It is important that the path inside require_once correctly points to the file autoload.php inside the vendor directory created during dependency installations.

Add a new project in PHPStorm - Step 4

After this you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.

3. Run the Test Project

To run your project you must set the Interpreter for your project. Interpreter is the PHP engine installed on your computer.

Open Settings from File menu.

Run Test Project - Step 1

Select PHP from within Languages & Frameworks

Run Test Project - Step 2

Browse for Interpreters near the Interpreter option and choose your interpreter.

Run Test Project - Step 3

Once the interpreter is selected, click OK

Run Test Project - Step 4

To run your project, right click on your PHP file inside your Test project and click on Run

Run Test Project - Step 5

How to Test

Unit tests in this SDK can be run using PHPUnit.

  1. First install the dependencies using composer including the require-dev dependencies.
  2. Run vendor\bin\phpunit --verbose from commandline to execute tests. If you have installed PHPUnit globally, run tests using phpunit --verbose instead.

You can change the PHPUnit test configuration in the phpunit.xml file.

Initialization

Authentication

In order to setup authentication and initialization of the API client, you need the following information.

API client can be initialized as following.

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

$client = new MundiAPILib\MundiAPIClient($basicAuthUserName, $basicAuthPassword);

Class Reference

List of Controllers

Class: ChargesController

Get singleton instance

The singleton instance of the ChargesController class can be accessed from the API Client.

$charges = $client->getCharges();

Method: getCharge

Get a charge from its id

function getCharge($chargeId)

Parameters

Example Usage

$chargeId = 'ch_wbnd47nCJJFKVZQy';

$result = $charges->getCharge($chargeId);

Method: retryCharge

Retries a charge

function retryCharge($chargeId)

Parameters

Example Usage

$chargeId = 'charge_id';

$result = $charges->retryCharge($chargeId);

Method: getCharges

Lists all charges

function getCharges()

Example Usage

$result = $charges->getCharges();

Method: createCharge

Creates a new charge

function createCharge($request)

Parameters

Example Usage

$request = new CreateChargeRequest();

$result = $charges->createCharge($request);

Method: updateChargeCard

Updates the card from a charge

function updateChargeCard(
        $chargeId,
        $request)

Parameters

Example Usage

$chargeId = 'charge_id';
$request = new UpdateChargeCardRequest();

$result = $charges->updateChargeCard($chargeId, $request);

Method: updateChargePaymentMethod

Updates a charge's payment method

function updateChargePaymentMethod(
        $chargeId,
        $request)

Parameters

Example Usage

$chargeId = 'charge_id';
$request = new UpdateChargePaymentMethodRequest();

$result = $charges->updateChargePaymentMethod($chargeId, $request);

Method: cancelCharge

Cancel a charge

function cancelCharge(
        $chargeId,
        $request = null)

Parameters

Example Usage

$chargeId = 'charge_id';
$request = new CreateCancelChargeRequest();

$result = $charges->cancelCharge($chargeId, $request);

Method: captureCharge

Captures a charge

function captureCharge(
        $chargeId,
        $request = null)

Parameters

Example Usage

$chargeId = 'charge_id';
$request = new CreateCaptureChargeRequest();

$result = $charges->captureCharge($chargeId, $request);

Back to List of Controllers

Class: CustomersController

Get singleton instance

The singleton instance of the CustomersController class can be accessed from the API Client.

$customers = $client->getCustomers();

Method: getAddresses

Gets all adressess from a customer

function getAddresses($customerId)

Parameters

Example Usage

$customerId = 'customer_id';

$result = $customers->getAddresses($customerId);

Method: getCards

Get all cards from a customer

function getCards($customerId)

Parameters

Example Usage

$customerId = 'customer_id';

$result = $customers->getCards($customerId);

Method: getCustomers

Get all Customers

function getCustomers()

Example Usage

$result = $customers->getCustomers();

Method: createCustomer

Creates a new customer

function createCustomer($request)

Parameters

Example Usage

$request = new CreateCustomerRequest();

$result = $customers->createCustomer($request);

Method: getCustomer

Get a customer

function getCustomer($customerId)

Parameters

Example Usage

$customerId = 'customer_id';

$result = $customers->getCustomer($customerId);

Method: updateAddress

Updates an address

function updateAddress(
        $customerId,
        $addressId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$addressId = 'address_id';
$request = new UpdateAddressRequest();

$result = $customers->updateAddress($customerId, $addressId, $request);

Method: updateCard

Updates a card

function updateCard(
        $customerId,
        $cardId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$cardId = 'card_id';
$request = new UpdateCardRequest();

$result = $customers->updateCard($customerId, $cardId, $request);

Method: getAddress

Get a customer's address

function getAddress(
        $customerId,
        $addressId)

Parameters

Example Usage

$customerId = 'customer_id';
$addressId = 'address_id';

$result = $customers->getAddress($customerId, $addressId);

Method: deleteAddress

Delete a Customer's address

function deleteAddress(
        $customerId,
        $addressId)

Parameters

Example Usage

$customerId = 'customer_id';
$addressId = 'address_id';

$result = $customers->deleteAddress($customerId, $addressId);

Method: deleteCard

Delete a customer's card

function deleteCard(
        $customerId,
        $cardId)

Parameters

Example Usage

$customerId = 'customer_id';
$cardId = 'card_id';

$result = $customers->deleteCard($customerId, $cardId);

Method: createAddress

Creates a new address for a customer

function createAddress(
        $customerId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$request = new CreateAddressRequest();

$result = $customers->createAddress($customerId, $request);

Method: getCard

Get a customer's card

function getCard(
        $customerId,
        $cardId)

Parameters

Example Usage

$customerId = 'customer_id';
$cardId = 'card_id';

$result = $customers->getCard($customerId, $cardId);

Method: createCard

Creates a new card for a customer

function createCard(
        $customerId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$request = new CreateCardRequest();

$result = $customers->createCard($customerId, $request);

Method: updateCustomer

Updates a customer

function updateCustomer(
        $customerId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$request = new UpdateCustomerRequest();

$result = $customers->updateCustomer($customerId, $request);

Method: deleteAccessTokens

Delete a Customer's access tokens

function deleteAccessTokens($customerId)

Parameters

Example Usage

$customerId = 'customer_id';

$result = $customers->deleteAccessTokens($customerId);

Method: getAccessTokens

Get all access tokens from a customer

function getAccessTokens($customerId)

Parameters

Example Usage

$customerId = 'customer_id';

$result = $customers->getAccessTokens($customerId);

Method: deleteAccessToken

Delete a customer's access token

function deleteAccessToken(
        $customerId,
        $tokenId)

Parameters

Example Usage

$customerId = 'customer_id';
$tokenId = 'token_id';

$result = $customers->deleteAccessToken($customerId, $tokenId);

Method: createAccessToken

Creates a access token for a customer

function createAccessToken(
        $customerId,
        $request)

Parameters

Example Usage

$customerId = 'customer_id';
$request = new CreateAccessTokenRequest();

$result = $customers->createAccessToken($customerId, $request);

Method: getAccessToken

Get a Customer's access token

function getAccessToken(
        $customerId,
        $tokenId)

Parameters

Example Usage

$customerId = 'customer_id';
$tokenId = 'token_id';

$result = $customers->getAccessToken($customerId, $tokenId);

Back to List of Controllers

Class: SubscriptionsController

Get singleton instance

The singleton instance of the SubscriptionsController class can be accessed from the API Client.

$subscriptions = $client->getSubscriptions();

Method: updateSubscriptionBillingDate

Updates the billing date from a subscription

function updateSubscriptionBillingDate(
        $subscriptionId,
        $request)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionBillingDateRequest();

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

Method: createUsage

Creates a usage

function createUsage(
        $subscriptionId,
        $itemId,
        $body)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$body = new CreateUsageRequest();

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

Method: updateSubscriptionItem

Updates a subscription item

function updateSubscriptionItem(
        $subscriptionId,
        $itemId,
        $body)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$body = new UpdateSubscriptionItemRequest();

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

Method: getSubscriptions

Gets all subscriptions

function getSubscriptions()

Example Usage

$result = $subscriptions->getSubscriptions();

Method: updateSubscriptionCard

Updates the credit card from a subscription

function updateSubscriptionCard(
        $subscriptionId,
        $request)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionCardRequest();

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

Method: createSubscription

Creates a new subscription

function createSubscription($body)

Parameters

Example Usage

$body = new CreateSubscriptionRequest();

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

Method: createSubscriptionItem

Creates a new Subscription item

function createSubscriptionItem(
        $subscriptionId,
        $request)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new CreateSubscriptionItemRequest();

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

Method: createDiscount

Creates a discount

function createDiscount(
        $subscriptionId,
        $request)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new CreateDiscountRequest();

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

Method: getSubscription

Gets a subscription

function getSubscription($subscriptionId)

Parameters

Example Usage

$subscriptionId = 'subscription_id';

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

Method: updateSubscriptionPaymentMethod

Updates the payment method from a subscription

function updateSubscriptionPaymentMethod(
        $subscriptionId,
        $request)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionPaymentMethodRequest();

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

Method: getUsages

Lists all usages from a subscription item

function getUsages(
        $subscriptionId,
        $itemId)

Parameters

Example Usage

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

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

Method: deleteUsage

Deletes a usage

function deleteUsage(
        $subscriptionId,
        $itemId,
        $usageId)

Parameters

Example Usage

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

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

Method: deleteDiscount

Deletes a discount

function deleteDiscount(
        $subscriptionId,
        $discountId)

Parameters

Example Usage

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

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

Method: cancelSubscription

Cancels a subscription

function cancelSubscription(
        $subscriptionId,
        $request = null)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$request = new CreateCancelSubscriptionRequest();

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

Method: deleteSubscriptionItem

Deletes a subscription item

function deleteSubscriptionItem(
        $subscriptionId,
        $subscriptionItemId)

Parameters

Example Usage

$subscriptionId = 'subscription_id';
$subscriptionItemId = 'subscription_item_id';

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

Back to List of Controllers

Class: PlansController

Get singleton instance

The singleton instance of the PlansController class can be accessed from the API Client.

$plans = $client->getPlans();

Method: getPlanItems

Gets all items from a plan

function getPlanItems($planId)

Parameters

Example Usage

$planId = 'plan_id';

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

Method: updatePlanItem

Updates a plan item

function updatePlanItem(
        $planId,
        $planItemId,
        $body)

Parameters

Example Usage

$planId = 'plan_id';
$planItemId = 'plan_item_id';
$body = new UpdatePlanItemRequest();

$result = $plans->updatePlanItem($planId, $planItemId, $body);

Method: getPlan

Gets a plan

function getPlan($planId)

Parameters

Example Usage

$planId = 'plan_id';

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

Method: createPlanItem

Adds a new item to a plan

function createPlanItem(
        $planId,
        $request)

Parameters

Example Usage

$planId = 'plan_id';
$request = new CreatePlanItemRequest();

$result = $plans->createPlanItem($planId, $request);

Method: updatePlan

Updates a plan

function updatePlan(
        $planId,
        $request)

Parameters

Example Usage

$planId = 'plan_id';
$request = new UpdatePlanRequest();

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

Method: createPlan

Creates a new plan

function createPlan($body)

Parameters

Example Usage

$body = new CreatePlanRequest();

$result = $plans->createPlan($body);

Method: getPlans

Gets all plans

function getPlans()

Example Usage

$result = $plans->getPlans();

Method: deletePlan

Deletes a plan

function deletePlan($planId)

Parameters

Example Usage

$planId = 'plan_id';

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

Method: getPlanItem

Gets a plan item

function getPlanItem(
        $planId,
        $planItemId)

Parameters

Example Usage

$planId = 'plan_id';
$planItemId = 'plan_item_id';

$result = $plans->getPlanItem($planId, $planItemId);

Method: deletePlanItem

Removes an item from a plan

function deletePlanItem(
        $planId,
        $planItemId)

Parameters

Example Usage

$planId = 'plan_id';
$planItemId = 'plan_item_id';

$result = $plans->deletePlanItem($planId, $planItemId);

Back to List of Controllers

Class: InvoicesController

Get singleton instance

The singleton instance of the InvoicesController class can be accessed from the API Client.

$invoices = $client->getInvoices();

Method: cancelInvoice

Cancels an invoice

function cancelInvoice($invoiceId)

Parameters

Example Usage

$invoiceId = 'invoice_id';

$result = $invoices->cancelInvoice($invoiceId);

Method: getLastInvoiceCharge

Gets the last charge from an invoice

function getLastInvoiceCharge($invoiceId)

Parameters

Example Usage

$invoiceId = 'invoice_id';

$result = $invoices->getLastInvoiceCharge($invoiceId);

Method: getInvoices

Gets all invoices

function getInvoices()

Example Usage

$result = $invoices->getInvoices();

Method: getInvoice

Gets an invoice

function getInvoice($invoiceId)

Parameters

Example Usage

$invoiceId = 'invoice_id';

$result = $invoices->getInvoice($invoiceId);

Back to List of Controllers

Class: OrdersController

Get singleton instance

The singleton instance of the OrdersController class can be accessed from the API Client.

$orders = $client->getOrders();

Method: getOrder

Gets an order

function getOrder($orderId)

Parameters

Example Usage

$orderId = 'order_id';

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

Method: getOrders

Gets all orders

function getOrders()

Example Usage

$result = $orders->getOrders();

Method: createOrder

Creates a new Order

function createOrder($body)

Parameters

Example Usage

$body = new CreateOrderRequest();

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

Back to List of Controllers