Mundipagg API
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 thevendor
directory in your project directory.
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:
- Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
- 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 =
The following section explains how to use the MundiAPI library in a new project.
Open an IDE for PHP like PhpStorm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on Open
in PhpStorm to browse to your generated SDK directory and then click OK
.
Create a new directory by right clicking on the solution name as shown below:
Name the directory as "test"
Add a PHP file to this project
Name it "testSDK"
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.
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.
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.
Select PHP
from within Languages & Frameworks
Browse for Interpreters near the Interpreter
option and choose your interpreter.
Once the interpreter is selected, click OK
To run your project, right click on your PHP file inside your Test project and click on Run
Unit tests in this SDK can be run using PHPUnit.
- First install the dependencies using composer including the
require-dev
dependencies. - Run
vendor\bin\phpunit --verbose
from commandline to execute tests. If you have installed PHPUnit globally, run tests usingphpunit --verbose
instead.
You can change the PHPUnit test configuration in the phpunit.xml
file.
In order to setup authentication and initialization of the API client, you need the following information.
Parameter | Description |
---|---|
basicAuthUserName | The username to use with basic authentication |
basicAuthPassword | The password to use with basic authentication |
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);
- ChargesController
- CustomersController
- SubscriptionsController
- PlansController
- InvoicesController
- OrdersController
The singleton instance of the ChargesController
class can be accessed from the API Client.
$charges = $client->getCharges();
Get a charge from its id
function getCharge($chargeId)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
$chargeId = 'ch_wbnd47nCJJFKVZQy';
$result = $charges->getCharge($chargeId);
Retries a charge
function retryCharge($chargeId)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
$chargeId = 'charge_id';
$result = $charges->retryCharge($chargeId);
Lists all charges
function getCharges()
$result = $charges->getCharges();
Creates a new charge
function createCharge($request)
Parameter | Tags | Description |
---|---|---|
request | Required |
Request for creating a charge |
$request = new CreateChargeRequest();
$result = $charges->createCharge($request);
Updates the card from a charge
function updateChargeCard(
$chargeId,
$request)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
request | Required |
Request for updating a charge's card |
$chargeId = 'charge_id';
$request = new UpdateChargeCardRequest();
$result = $charges->updateChargeCard($chargeId, $request);
Updates a charge's payment method
function updateChargePaymentMethod(
$chargeId,
$request)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
request | Required |
Request for updating the payment method from a charge |
$chargeId = 'charge_id';
$request = new UpdateChargePaymentMethodRequest();
$result = $charges->updateChargePaymentMethod($chargeId, $request);
Cancel a charge
function cancelCharge(
$chargeId,
$request = null)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
request | Optional |
Request for cancelling a charge |
$chargeId = 'charge_id';
$request = new CreateCancelChargeRequest();
$result = $charges->cancelCharge($chargeId, $request);
Captures a charge
function captureCharge(
$chargeId,
$request = null)
Parameter | Tags | Description |
---|---|---|
chargeId | Required |
Charge id |
request | Optional |
Request for capturing a charge |
$chargeId = 'charge_id';
$request = new CreateCaptureChargeRequest();
$result = $charges->captureCharge($chargeId, $request);
The singleton instance of the CustomersController
class can be accessed from the API Client.
$customers = $client->getCustomers();
Gets all adressess from a customer
function getAddresses($customerId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer id |
$customerId = 'customer_id';
$result = $customers->getAddresses($customerId);
Get all cards from a customer
function getCards($customerId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
$customerId = 'customer_id';
$result = $customers->getCards($customerId);
Get all Customers
function getCustomers()
$result = $customers->getCustomers();
Creates a new customer
function createCustomer($request)
Parameter | Tags | Description |
---|---|---|
request | Required |
Request for creating a customer |
$request = new CreateCustomerRequest();
$result = $customers->createCustomer($request);
Get a customer
function getCustomer($customerId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
$customerId = 'customer_id';
$result = $customers->getCustomer($customerId);
Updates an address
function updateAddress(
$customerId,
$addressId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
addressId | Required |
Address Id |
request | Required |
Request for updating an address |
$customerId = 'customer_id';
$addressId = 'address_id';
$request = new UpdateAddressRequest();
$result = $customers->updateAddress($customerId, $addressId, $request);
Updates a card
function updateCard(
$customerId,
$cardId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
cardId | Required |
Card id |
request | Required |
Request for updating a card |
$customerId = 'customer_id';
$cardId = 'card_id';
$request = new UpdateCardRequest();
$result = $customers->updateCard($customerId, $cardId, $request);
Get a customer's address
function getAddress(
$customerId,
$addressId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer id |
addressId | Required |
Address Id |
$customerId = 'customer_id';
$addressId = 'address_id';
$result = $customers->getAddress($customerId, $addressId);
Delete a Customer's address
function deleteAddress(
$customerId,
$addressId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
addressId | Required |
Address Id |
$customerId = 'customer_id';
$addressId = 'address_id';
$result = $customers->deleteAddress($customerId, $addressId);
Delete a customer's card
function deleteCard(
$customerId,
$cardId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
cardId | Required |
Card Id |
$customerId = 'customer_id';
$cardId = 'card_id';
$result = $customers->deleteCard($customerId, $cardId);
Creates a new address for a customer
function createAddress(
$customerId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
request | Required |
Request for creating an address |
$customerId = 'customer_id';
$request = new CreateAddressRequest();
$result = $customers->createAddress($customerId, $request);
Get a customer's card
function getCard(
$customerId,
$cardId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer id |
cardId | Required |
Card id |
$customerId = 'customer_id';
$cardId = 'card_id';
$result = $customers->getCard($customerId, $cardId);
Creates a new card for a customer
function createCard(
$customerId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer id |
request | Required |
Request for creating a card |
$customerId = 'customer_id';
$request = new CreateCardRequest();
$result = $customers->createCard($customerId, $request);
Updates a customer
function updateCustomer(
$customerId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer id |
request | Required |
Request for updating a customer |
$customerId = 'customer_id';
$request = new UpdateCustomerRequest();
$result = $customers->updateCustomer($customerId, $request);
Delete a Customer's access tokens
function deleteAccessTokens($customerId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
$customerId = 'customer_id';
$result = $customers->deleteAccessTokens($customerId);
Get all access tokens from a customer
function getAccessTokens($customerId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
$customerId = 'customer_id';
$result = $customers->getAccessTokens($customerId);
Delete a customer's access token
function deleteAccessToken(
$customerId,
$tokenId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
tokenId | Required |
Token Id |
$customerId = 'customer_id';
$tokenId = 'token_id';
$result = $customers->deleteAccessToken($customerId, $tokenId);
Creates a access token for a customer
function createAccessToken(
$customerId,
$request)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
request | Required |
Request for creating a access token |
$customerId = 'customer_id';
$request = new CreateAccessTokenRequest();
$result = $customers->createAccessToken($customerId, $request);
Get a Customer's access token
function getAccessToken(
$customerId,
$tokenId)
Parameter | Tags | Description |
---|---|---|
customerId | Required |
Customer Id |
tokenId | Required |
Token Id |
$customerId = 'customer_id';
$tokenId = 'token_id';
$result = $customers->getAccessToken($customerId, $tokenId);
The singleton instance of the SubscriptionsController
class can be accessed from the API Client.
$subscriptions = $client->getSubscriptions();
Updates the billing date from a subscription
function updateSubscriptionBillingDate(
$subscriptionId,
$request)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
The subscription id |
request | Required |
Request for updating the subscription billing date |
$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionBillingDateRequest();
$result = $subscriptions->updateSubscriptionBillingDate($subscriptionId, $request);
Creates a usage
function createUsage(
$subscriptionId,
$itemId,
$body)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription Id |
itemId | Required |
Item id |
body | Required |
Request for creating a usage |
$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$body = new CreateUsageRequest();
$result = $subscriptions->createUsage($subscriptionId, $itemId, $body);
Updates a subscription item
function updateSubscriptionItem(
$subscriptionId,
$itemId,
$body)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription Id |
itemId | Required |
Item id |
body | Required |
Request for updating a subscription item |
$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$body = new UpdateSubscriptionItemRequest();
$result = $subscriptions->updateSubscriptionItem($subscriptionId, $itemId, $body);
Gets all subscriptions
function getSubscriptions()
$result = $subscriptions->getSubscriptions();
Updates the credit card from a subscription
function updateSubscriptionCard(
$subscriptionId,
$request)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
request | Required |
Request for updating a card |
$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionCardRequest();
$result = $subscriptions->updateSubscriptionCard($subscriptionId, $request);
Creates a new subscription
function createSubscription($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
Request for creating a subscription |
$body = new CreateSubscriptionRequest();
$result = $subscriptions->createSubscription($body);
Creates a new Subscription item
function createSubscriptionItem(
$subscriptionId,
$request)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
request | Required |
Request for creating a subscription item |
$subscriptionId = 'subscription_id';
$request = new CreateSubscriptionItemRequest();
$result = $subscriptions->createSubscriptionItem($subscriptionId, $request);
Creates a discount
function createDiscount(
$subscriptionId,
$request)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
request | Required |
Request for creating a discount |
$subscriptionId = 'subscription_id';
$request = new CreateDiscountRequest();
$result = $subscriptions->createDiscount($subscriptionId, $request);
Gets a subscription
function getSubscription($subscriptionId)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
$subscriptionId = 'subscription_id';
$result = $subscriptions->getSubscription($subscriptionId);
Updates the payment method from a subscription
function updateSubscriptionPaymentMethod(
$subscriptionId,
$request)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
request | Required |
Request for updating the paymentmethod from a subscription |
$subscriptionId = 'subscription_id';
$request = new UpdateSubscriptionPaymentMethodRequest();
$result = $subscriptions->updateSubscriptionPaymentMethod($subscriptionId, $request);
Lists all usages from a subscription item
function getUsages(
$subscriptionId,
$itemId)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
The subscription id |
itemId | Required |
The subscription item id |
$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$result = $subscriptions->getUsages($subscriptionId, $itemId);
Deletes a usage
function deleteUsage(
$subscriptionId,
$itemId,
$usageId)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
The subscription id |
itemId | Required |
The subscription item id |
usageId | Required |
The usage id |
$subscriptionId = 'subscription_id';
$itemId = 'item_id';
$usageId = 'usage_id';
$result = $subscriptions->deleteUsage($subscriptionId, $itemId, $usageId);
Deletes a discount
function deleteDiscount(
$subscriptionId,
$discountId)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
discountId | Required |
Discount Id |
$subscriptionId = 'subscription_id';
$discountId = 'discount_id';
$result = $subscriptions->deleteDiscount($subscriptionId, $discountId);
Cancels a subscription
function cancelSubscription(
$subscriptionId,
$request = null)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
request | Optional |
Request for cancelling a subscription |
$subscriptionId = 'subscription_id';
$request = new CreateCancelSubscriptionRequest();
$result = $subscriptions->cancelSubscription($subscriptionId, $request);
Deletes a subscription item
function deleteSubscriptionItem(
$subscriptionId,
$subscriptionItemId)
Parameter | Tags | Description |
---|---|---|
subscriptionId | Required |
Subscription id |
subscriptionItemId | Required |
Subscription item id |
$subscriptionId = 'subscription_id';
$subscriptionItemId = 'subscription_item_id';
$result = $subscriptions->deleteSubscriptionItem($subscriptionId, $subscriptionItemId);
The singleton instance of the PlansController
class can be accessed from the API Client.
$plans = $client->getPlans();
Gets all items from a plan
function getPlanItems($planId)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
$planId = 'plan_id';
$result = $plans->getPlanItems($planId);
Updates a plan item
function updatePlanItem(
$planId,
$planItemId,
$body)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
planItemId | Required |
Plan item id |
body | Required |
Request for updating the plan item |
$planId = 'plan_id';
$planItemId = 'plan_item_id';
$body = new UpdatePlanItemRequest();
$result = $plans->updatePlanItem($planId, $planItemId, $body);
Gets a plan
function getPlan($planId)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
$planId = 'plan_id';
$result = $plans->getPlan($planId);
Adds a new item to a plan
function createPlanItem(
$planId,
$request)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
request | Required |
Request for creating a plan item |
$planId = 'plan_id';
$request = new CreatePlanItemRequest();
$result = $plans->createPlanItem($planId, $request);
Updates a plan
function updatePlan(
$planId,
$request)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
request | Required |
Request for updating a plan |
$planId = 'plan_id';
$request = new UpdatePlanRequest();
$result = $plans->updatePlan($planId, $request);
Creates a new plan
function createPlan($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
Request for creating a plan |
$body = new CreatePlanRequest();
$result = $plans->createPlan($body);
Gets all plans
function getPlans()
$result = $plans->getPlans();
Deletes a plan
function deletePlan($planId)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
$planId = 'plan_id';
$result = $plans->deletePlan($planId);
Gets a plan item
function getPlanItem(
$planId,
$planItemId)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
planItemId | Required |
Plan item id |
$planId = 'plan_id';
$planItemId = 'plan_item_id';
$result = $plans->getPlanItem($planId, $planItemId);
Removes an item from a plan
function deletePlanItem(
$planId,
$planItemId)
Parameter | Tags | Description |
---|---|---|
planId | Required |
Plan id |
planItemId | Required |
Plan item id |
$planId = 'plan_id';
$planItemId = 'plan_item_id';
$result = $plans->deletePlanItem($planId, $planItemId);
The singleton instance of the InvoicesController
class can be accessed from the API Client.
$invoices = $client->getInvoices();
Cancels an invoice
function cancelInvoice($invoiceId)
Parameter | Tags | Description |
---|---|---|
invoiceId | Required |
Invoice id |
$invoiceId = 'invoice_id';
$result = $invoices->cancelInvoice($invoiceId);
Gets the last charge from an invoice
function getLastInvoiceCharge($invoiceId)
Parameter | Tags | Description |
---|---|---|
invoiceId | Required |
Invoice id |
$invoiceId = 'invoice_id';
$result = $invoices->getLastInvoiceCharge($invoiceId);
Gets all invoices
function getInvoices()
$result = $invoices->getInvoices();
Gets an invoice
function getInvoice($invoiceId)
Parameter | Tags | Description |
---|---|---|
invoiceId | Required |
Invoice Id |
$invoiceId = 'invoice_id';
$result = $invoices->getInvoice($invoiceId);
The singleton instance of the OrdersController
class can be accessed from the API Client.
$orders = $client->getOrders();
Gets an order
function getOrder($orderId)
Parameter | Tags | Description |
---|---|---|
orderId | Required |
Order id |
$orderId = 'order_id';
$result = $orders->getOrder($orderId);
Gets all orders
function getOrders()
$result = $orders->getOrders();
Creates a new Order
function createOrder($body)
Parameter | Tags | Description |
---|---|---|
body | Required |
Request for creating an order |
$body = new CreateOrderRequest();
$result = $orders->createOrder($body);