PHP Library

The library requires data in utf-8. For example, if you have data in windows-1250, you need to convert it to utf-8 before passing to the library, e.g., using iconv.

class Twisto

Twisto constructor

Creates new Twisto object

Twisto::__construct([public_key])
ArgumentsData TypeDescription
public_keyStringPublic API key

Twisto setSecretKey

Sets your secret key

Twisto::setSecretKey(key)
ArgumentsData TypeDescription
keyArrayYour secret API key

Twisto setPublicKey

Sets your secret key

Twisto::setPublicKey(key)
ArgumentsData TypeDescription
keyArrayYour public API key

Twisto getPrecheckPayload

Serializes and encrypts data for the JS precheck function

Twisto::getPrecheckPayload(customer, orders)
ArgumentsData TypeDescription
customerCustomerAnonymous customer information
ordersArray<BareOrder>Customer order data

Twisto getCheckPayload

Serializes and encrypts data for the JS check function

Twisto::getCheckPayload(customer, orders)
ArgumentsData TypeDescription
customerBareCustomerAnonymous customer information
ordersArray<Order>Customer order data

Twisto createInvoice

Makes an API call with a request to create an invoice. A TwistoError exception is thrown on an error.

Twisto::createInvoice(transaction_id, customer, order)
ArgumentsData TypeDescription
transaction_idStringThe transaction identifier from the customer evaluation
customerCustomerAnonymous customer information
ordersOrderCustomer order data

class CheckResponse

CheckResponse constructor

Creates new CheckResponse object

CheckResponse::__construct()

CheckResponse add

Serializes and passes data about the customer and their orders for the webhook request check

CheckResponse::add(customer, orders)
ArgumentsData TypeDescription
customerBareCustomerAnonymous customer information
ordersArray<Order>Customer order data

class BareCustomer

BareCustomer constructor

Creates new BareCustomer object

BareCustomer::__construct(data)
ArgumentsData TypeDescription
dataObject {email, facebook_id}Email and facebook_id of customer

BareCustomer serialize

Prepares the data to be sent to the Twisto server

BareCustomer::serialize()

class BareOrder

BareOrder constructor

Creates a new BareOrder object

BareOrder::__construct(data)
ArgumentsDescription
order_idOrder ID
createdDate and time of order creation
billing_addressBilling address
delivery_addressDelivery address
total_priceTotal price of order
is_paidInformation if order has been paid or not
is_shippedInformation if order has been shipped to customer
is_deliveredInformation if order has been already delivered to customer
is_returnedInformation if order has been returned

BareOrder serialize

Prepares the data to be sent to the Twisto server

BareOrder::serialize()

class BareAddress

BareAddress constructor

Creates a new BareAddress object

BareAddress::__construct(data)
ArgumentsDescription
nameFull name
streetStreet
cityCity
zipcodeZip code
countryCountry code
phonesContact phone numbers

BareAddress serialize

Prepares the data to be sent to the Twisto server

BareAddress::serialize()

class Customer

Customer constructor

Creates new Customer object

Customer::__construct(data)
ArgumentsDescription
nameFull name of customer
emailCustomer's email
facebook_idCustomer's Facebook ID
date_registeredDate and time of registration
promo_scoreScore of customer

Customer serialize

Prepares the data to be sent to the Twisto server

Customer::serialize()

class Order

Order constructor

Creates new Order object

Order::__construct(data)
ArgumentsDescription
order_idOrder ID
createdDate and time of Order creation
billing_addressBilling address
delivery_addressDelivery address
is_paidInformation if order has been paid or not
is_shippedInformation if order has been shipped to customer
is_deliveredInformation if order has been already delivered to customer
is_returnedInformation if order has been returned
itemsItems from order

Order serialize

Prepares the data to be sent to the Twisto server

Order::serialize()

class Address

Address constructor

Creates new Address object

Address::__construct(data)
ArgumentsDescription
nameFull name
streetStreet
cityCity
zipcodeZip code
countryCountry code
phonesContact phone numbers

Address serialize

Prepares the data to be sent to the Twisto server

Address::serialize()

class OrderItem

OrderItem constructor

Creates new OrderItem object

OrderItem::__construct(data)
ArgumentsDescription
quantityQuantity of items
nameName of product
price_vatPrice incl. VAT(DPH)
vatVAT(DPH)
is_shipmentThe item represents a shipping fee
is_paymentThe item represents the payment fee
is_discountItem represents discount o
categoriesCategory tree
ean_codeEAN code of the product

OrderItem serialize

Prepares the data to be sent to the Twisto server

OrderItem::serialize()

class NewOrder

NewOrder constructor

Creates new NewOrder object

NewOrder::__construct(data)
ArgumentsDescription
billing_addressBilling address
delivery_addressDelivery address
itemsItems of order

NewOrder serialize

Prepares the data to be sent to the Twisto server

NewOrder::serialize()