You can integrate a web app with Payworks SDKs using a wrapper app running on iOS.
Ask your account manager about how to get access to the wrapper app for your web application.
Implementing Transactions from your WebApp
The wrapper app exposes a local web server. You can connect from the client side (Javascript) of your web application via Websockets:
var ws = new WebSocket("ws://localhost:8080");
var ws = new WebSocket("ws://localhost:8080");
This Websocket connection accepts two messages: "Login Merchant" and "Execute Transaction." You must first send a "Login Merchant" and then send an "Execute Transaction" message.
Use this message at the beginning of a transaction to select the merchant.
{
"type": "LOGIN_MERCHANT_REQUEST",
"resource": null,
"loginMerchantRequest": {
"providerMode": "MOCK|JUNGLE|TEST|TEST_FIXED|LIVE|LIVE_FIXED",
"merchantIdentifier": "your-merchant-identifier",
"merchantSecret": "your-merchant-secret"
}
}
All of the request parameters are required.
The
providerMode
references a value from the SDK as described
in the documentation. The
merchantIdentifier
and
merchantSecret
is the same you would specify to the SDK and is obtainable in the payworks Gateway Manager.
{
"type": "LOGIN_MERCHANT_RESPONSE",
"resource": null,
"status": "OK"
}
Use this message to execute a transaction on a connected device:
{
"type": "EXECUTE_TRANSACTION_REQUEST",
"resource": null,
"executeTransactionRequest": {
"transactionParameters": {
"amount": 5.13,
"currency": "USD",
"type": "CHARGE", // only charge supported
"subject": "My subject",
"customIdentifier": "my-custom-identifier",
"applicationFee": 1.00,
"metadata": {
"my": "metadata"
}
}
}
}
After the transaction is done, you will receive a response with the transaction identifier:
{
"type": "EXECUTE_TRANSACTION_RESPONSE",
"executeTransactionResponse": {
"transaction": {
"identifier": "7e2fc2585cd24f648d96760f56fba26c"
}
}
}
You can use the identifier to query the transaction and get the transaction status and receipt information.
Query Transaction Details and Printed Receipts