2017 © Pedro Peláez
 

library php-sdk

Stidner Complete PHP SDK

image

stidner/php-sdk

Stidner Complete PHP SDK

  • Thursday, April 20, 2017
  • by YatesHarry
  • Repository
  • 4 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

StyleCI, (*1)

Stidner PHP SDK

Requirements

At least PHP 5.4., (*2)

Installation

Please install the SDK via Composer., (*3)

composer require stidner/php-sdk

And then load the SDK using Composer's autoload:, (*4)

require_once('vendor/autoload.php');

Dependencies

The SDK depends on:, (*5)

  • The Httpful library,
  • and the curl extension.

When using Composer, these should be automatically handled., (*6)

Usage

We suggest you read our full documentation at http://developer.stidner.com., (*7)

Create new order

...but to summarize, you need to:, (*8)

1) Create a new API instance; this includes your API key and user ID., (*9)

$api_handle = new \Stidner\Api(API_USER_ID, 'API_KEY');

2) Craft the various objects that the API requires. Please click the links for complete example code., (*10)

Required: - merchant URLs, - items array., (*11)

Optional: - billing address, - checkout options., (*12)

3) Create the Order object, which contains the above objects and a few final variables., (*13)

$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);

4) 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!, (*14)

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;
}

Checking an order's status

Same with creating an order, you must create the API instance:, (*15)

$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., (*16)

$request = $api_handle->getOrder('ORDER_ID');

Finally, getStatus() on the response's json object. This will be: purchase_incomplete, purchase_complete, or purchase_refunded., (*17)

$orderStatus = $request->getStatus();

License

Stidner's PHP SDK is licensed under the Apache License, Version 2., (*18)

The Versions

20/04 2017

dev-master

9999999-dev http://developer.stidner.com

Stidner Complete PHP SDK

  Sources   Download

Apache-2.0

The Requires