grim-reapper / xero
XERO Auth2 integration
1.1.0
2021-11-12 13:02 UTC
Requires
- php: ^7.3|^8.0
- xeroapi/xero-php-oauth2: ^2.9.0
This package is auto-updated.
Last update: 2025-02-19 12:51:39 UTC
README
#Xero OAuth2.0 API Integration
This package is just created to use in personal project, so all the function implemented according to our personal project. Please check this before use it.
// To use this package you have to extend it, create your own PHP class and extend this. class YourClassName extends \GrimReapper\Xero\Xero{ // then override it constructor public function __construct(array $params) { if(!empty($params)) { parent::__construct($params['client_id'], $params['client_secret'], $params['redirect_uri']); } } // that's it }
Create your class object first
$object = new YourClassName();
To get Authorize URL
$data = $object->getAuthorizeURL(); // it will return array containing URL and State Code $state = $data['state']; // this is used to verify state after api redirect to prevent xss $url = $data['url']; // use this url to redirect to Xero website for Authentication
To add scopes
$object->setScopes(['scope1','scope2']);
To get Access Token after redirection to your site
$code = $_GET['code']; // get code param from url and pass it to function $accessToken = $object->getAccessToken($code);
To create contact
$contact = $object->createContact(array $contactData);
To get a contact
$contact = $object->getContact(string $emailAddress);
To create an invoice
$invoice = $object->createInvoice(array $invoiceData);
To create a Payment
$payment = $object->createPayment($invoiceID, $account_code, $amount, $date);
To create a Credit Note
$creditNote = $object->createCreditNotes(array $creditNotesData, bool $returnObj = false);
To make Credit Note Payment
$creditNote = $object->createCreditNotePayment(array $paymentData);