Skip to main content
Autopay lets Flexprice charge a customer’s saved card whenever a new invoice is due, without any action from the customer. The card is captured once through the Flexprice checkout page, stored as a payment method, and reused for all subsequent invoice payments.
Autopay requires an active Moyasar connection with a valid Secret Key, Publishable Key, and Webhook Secret. See Moyasar Connection Setup before proceeding.

How it Works

1

Setup intent is created

Flexprice creates a payment record to track the card save attempt and returns a secure checkout URL.
2

Customer enters card details

The customer is redirected to the Flexprice checkout page and enters their card number, expiry, and CVC.
3

Card verified

Flexprice runs a 1 SAR verification charge to confirm the card is valid. Once confirmed, the charge is voided immediately. If the void fails, Flexprice issues a refund automatically. The customer is not charged.
4

Card saved

Flexprice receives confirmation, extracts the reusable card token, and saves it as an active payment method linked to the customer.
5

Invoices charged automatically

When a new invoice is generated for the customer, Flexprice charges the saved card directly. No redirect or manual payment step is required.

Setting Up Autopay for a Customer

Using the Flexprice Dashboard

1

Open the customer detail page

Go to BillingCustomers and select the customer.
2

Create a setup intent

In the Integrations section, locate the Moyasar entry and click Setup Autopay.
Setup Autopay button on the customer page
Flexprice opens the checkout page in the current tab. The customer sees a card entry form.

Using the API

POST /v1/payments/customers/{customer_id}/setup/intent
Request body:
{
  "provider": "moyasar",
  "success_url": "https://yourapp.com/customers/cust_01KVZ9HE6XC2AH7CXE6WK8SXK8"
}
FieldTypeRequiredDescription
providerstringYesMust be moyasar
success_urlstringNoURL the customer is redirected to after the card is saved. Must be on the same origin as your application.
Response:
{
  "status": "pending_card_entry",
  "customer_id": "cust_01KVZ9HE6XC2AH7CXE6WK8SXK8",
  "checkout_url": "https://admin.flexprice.io/checkout?provider=moyasar&token=eyJhbGci..."
}
Redirect the customer to checkout_url. The JWT embedded in the URL expires after 2 hours.

Card Entry

The customer is taken to the Flexprice checkout page where they enter their card details.
Flexprice card entry form
If the card issuer requires 3DS authentication, the customer is redirected to their bank’s verification page and returned automatically after completing it.
3DS verification screen

Payment Tracking

Every autopay attempt is tracked as a payment record in Flexprice from the moment the setup intent is created. Each invoice charge attempt also creates its own record, so you can see exactly which invoices were collected automatically.

Payment Status

StatusWhen it occurs
INITIATEDSetup intent is created. Waiting for the customer to complete the card form.
SUCCEEDEDCard confirmed. Token saved.
VOIDEDThe 1 SAR verification charge was voided successfully.
REFUNDEDThe 1 SAR charge could not be voided and was refunded instead.
FAILEDCard authentication or the verification charge failed.

Automatic Invoice Charging

Once a customer has a saved payment method, Flexprice charges it automatically when a new invoice is generated.
1

Invoice is generated

A new invoice is created for the customer.
2

Payment method lookup

Flexprice looks for the customer’s default saved payment method. If no default is set, the most recently added active payment method is used.
3

Card charged

If a valid saved method is found, Flexprice creates a charge request using the stored token. The customer does not need to take any action.
4

Fallback

If no active saved payment method exists, Flexprice falls back to the invoice-link flow. See Moyasar Invoice Synchronization.
5

Invoice marked paid

When the charge is confirmed, Flexprice marks the invoice as PAID.

Troubleshooting

IssueLikely CauseResolution
Customer completed the card form but invoices are still not being charged automaticallyThe card save did not complete successfullyRun the setup autopay flow again for the customer
A 1 SAR charge appeared on the customer’s card but was not returnedThe reversal is processed automatically and typically settles within 1-5 business days depending on the card issuerNo action needed. If it does not settle, contact Moyasar support with the payment reference
Autopay is charging the wrong cardThe customer has more than one saved cardMake sure the correct card is set as the default payment method
A card was saved but automatic charging has stopped workingThe Moyasar connection credentials may have changed or the connection is inactiveGo to IntegrationsMoyasar and verify the connection is active. Re-enter credentials if needed
The checkout URL expired before the customer completed the formThe link is valid for 2 hours from the time it was createdRun the setup autopay flow again to generate a new link