No description
Find a file
2023-08-18 16:04:13 +02:00
.env.example Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
.gitignore Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
.graphqlrc.yaml Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
deno-apl.ts Fix linter issues 2023-08-18 14:49:32 +02:00
deno.json Update logger formatting, add dev script 2023-08-18 14:54:57 +02:00
deno.lock Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
import_map.json Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
invariant.ts Add logger 2023-08-18 13:57:33 +02:00
justfile Add APL for storing installation data 2023-08-18 13:44:07 +02:00
logger.ts Update logger formatting 2023-08-18 14:58:05 +02:00
main.ts Refactor to use custom data from request 2023-08-18 16:04:13 +02:00
README.md Update readme 2023-08-07 17:32:56 +02:00
subscriptions.ts Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00
types.ts Initial commit 2023-01-11 10:52:15 +01:00
utils.ts Add AST parsing, graphql tag 2023-08-18 14:49:03 +02:00

Dummy Payment Server

Made for testing Saleor's Transaction API

Installation

Deno

This project requires deno to be installed. Follow official installation instructions if deno is not installed on your system

Running app

Start app:

deno task start

Tunnel

Note

Before you go ahead and start your app locally, give Deno Deploy a try! It takes a ~2 seconds to deploy the app after you push the changes to the repository 😉

Create a tunnel, to make your app accessible from Internet. You can use Cloudflare Tunnel:

cloudflared tunnel --url localhost:5544

or by using ngrook:

ngrok http 5544

Note

Saleor CLI's tunnel doesn't work with Deno

Install app

After running a tunnel install the app in Saleor.

  • In Dashboard: go to Apps > Install external app
  • In CLI: saleor app install

** The manifest URL is: your tunnel URL + /manifest**.

For example, if your tunnel URL is https://happy-tunnel.com then the manifest URL will be https://happy-tunnel.com/manifest

After installation auth_token will be visible in the console. It is also stored inside .token file.

Deployment

Fork this project

Use Deno Deploy to deploy your forked repository.

Example usage

The app id is witoszekdev.dummy-payment-app.

The app has excessive permissions for debug purposes. They can be modified inside main.ts file

paymentGatewayInitialize

mutation GatewayInitialize($id: ID!) {
  paymentGatewayInitialize(
    id: $id
    paymentGateways: [{ id: "witoszekdev.dummy-payment-app" }]
  ) {
    gatewayConfigs {
      id
      data
      errors {
        field
        message
        code
      }
    }
    errors {
      field
      message
      code
    }
  }
}

Variables:

{
  "id": "<checkout_id>"
}

transactionInitialize

mutation TransactionInitalize(
  $amount: PositiveDecimal
  $checkoutId: ID!
  $data: JSON
) {
  transactionInitialize(
    amount: $amount
    id: $checkoutId
    paymentGateway: { id: "witoszekdev.dummy-payment-app", data: $data }
  ) {
    transaction {
      id
      actions
      message
      pspReference
    }
    data
    errors {
      field
      message
      code
    }
  }
}

Variables:

{
  "checkoutId": "<checkout_id>",
  "amount": 100 // your checkout amount
  "data": {
    "final": true
  }
}

When you provide data.final = true, then the app will return CHARGE_SUCCESS response, otherwise it will return CHARGE_REQUESTED.

transactionProcess

mutation TransactionProcess($transactionId: ID!) {
  transactionProcess(data: {}, id: $transactionId) {
    transaction {
      id
    }
    transactionEvent {
      id
      createdAt
      pspReference
      message
      externalUrl
      amount {
        currency
        amount
      }
      type
    }
    data
    errors {
      field
      message
      code
    }
  }
}

Variables:

{
  "transactionId": "<transaction id from transactionInitialzie>"
}