POST | /payment/stripe/v1/checkout | Create an checkout for Payble entity. Note if existing checkouts already exists, it will invalidate those. | Create Stripe checkout (requires settings for Stripe Checkout 1.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};
class StripeCheckoutQueryResponse implements JsonSerializable
{
public function __construct(
/** @description The checkout session id */
// @ApiMember(Description="The checkout session id")
/** @var string|null */
public ?string $Number=null,
/** @description The url for checkout module to be placed in a iframe */
// @ApiMember(Description="The url for checkout module to be placed in a iframe")
/** @var string|null */
public ?string $Url=null,
/** @description The checkout status */
// @ApiMember(Description="The checkout status")
/** @var string|null */
public ?string $Status=null,
/** @description Client secret to be used when initializing Stripe.js embedded checkout. */
// @ApiMember(Description="Client secret to be used when initializing Stripe.js embedded checkout.")
/** @var string|null */
public ?string $ClientSecret=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Number'])) $this->Number = $o['Number'];
if (isset($o['Url'])) $this->Url = $o['Url'];
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['ClientSecret'])) $this->ClientSecret = $o['ClientSecret'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Number)) $o['Number'] = $this->Number;
if (isset($this->Url)) $o['Url'] = $this->Url;
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->ClientSecret)) $o['ClientSecret'] = $this->ClientSecret;
return empty($o) ? new class(){} : $o;
}
}
class StripeV1CreateCheckout implements ICompany, JsonSerializable
{
public function __construct(
/** @description The company id. */
// @ApiMember(Description="The company id.", IsRequired=true)
/** @var string */
public string $CompanyId='',
/** @description Country code for checkout */
// @ApiMember(Description="Country code for checkout", IsRequired=true)
/** @var string */
public string $CountryCode='',
/** @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=[],
/** @description An internal reference id (Could be booking, rebate code etc.) */
// @ApiMember(Description="An internal reference id (Could be booking, rebate code etc.)", IsRequired=true)
/** @var string */
public string $InternalReferenceId='',
/** @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 If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. This parameter is not allowed if ui_mode is <c>embedded</c>. */
// @ApiMember(Description="If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. This parameter is not allowed if ui_mode is <c>embedded</c>.")
/** @var string|null */
public ?string $CancelUrl=null,
/** @description The UI mode of the Session. Defaults to <c>hosted</c>; One of: <c>embedded</c>, or <c>hosted</c> */
// @ApiMember(Description="The UI mode of the Session. Defaults to <c>hosted</c>; One of: <c>embedded</c>, or <c>hosted</c>", IsRequired=true)
/** @var string */
public string $UiMode=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['CountryCode'])) $this->CountryCode = $o['CountryCode'];
if (isset($o['Articles'])) $this->Articles = JsonConverters::fromArray('ArticleToCreate', $o['Articles']);
if (isset($o['InternalReferenceId'])) $this->InternalReferenceId = $o['InternalReferenceId'];
if (isset($o['ConfirmationUrl'])) $this->ConfirmationUrl = $o['ConfirmationUrl'];
if (isset($o['CancelUrl'])) $this->CancelUrl = $o['CancelUrl'];
if (isset($o['UiMode'])) $this->UiMode = $o['UiMode'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->CountryCode)) $o['CountryCode'] = $this->CountryCode;
if (isset($this->Articles)) $o['Articles'] = JsonConverters::toArray('ArticleToCreate', $this->Articles);
if (isset($this->InternalReferenceId)) $o['InternalReferenceId'] = $this->InternalReferenceId;
if (isset($this->ConfirmationUrl)) $o['ConfirmationUrl'] = $this->ConfirmationUrl;
if (isset($this->CancelUrl)) $o['CancelUrl'] = $this->CancelUrl;
if (isset($this->UiMode)) $o['UiMode'] = $this->UiMode;
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 StripeV1CreateCheckout DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /payment/stripe/v1/checkout HTTP/1.1
Host: testapi.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
CompanyId: 00000000-0000-0000-0000-000000000000,
CountryCode: String,
Articles:
[
{
ArticleId: 0,
ArticleTypeId: 0,
Quantity: 0
}
],
InternalReferenceId: String,
ConfirmationUrl: String,
CancelUrl: String,
UiMode: String
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { Number: String, Url: String, Status: String, ClientSecret: String }