At least PHP 5.4.
Please install the SDK via Composer.
composer require stidner/php-sdk
And then load the SDK using Composer's autoload:
require_once('vendor/autoload.php');
The SDK depends on:
- The
Httpful
library, - and the
curl
extension.
When using Composer, these should be automatically handled.
We suggest you read our full documentation at http://developer.stidner.com.
...but to summarize, you need to:
- Create a new API instance; this includes your API key and user ID.
$api_handle = new \Stidner\Api(API_USER_ID, 'API_KEY');
- Craft the various objects that the API requires. Please click the links for complete example code.
Required:
Optional:
- Create the Order object, which contains the above objects and a few final variables.
$order = new \Stidner\Model\Order();
$order->setMerchantReference1(null)
->setMerchantReference2(null)
->setPurchaseCountry('SE')
->setPurchaseCurrency('SEK')
->setLocale('sv_se')
->setTotalPriceExcludingTax(171000)
->setTotalPriceIncludingTax(213750)
->setTotalTaxAmount(42750)
->setBillingAddress($billingAddress) // Don't forget to add all the objects!
->addItem($item[1])
->addItem($item[2])
->setMerchantUrls($merchant)
->setOptions($options);
- Finally, send the now-complete json object off to the API server! If successful, the response should be the entire order object, and include a URL to our Stidner Complete payment system; this URL should be loaded in an iframe on your checkout page!
try {
$request = $api_handle->createOrder($order);
$iframeUrl = $request->getIframeUrl();
echo "<iframe src='$iframeUrl' width='75%' height='75%'></iframe>";
} catch (\Stidner\ApiException $e) {
print $e;
} catch (\Stidner\Api\ResponseException $e) {
print $e;
}
Same with creating an order, you must create the API instance:
$api_handle = new \Stidner\Api(API_USER_ID, 'API_KEY');
Now do getOrder(), with the orderID as a parameter. This loads the entire order json object from the API.
$request = $api_handle->getOrder('ORDER_ID');
Finally, getStatus() on the response's json object. This will be: purchase_incomplete, purchase_complete, or purchase_refunded.
$orderStatus = $request->getStatus();
Stidner's PHP SDK is licensed under the Apache License, Version 2.