You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom callbacks on events from the Checkout has been introduced.
The snippet from create_checkout will no longer auto initialize the checkout.
This to allow the integrating partner to be able to handle the callbacks manually.
Getting Started
This documentation is about the PHP SDK for communicating with Wasa Kredit checkout services.
Prerequisites
Partner credentials
PHP 5.7 or above
Acquiring the SDK
You can apply to recieve the SDK and Partner credentials by sending a mail to [email protected].
Initialization
Initialize the main Client class by passing in your issued Client ID and Client Secret.
You can optionally supply a Test Mode parameter which is by default is set to true.
/**
* Checks if the input is valid JSON or not
* @param string clientId
* @param string clientSecret
* @param boolean testMode
*
* @return Client
*/
new Client({CLIENT ID}, {CLIENT SECRET}, {TEST MODE})
Client
Orchestrates the main flow. Client will fetch and store an access token upon an initial request and save it in a PHP session for future requests.
Example
$this->_client = new Client(clientId, clientSecret, testMode);
Parameters
Name
Type
Description
clientId
string (required)
The client id that has been issued by Wasa Kredit
clientSecret
string (required)
Your client secret issued by Wasa Kredit
testMode
boolean
A boolean value if SDK should make requests in test mode or not
Available methods
Calculate Leasing Cost
When presenting a product list view this method calculates the leasing price for each of the products.
public function calculate_leasing_cost({ITEMS})
Parameters
Name
Type
Description
items
array[Item] (required)
An array containing the data type Item
Item
Name
Type
Description
financed_price
Price (required)
...
product_id
string (required)
Your unique product identifier
Price
Name
Type
Description
amount
string (required)
A string value that will be parsed to a decimal, e.g. 199 is '199.00'
The Checkout is inserted as a Payment Method in the checkout. It could be used either with or without input fields for address. Post the cart to Create Checkout to initiate the checkout.
An alternative use case for the Checkout is as a complete checkout if there is no need for other payment methods.
public function create_checkout({CHECKOUT})
Parameters
Name
Type
Description
payment_types
string
Selected payment type to use in the checkout, e.g. 'leasing'
order_reference_id
string (required)
The order reference of the partner
order_references
array
The order reference of the partner
cart_items
array[Cart Item] (required)
An array of the items in the cart as Cart Item objects
shipping_cost_ex_vat
Price (required)
Price object containing the shipping cost excluding VAT
customer_organization_number
string
Optional customer organization number
purchaser_name
string
Optional name of the purchaser
purchaser_email
string
Optional e-mail of the purchaser
purchaser_phone
string
Optional phone number of the purchaser
billing_address
Address
Optional Address object containing the billing address
delivery_address
Address
Optional Address object containing the delivery address
recipient_name
string
Optional name of the recipient
recipient_phone
string
Optional phone number of the recipient
request_domain
string (required)
The domain of the partner, used to allow CORS
confirmation_callback_url
string (required)
Url to the partner's confirmation page
ping_url
string (required)
Receiver url for order status changes notifications
Cart Item
Name
Type
Description
product_id
string (required)
Id of the Product
product_name
string (required)
Name of the product
price_ex_vat
Price (required)
Price object containing the price of the product excluding VAT
quantity
int (required)
Quantity of the product
vat_percentage
string (required)
VAT percentage as a parsable string, e.g. '25' is 25%
vat_amount
Price (required)
Price object containing the calculated VAT of the product
image_url
string
An optional image url of the product
Price
Name
Type
Description
amount
string (required)
A string value that will be parsed to a decimal, e.g. 199 is '199.00'
currency
string (required)
The currency
Address
Name
Type
Description
company_name
string
Company name
street_address
string
Street address
postal_code
string
Postal code
city
string
City
country
string
Country
Response
The response will return a unique html snippet to be embedded in your checkout html.
When you want to initialize the checkout, just call the global window.wasaCheckout.init().
<script>
window.wasaCheckout.init();
</script>
Handling custom checkout callbacks
Optionally, you're able to pass an options object to the init-function. Use this if you want to manually handle the onComplete, onRedirect and onCancel events.
<script>
var options = {onComplete: function(orderReferences){//[...]},onRedirect: function(orderReferences){//[...]},onCancel: function(orderReferences){//[...]}};
window.wasaCheckout.init(options);
</script>
The onComplete event will be raised when a User has completed the checkout process. We recommend that you convert your cart/checkout to an order here if you haven't done it already.
The onRedirect event will be raised the user clicks the "back to store/proceed"-button. The default behaviour will redirect the user to the confirmation_callback_url passed into the create_checkout-function.
The onCancel event will be raised if the checkout process is canceled by the user or Wasa Kredit.
All callback functions will get the orderReferences parameter passed from the checkout. This parameter consists of an Array of KeyValue objects.
These are the same values as the ones that was passed to the create_checkout-function as the order_references property.
Amount sent is between min/max limit for the partner
$response->data
{
"validation_result": true
}
Create Product Widget
To inform the customer about leasing as a Payment Method the Product Widget should be displayed close to the price information on the product detail page.
public function create_product_widget($payload)
Parameters
Name
Type
Description
financial_product
string (required)
The amount to be validated
price_ex_vat
Price (required)
Price object excluding VAT
Price
Name
Type
Description
amount
string (required)
A string value that will be parsed to a decimal, e.g. 199 is '199.00'