Contents
On this page

Start Card Payment - Plugixa POS for WooCommerce

POST /plugixa-pos/v1/stripe-terminal/payments

Create a card-present PaymentIntent in the shop’s currency and send it to the register’s reader. Then poll Get Card Payment Status until it is no longer pending, and pass the PaymentIntent id as the payment reference in Create Sale.

Needs a user with the plugixa_pos_sell capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; other roles only when you grant it. The user must also be allowed to use the register (register access).

Request

POST https://your-site.example/wp-json/plugixa-pos/v1/stripe-terminal/payments

Request body

Content type: application/json

Field Type Required Description
register_id integer Yes The register.
amount string Yes Amount, decimal, above zero.
attempt_id string Yes Your id for this payment attempt, 8 to 64 letters, digits and dashes. Resending the same id does not charge twice.
{
  "register_id": 1,
  "amount": "29.00",
  "attempt_id": "3f0a9c2e-7b14-4d58-9e61-0c2b8a4f7d13"
}

Responses

201 Created.

{
  "success": true,
  "data": {
    "payment_intent": "pi_3UdVCnPfpjsL7fG11ZgTLneO",
    "amount": "29.00",
    "test_mode": true
  }
}

Errors

Status Code When
403 plugixa_pos_forbidden The user may not use this register (this route answers with this code rather than plugixa_pos_register_forbidden).
422 plugixa_pos_invalid_amount The amount is zero.
409 plugixa_pos_stripe_no_reader No reader linked to the register.
409 plugixa_pos_stripe_not_configured No secret key saved.
502 plugixa_pos_stripe_unreachable Stripe could not be reached.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/stripe-terminal/payments" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"register_id":1,"amount":"29.00","attempt_id":"3f0a9c2e-7b14-4d58-9e61-0c2b8a4f7d13"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/stripe-terminal/payments');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'register_id' => 1,
        'amount'      => '29.00',
        'attempt_id'  => '3f0a9c2e-7b14-4d58-9e61-0c2b8a4f7d13',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/stripe-terminal/payments', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ register_id: 1, amount: '29.00', attempt_id: '3f0a9c2e-7b14-4d58-9e61-0c2b8a4f7d13' }),
});
const { data } = await response.json();

Quick Links

Share