The payments API is used to create a session to offer Klarna's payment methods as part of your checkout. As soon as the purchase is completed the order should be read and handled using the [Order Management API
].
Most files of this PHP package was automatically generated by the Swagger Codegen project:
- API version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
Important changes have been made for this package to be useful.
Added new classes and fixed existing ones.
PHP 5.5 and later
Run composer install
to install all the dependenices
Download the files and include autoload.php
:
require_once('/path/to/klarna-Payments/vendor/autoload.php');
Or, you already have a project?
- Download the repository
- Create a new folder called
nirmalsunny
under yourvendor
folder - Create another folder called
klarna-payments
and add thelib
folder there. - Add these to your
composer.json
:
"autoload": {
"psr-4": { "nirmalsunny\\KlarnaPayments\\" : "vendor/nirmalsunny/klarna-payments/lib/" }
}
- Add these if not already added in your
composer.json
"require": {
"guzzlehttp/guzzle": "^6.2"
}
- run
composer update
To do
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
use \nirmalsunny\KlarnaPayments\ApiException;
$config = \nirmalsunny\KlarnaPayments\Configuration::getDefaultConfiguration();
$config->setUsername('');
$config->setPassword('');
$config->setHost(\nirmalsunny\KlarnaPayments\KlarnaPlaygroundEndpoint::$EUROPE);
$apiInstance = new nirmalsunny\KlarnaPayments\Api\OrdersApi($config,
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$authorization_token = "authorization_token_example"; // string |
try {
$apiInstance->cancelAuthorization($authorization_token);
} catch (ApiException $e) {
//print_r($e->getResponseHeaders());
}
$apiInstance = new nirmalsunny\KlarnaPayments\Api\OrdersApi($config,
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$authorization_token = "authorization_token_example"; // string |
$body = new \nirmalsunny\KlarnaPayments\Model\CreateOrderRequest(); // \nirmalsunny\KlarnaPayments\Model\CreateOrderRequest |
try {
$result = $apiInstance->createOrder($authorization_token, $body);
print_r($result);
} catch (ApiException $e) {
//print_r($e->getResponseHeaders());
}
$apiInstance = new nirmalsunny\KlarnaPayments\Api\OrdersApi($config,
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$authorization_token = "authorization_token_example"; // string |
$body = new \nirmalsunny\KlarnaPayments\Model\CustomerTokenCreationRequest(); // \nirmalsunny\KlarnaPayments\Model\CustomerTokenCreationRequest |
try {
$result = $apiInstance->purchaseToken($authorization_token, $body);
print_r($result);
} catch (ApiException $e) {
//print_r($e->getResponseHeaders());
}
?>
session.php
is an example on how to create a session which is the first step in the flow.
All URIs are relative to https://api.klarna.com
Class | Method | HTTP request | Description |
---|---|---|---|
OrdersApi | cancelAuthorization | DELETE /payments/v1/authorizations/{authorizationToken} | Cancel an existing authorization |
OrdersApi | createOrder | POST /payments/v1/authorizations/{authorizationToken}/order | Create a new order |
OrdersApi | purchaseToken | POST /payments/v1/authorizations/{authorizationToken}/customer-token | Generate a consumer token |
SessionsApi | createCreditSession | POST /payments/v1/sessions | Create a new credit session |
SessionsApi | readCreditSession | GET /payments/v1/sessions/{session_id} | Read an existing credit session |
SessionsApi | updateCreditSession | POST /payments/v1/sessions/{session_id} | Update an existing credit session |
- Address
- AssetUrls
- Attachment
- AttachmentDisplay
- AttachmentDisplayBody
- AttachmentDisplayBodyAccountLastModified
- AttachmentDisplayBodyAddress
- AttachmentDisplayBodyAirReservationDetails
- AttachmentDisplayBodyArenaLocation
- AttachmentDisplayBodyBusReservationDetails
- AttachmentDisplayBodyCarRentalItinerary
- AttachmentDisplayBodyCarRentalReservationDetails
- AttachmentDisplayBodyCustomerAccountInfo
- AttachmentDisplayBodyEvent
- AttachmentDisplayBodyHotelItinerary
- AttachmentDisplayBodyHotelReservationDetails
- AttachmentDisplayBodyInsurance
- AttachmentDisplayBodyItinerary
- AttachmentDisplayBodyItinerary1
- AttachmentDisplayBodyMarketplaceSellerInfo
- AttachmentDisplayBodyMarketplaceWinnerInfo
- AttachmentDisplayBodyOtherDeliveryAddress
- AttachmentDisplayBodyPassengers
- AttachmentDisplayBodyPaymentHistoryFull
- AttachmentDisplayBodyPaymentHistorySimple
- AttachmentDisplayBodySubscription
- AttachmentDisplayBodyUniqueAccountIdentifierSeller
- AttachmentDisplayBodyVoucher
- AuthorizedPaymentMethod
- CreateOrderRequest
- Customer
- CustomerTokenCreationRequest
- CustomerTokenCreationResponse
- ErrorV2
- Instant
- MerchantSession
- MerchantUrls
- Options
- Order
- OrderLine
- PaymentMethodCategory
- ProductIdentifiers
- Session
All endpoints require authorization.
The Authorization header is created and sent automatically.
- Documentation
- Tests