BokaMera.API.Host

<back to all web services

PaysonV2CreateCheckout

The following routes are available for this service:
POST/payment/payson/v2/checkoutCreate an checkout for Booking. Note if existing checkouts already exists, i will invalidate those.Create payson checkout (requires settings for Payson Checkout 2.0)
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum Payson2CheckoutStatus : string
{
    case None = 'None';
    case Created = 'Created';
    case FormsFilled = 'FormsFilled';
    case ReadyToPay = 'ReadyToPay';
    case ProcessingPayment = 'ProcessingPayment';
    case ReadyToShip = 'ReadyToShip';
    case Shipped = 'Shipped';
    case PaidToAccount = 'PaidToAccount';
    case Canceled = 'Canceled';
    case Credited = 'Credited';
    case Expired = 'Expired';
    case Denied = 'Denied';
}

class PaysonCheckoutV2Response implements JsonSerializable
{
    public function __construct(
        /** @description The checkout id */
        // @ApiMember(Description="The checkout id")
        /** @var string */
        public string $Id='',

        /** @description The code snippet to for checkout module */
        // @ApiMember(Description="The code snippet to for checkout module")
        /** @var string|null */
        public ?string $Snippet=null,

        /** @description The checkout status */
        // @ApiMember(Description="The checkout status")
        /** @var Payson2CheckoutStatus|null */
        public ?Payson2CheckoutStatus $Status=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Snippet'])) $this->Snippet = $o['Snippet'];
        if (isset($o['Status'])) $this->Status = JsonConverters::from('Payson2CheckoutStatus', $o['Status']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Snippet)) $o['Snippet'] = $this->Snippet;
        if (isset($this->Status)) $o['Status'] = JsonConverters::to('Payson2CheckoutStatus', $this->Status);
        return empty($o) ? new class(){} : $o;
    }
}

enum PaymentOrigin : string
{
    case HomePage = 'HomePage';
    case Embedded = 'Embedded';
    case Admin = 'Admin';
    case Apps = 'Apps';
    case HomePageNew = 'HomePageNew';
}

class PaysonV2CreateCheckout implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The company id. */
        // @ApiMember(Description="The company id.", IsRequired=true)
        /** @var string */
        public string $CompanyId='',

        /** @description The reference id. (Could be booking, could be rebate code etc.) */
        // @ApiMember(Description="The reference id. (Could be booking, could be rebate code etc.)")
        /** @var string|null */
        public ?string $BookingId=null,

        /** @description The reference id. (Could be booking, could be rebate code etc.) */
        // @ApiMember(Description="The reference id. (Could be booking, could be rebate code etc.)", IsRequired=true)
        /** @var string */
        public string $InternalReferenceId='',

        /** @description Optional to set the checkout url. This url will be redirected to if payment is interupted for some reason. */
        // @ApiMember(Description="Optional to set the checkout url. This url will be redirected to if payment is interupted for some reason.")
        /** @var string|null */
        public ?string $CheckoutUrl=null,

        /** @description Optional to set your own confirmation url after payment completed. */
        // @ApiMember(Description="Optional to set your own confirmation url after payment completed.")
        /** @var string|null */
        public ?string $ConfirmationUrl=null,

        /** @description The payment origin id. HomePage = 0, Embedded = 1, Admin = 2, Apps = 3 */
        // @ApiMember(Description="The payment origin id. HomePage = 0, Embedded = 1, Admin = 2, Apps = 3", IsRequired=true)
        /** @var PaymentOrigin|null */
        public ?PaymentOrigin $PaymentOrigin=null,

        /** @description If you want to have another language (sv, fi, dk, no, en) than the default language in system settings, specify it here. Leave empty if default language should be used. */
        // @ApiMember(Description="If you want to have another language (sv, fi, dk, no, en) than the default language in system settings, specify it here. Leave empty if default language should be used.", IsRequired=true)
        /** @var string */
        public string $Language='',

        /** @description Country code for checkout */
        // @ApiMember(Description="Country code for checkout", IsRequired=true)
        /** @var string */
        public string $CountryCode='',

        /** @description Determins if it's a test call */
        // @ApiMember(Description="Determins if it's a test call")
        /** @var bool|null */
        public ?bool $TestMode=null,

        /** @description Articles (Could be Service, rebate code types, etc.. */
        // @ApiMember(Description="Articles (Could be Service, rebate code types, etc..", IsRequired=true)
        /** @var ArticleToCreate[] */
        public array $Articles=[]
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
        if (isset($o['InternalReferenceId'])) $this->InternalReferenceId = $o['InternalReferenceId'];
        if (isset($o['CheckoutUrl'])) $this->CheckoutUrl = JsonConverters::from('string', $o['CheckoutUrl']);
        if (isset($o['ConfirmationUrl'])) $this->ConfirmationUrl = JsonConverters::from('string', $o['ConfirmationUrl']);
        if (isset($o['PaymentOrigin'])) $this->PaymentOrigin = JsonConverters::from('PaymentOrigin', $o['PaymentOrigin']);
        if (isset($o['Language'])) $this->Language = $o['Language'];
        if (isset($o['CountryCode'])) $this->CountryCode = $o['CountryCode'];
        if (isset($o['TestMode'])) $this->TestMode = $o['TestMode'];
        if (isset($o['Articles'])) $this->Articles = JsonConverters::fromArray('ArticleToCreate', $o['Articles']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
        if (isset($this->InternalReferenceId)) $o['InternalReferenceId'] = $this->InternalReferenceId;
        if (isset($this->CheckoutUrl)) $o['CheckoutUrl'] = JsonConverters::to('string', $this->CheckoutUrl);
        if (isset($this->ConfirmationUrl)) $o['ConfirmationUrl'] = JsonConverters::to('string', $this->ConfirmationUrl);
        if (isset($this->PaymentOrigin)) $o['PaymentOrigin'] = JsonConverters::to('PaymentOrigin', $this->PaymentOrigin);
        if (isset($this->Language)) $o['Language'] = $this->Language;
        if (isset($this->CountryCode)) $o['CountryCode'] = $this->CountryCode;
        if (isset($this->TestMode)) $o['TestMode'] = $this->TestMode;
        if (isset($this->Articles)) $o['Articles'] = JsonConverters::toArray('ArticleToCreate', $this->Articles);
        return empty($o) ? new class(){} : $o;
    }
}

class ArticleToCreate implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $ArticleId=0,
        /** @var int */
        public int $ArticleTypeId=0,
        /** @var int */
        public int $Quantity=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ArticleId'])) $this->ArticleId = $o['ArticleId'];
        if (isset($o['ArticleTypeId'])) $this->ArticleTypeId = $o['ArticleTypeId'];
        if (isset($o['Quantity'])) $this->Quantity = $o['Quantity'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ArticleId)) $o['ArticleId'] = $this->ArticleId;
        if (isset($this->ArticleTypeId)) $o['ArticleTypeId'] = $this->ArticleTypeId;
        if (isset($this->Quantity)) $o['Quantity'] = $this->Quantity;
        return empty($o) ? new class(){} : $o;
    }
}

PHP PaysonV2CreateCheckout DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /payment/payson/v2/checkout HTTP/1.1 
Host: api.bokamera.se 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","BookingId":"String","InternalReferenceId":"String","PaymentOrigin":"HomePage","Language":"String","CountryCode":"String","TestMode":false,"Articles":[{"ArticleId":0,"ArticleTypeId":0,"Quantity":0}]}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Snippet":"String","Status":"None"}