Skip to content

Latest commit

 

History

History
144 lines (118 loc) · 4.83 KB

README.md

File metadata and controls

144 lines (118 loc) · 4.83 KB

Develop. Connect. Shipped. Tenang Pakai #KiriminAja.

This library is the abstraction of KiriminAja API for access from applications written with PHP.

Total Downloads Latest Stable Version License

Installation

Install kiriminaja-php with composer by following command:

composer require kiriminaja/kiriminaja-php

or add it manually in your composer.json file.

Usage

Configure package with your account's secret key obtained from KiriminAja Document Assignment.

// When on your dev/stag 
KiriminAjaConfig::setMode(Mode::Staging)::setApiTokenKey('YOUR_KEY');

// When on your production
KiriminAjaConfig::setMode(Mode::Production)::setApiTokenKey('YOUR_KEY');

Available Services

KiriminAja::getCity((int) $province_id);
KiriminAja::getDistrict((int) $district_id);
KiriminAja::getDistrictByName((string) $keyword);
KiriminAja::getProvince();
KiriminAja::setWhiteListExpedition((array) $services);
KiriminAja::setCallback((string) $url);
KiriminAja::getPrice(ShippingPriceData $data);
KiriminAja::requestPickup(RequestPickupData $data);
KiriminAja::getPayment((string) $payment_id);
KiriminAja::cancelShipment((string) $waybill,(string)  $reason);
KiriminAja::getTracking((string) $package_id);
KiriminAja::getSchedules();

Get Price Example

public function get_price() {
    $shipping_price_object = new ShippingPriceData;
    $shipping_price_object->origin = 1063;
    $shipping_price_object->destination = 1064;
    $shipping_price_object->weight = 1000;
    $shipping_price_object->insurance = 1;
    $shipping_price_object->item_value = 100000;
    $shipping_price_object->courier = ['jne', 'jnt', 'sicepat'];
    return KiriminAja::getPrice($shipping_price_object);
}

Request Pickup Example

public function request_pickup() {
    $pickup_object = new RequestPickupData;
    $pickup_object->address = "Jl. Jodipati No.29 Perum Taman Kencana Sejahtera";
    $pickup_object->phone = "082129627860";
    $pickup_object->name = "dipaferdian";
    $pickup_object->kecamatan_id = 5784;
    $pickup_object->schedule = "2022-11-03 17:00:00";
    $pickup_object->zipcode = 16610;
    $pickup_object->platform_name = 'mitra';
    // Array of packages
    $pickup_object->packages = [];

    // Package object
    $package_data = new PackageData;
    $package_data->order_id = "DEV-2300000024";
    $package_data->destination_name = "Flag Test3";
    $package_data->destination_phone = "082223323333";
    $package_data->destination_address = "Jl. Magelang KM 11";
    $package_data->destination_kecamatan_id = 419;
    $package_data->destination_zipcode = 55598;
    $package_data->weight = 520;
    $package_data->width = 8;
    $package_data->height = 8;
    $package_data->length = 8;
    $package_data->item_value = 275000;
    $package_data->shipping_cost = 65000;
    $package_data->service = "sicepat";
    $package_data->service_type = "SIUNT";
    $package_data->item_name = "Test item name";
    $package_data->package_type_id = 1;
    $package_data->cod = 0;
    $package_data->note = 'test pickup request non cod';
    $package_data->drop = true;
    
    // Bind package object to packages
    $pickup_object->packages = [$package_data];
    
    return KiriminAja::requestPickup($pickup_object);
}

Contributing

For any requests, bugs, or comments, please open an issue or submit a pull request.

Installing Packages

Before you start to code, run this command to install all of the required packages. Make sure you have composer installed in your computer

composer install

Tests

Running test suite:

vendor\bin\phpunit tests

Running examples:

php examples\InvoiceExample.php

There is a pre-commit hook to run phpcs and phpcbf. Please make sure they passed before making commits/pushes.