SDK API
Core
Configuration with precedence
explicit kwargs > environment (.env) > defaults
Server-side calls require BOTH jwt and secret.
Source code in univapay/config.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
backoff_factor = None
class-attribute
instance-attribute
base_url = None
class-attribute
instance-attribute
debug = None
class-attribute
instance-attribute
jwt = None
class-attribute
instance-attribute
retries = None
class-attribute
instance-attribute
secret = None
class-attribute
instance-attribute
store_id = None
class-attribute
instance-attribute
timeout = None
class-attribute
instance-attribute
__init__(jwt=None, secret=None, store_id=None, base_url=None, timeout=None, debug=None, retries=None, backoff_factor=None)
__post_init__()
Source code in univapay/config.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
copy_with(*, jwt=None, secret=None, store_id=None, base_url=None, timeout=None, debug=None, retries=None, backoff_factor=None)
Create a modified copy (handy in tests).
Source code in univapay/config.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
from_env()
classmethod
Build config strictly from environment (.env considered if loaded).
Source code in univapay/config.py
252 253 254 255 |
|
masked()
Return a sanitized dict for logging/diagnostics.
Source code in univapay/config.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
require_store_id()
Ensure a store_id is present for endpoints that need it.
Source code in univapay/config.py
207 208 209 210 211 |
|
validate()
Validate presence of credentials for server-side API calls. (Widget-only use-cases can bypass by not instantiating this config.)
Source code in univapay/config.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
Lightweight sync client for Univapay REST.
- Adds Authorization header "Bearer {secret}.{jwt}".
- Supports Idempotency-Key on mutating requests.
- Optional simple retries/backoff for transient errors (429/5xx).
- Prints sanitized debug logs (Authorization redacted).
Source code in univapay/client.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
backoff_factor = max(0.0, float(backoff_factor))
instance-attribute
config = config.validate()
instance-attribute
retries = max(0, int(retries))
instance-attribute
__enter__()
Source code in univapay/client.py
89 90 91 |
|
__exit__(exc_type, exc, tb)
Source code in univapay/client.py
93 94 95 |
|
__init__(config, *, retries=0, backoff_factor=0.5)
Source code in univapay/client.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
close()
Source code in univapay/client.py
324 325 326 |
|
delete(resource_path, *, json=None, idempotency_key=None, params=None, extra_headers=None)
Source code in univapay/client.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
get(resource_path, *, polling=False, params=None, extra_headers=None)
Source code in univapay/client.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
head(resource_path, *, params=None, extra_headers=None)
Source code in univapay/client.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
patch(resource_path, *, json, idempotency_key=None, params=None, extra_headers=None)
Source code in univapay/client.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
post(resource_path, *, json, idempotency_key=None, params=None, extra_headers=None)
Source code in univapay/client.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
put(resource_path, *, json, idempotency_key=None, params=None, extra_headers=None)
Source code in univapay/client.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
Resources
One-time & recurring charges API.
Notes
- For one-time: pass a transaction token produced by a one-time widget.
- For recurring: pass a transaction token produced by a 'recurring' widget.
- Use
idempotency_key
on POSTs to avoid duplicate charges on retries. - Use
get(..., polling=True)
orwait_until_terminal(...)
to block until a terminal status.
Source code in univapay/resources/charges.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
client = client
instance-attribute
__init__(client)
Source code in univapay/resources/charges.py
57 58 59 |
|
cancel(charge_id, *, idempotency_key=None, **extra)
Cancel (void) a charge. Route name may vary by capture flow; adjust if needed.
Source code in univapay/resources/charges.py
238 239 240 241 242 243 244 245 246 247 |
|
capture(charge_id, *, idempotency_key=None, **extra)
Capture a previously authorized charge (if your account flow supports auth/capture).
Source code in univapay/resources/charges.py
227 228 229 230 231 232 233 234 235 236 |
|
create_one_time(*, token_id, amount, currency='jpy', capture=True, metadata=None, idempotency_key=None, **extra)
Create a one-time charge using a one-time transaction token.
Source code in univapay/resources/charges.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
create_recurring(*, token_id, amount, currency='jpy', capture=True, metadata=None, idempotency_key=None, **extra)
Create a charge using a recurring transaction token. Endpoint is the same as one-time; the server enforces token type.
Source code in univapay/resources/charges.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
get(charge_id, *, polling=False)
Retrieve a charge. If polling=True, server blocks until a terminal state when supported.
Source code in univapay/resources/charges.py
146 147 148 149 150 151 152 153 |
|
refund(charge_id, *, amount=None, idempotency_key=None)
Create a refund for a charge. If amount
is None, a full refund may be performed (API-dependent).
Source code in univapay/resources/charges.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
wait_until_terminal(charge_id, *, server_polling=True, timeout_s=90, interval_s=2.0)
Block until the charge reaches a terminal state.
If server_polling=True, perform a single GET with polling=true. Otherwise, poll client-side every interval_s until timeout_s is reached.
Source code in univapay/resources/charges.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
Subscriptions API.
- Create a subscription from a transaction token produced by a subscription widget.
- Use
idempotency_key
on POSTs to avoid dupes on retry. - Use
get(..., polling=True)
orwait_until_terminal(...)
to block until a terminal-ish state. - Cancel with
cancel(subscription_id, ...)
.
Source code in univapay/resources/subscriptions.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
client = client
instance-attribute
__init__(client)
Source code in univapay/resources/subscriptions.py
101 102 103 |
|
cancel(subscription_id, *, idempotency_key=None, termination_mode=None, **extra)
Cancel a subscription and return the updated Subscription resource.
Primary attempt: POST /subscriptions/{id}/cancel. Fallback: PATCH /subscriptions/{id} with {'termination_mode': 'immediate'|'on_next_payment'}
Source code in univapay/resources/subscriptions.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
create(*, token_id, amount, period, currency='jpy', metadata=None, start_on=None, idempotency_key=None, **extra)
Create a subscription using a subscription-capable transaction token.
Source code in univapay/resources/subscriptions.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
get(subscription_id, *, polling=False)
Retrieve a subscription. If polling=True, server may block until steady/terminal state.
Source code in univapay/resources/subscriptions.py
155 156 157 158 159 160 |
|
wait_until_terminal(subscription_id, *, server_polling=False, timeout_s=60, interval_s=2.0)
Return once the subscription is in a terminal-ish state.
Flow
1) Quick GET without polling; if already terminal-ish (e.g., 'current'), return immediately. 2) If server_polling=True, do a single GET with polling=true (server may block). 3) Else, client-side poll until terminal or timeout.
Source code in univapay/resources/subscriptions.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
Refunds API (per-charge).
Common flows
- Create a refund for a given charge (full refund if
amount
omitted and your account allows it). - Get a specific refund (optionally with server-side polling).
- List refunds for a charge (basic pagination passthrough).
- Wait until a refund reaches a terminal status.
Source code in univapay/resources/refunds.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
client = client
instance-attribute
__init__(client)
Source code in univapay/resources/refunds.py
44 45 |
|
create(charge_id, *, amount=None, reason=None, idempotency_key=None, **extra)
Create a refund.
Parameters
charge_id : str The charge to refund. amount : Optional[int] Amount in minor units. If None, a full refund may be performed (API/account dependent). reason : Optional[str] Optional reason string for audit trails. idempotency_key : Optional[str] Recommended: pass a stable id for safe retries.
Returns
Refund
Source code in univapay/resources/refunds.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
create_full_refund(charge_id, *, reason=None, idempotency_key=None, **extra)
Convenience: request a full refund (omit amount
).
Source code in univapay/resources/refunds.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
create_partial_refund(charge_id, *, amount, reason=None, idempotency_key=None, **extra)
Convenience: request a partial refund (requires amount
).
Source code in univapay/resources/refunds.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
get(charge_id, refund_id, *, polling=False)
Fetch a specific refund. If polling=True
, server may block until a terminal state (when supported).
Source code in univapay/resources/refunds.py
143 144 145 146 147 148 149 150 151 152 153 |
|
list(charge_id, *, limit=None, cursor=None, extra_params=None)
List refunds for a charge (passthrough dict to preserve API fields/pagination).
Source code in univapay/resources/refunds.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
wait_until_terminal(charge_id, refund_id, *, server_polling=True, timeout_s=60, interval_s=2.0)
Block until the refund reaches a terminal-ish status.
If server_polling=True, perform a single GET with polling=true.
Otherwise, poll client-side every interval_s
until timeout_s
is reached.
Source code in univapay/resources/refunds.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
Cancel helpers for charges (authorization/charge cancel).
Most accounts use
POST /charges/{charge_id}/cancel
Depending on your capture flow, this may be equivalent to voiding an
authorization. This SDK provides a void_authorization
alias for clarity.
Source code in univapay/resources/cancels.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
client = client
instance-attribute
__init__(client)
Source code in univapay/resources/cancels.py
25 26 |
|
cancel_charge(charge_id, *, idempotency_key=None, **extra)
Cancel a charge (or an authorization prior to capture).
Parameters
charge_id : str The charge identifier to cancel. idempotency_key : Optional[str] Recommended for safe retries. **extra : Additional fields supported by your Univapay account.
Returns
Charge The canceled/voided charge resource (typed).
Source code in univapay/resources/cancels.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
void_authorization(charge_id, *, idempotency_key=None, **extra)
Void a previously authorized (not yet captured) charge.
Notes
Many Univapay setups map this to the same route as cancel: POST /charges/{charge_id}/cancel
Returns
Charge
Source code in univapay/resources/cancels.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
Transaction Tokens API (read-only on the server).
Notes: - Transaction tokens are typically created client-side by the Univapay widget. - Use this API to fetch token details server-side when needed (e.g., auditing).
Source code in univapay/resources/tokens.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
client = client
instance-attribute
__init__(client)
Source code in univapay/resources/tokens.py
28 29 30 |
|
get(token_id)
Fetch a transaction token by ID.
Parameters
token_id : str The transaction token id (from the FE widget callback).
Returns
TransactionToken A typed model of the token response (extra fields are preserved).
Raises
ValueError If token_id is empty/invalid. UnivapayHTTPError If the HTTP call fails.
Source code in univapay/resources/tokens.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
try_get(token_id)
Like get()
but returns None if the token does not exist (HTTP 404).
Propagates other HTTP errors.
Source code in univapay/resources/tokens.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
Webhooks
Bases: BaseModel
Generic Univapay webhook envelope (best-effort typed). We keep it permissive so unknown fields won't break you.
Source code in univapay/resources/webhooks.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
created = None
class-attribute
instance-attribute
created_on = Field(None, alias='createdOn')
class-attribute
instance-attribute
data = Field(default_factory=dict)
class-attribute
instance-attribute
id = None
class-attribute
instance-attribute
mode = None
class-attribute
instance-attribute
model_config = ConfigDict(extra='allow', populate_by_name=True)
class-attribute
instance-attribute
resource_type = Field(None, alias='resourceType')
class-attribute
instance-attribute
type = None
class-attribute
instance-attribute
Minimal event router
router = WebhookRouter() @router.on("charge.successful") def _h(e): ...
wildcard handler:
@router.on("*") def _all(e): ...
info, event = verify_and_parse(body=..., headers=..., secret=...) results = router.dispatch(event)
Source code in univapay/resources/webhooks.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
__init__()
Source code in univapay/resources/webhooks.py
335 336 |
|
add(event_type, func)
Source code in univapay/resources/webhooks.py
349 350 351 |
|
dispatch(event)
Source code in univapay/resources/webhooks.py
359 360 361 362 363 364 365 366 367 368 369 |
|
handlers_for(event_type)
Source code in univapay/resources/webhooks.py
353 354 355 356 357 |
|
on(event_type)
Source code in univapay/resources/webhooks.py
338 339 340 341 342 343 344 345 346 347 |
|
Parse and (optionally) verify a Univapay webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body
|
Union[str, bytes, bytearray]
|
raw request body (bytes/str). |
required |
headers
|
Mapping[str, str]
|
incoming HTTP headers (case-insensitive handling). |
required |
secret
|
Optional[Union[str, bytes]]
|
your webhook signing secret (None + skip_verification=True for dev). |
None
|
header_name
|
Optional[str]
|
force a specific signature header name (optional). |
None
|
tolerance_s
|
int
|
timestamp tolerance when signature contains a timestamp. |
5 * 60
|
skip_verification
|
bool
|
set True for local/dev only. |
False
|
Returns:
Type | Description |
---|---|
WebhookEvent
|
WebhookEvent |
Source code in univapay/resources/webhooks.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
Verify HMAC signatures using common header conventions. Returns details dict (including which header matched). Raises WebhookVerificationError on failure (unless skip_verification=True).
DEV NOTE
- If
secret
is None/empty and skip_verification=False -> raise. - If
skip_verification=True
, we log and return without checking.
Source code in univapay/resources/webhooks.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
Widgets
__all__ = ['build_one_time_widget_config', 'build_subscription_widget_config', 'build_recurring_widget_config', 'build_widget_bundle_envelope', 'widget_loader_src', 'to_json']
module-attribute
build_one_time_widget_config(*, amount, form_id, button_id, description, widget_key='oneTime', app_jwt=None, env=None, base_config=None, callbacks=None, api=None, payment_methods=None, **extra)
Build FE config for a ONE-TIME payment widget.
- Supports enabling/disabling card/paidy/online brands/konbini/bank_transfer via payment_methods
.
Source code in univapay/widgets.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
build_recurring_widget_config(*, amount, form_id, button_id, description, widget_key='recurring', app_jwt=None, env=None, base_config=None, callbacks=None, api=None, payment_methods=None, **extra)
Build FE config for a RECURRING payment widget (tokenize card for merchant-initiated charges). - Recurring is effectively a card-token flow; other methods will be debug-warned if supplied.
Source code in univapay/widgets.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
build_subscription_widget_config(*, amount, period, form_id, button_id, description, widget_key='subscription', app_jwt=None, env=None, base_config=None, callbacks=None, api=None, payment_methods=None, **extra)
Build FE config for a SUBSCRIPTION payment widget. - Typically card; other methods will be debug-warned if supplied.
Source code in univapay/widgets.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
build_widget_bundle_envelope(*, widgets, app_jwt=None, env=None, base_config=None, callbacks=None, api=None)
Source code in univapay/widgets.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
to_json(payload, *, pretty=False)
Serialize any widget envelope to JSON (useful in tests or manual output).
Source code in univapay/widgets.py
450 451 452 453 454 455 456 457 458 459 460 461 |
|
widget_loader_src(env=None)
Return the official Univapay widget loader URL, optionally overridden by env.
Env override key: "UNIVAPAY_WIDGET_URL" Default: "https://widget.univapay.com/client/checkout.js"
Source code in univapay/widgets.py
437 438 439 440 441 442 443 444 445 |
|
Errors
Bases: Exception
Base exception for all Univapay SDK errors.
Source code in univapay/errors.py
7 8 9 |
|
Bases: UnivapaySDKError
Raised when configuration/credentials are invalid or missing.
Source code in univapay/errors.py
12 13 14 |
|
Bases: UnivapaySDKError
Unified HTTP error for API requests.
Attributes
status : int HTTP status code (or -1 for network errors). payload : Any Parsed JSON or fallback body describing the error (kept verbatim). request_id : Optional[str] Server-provided request correlation id, if available. method : Optional[str] Best-effort HTTP method that triggered the error (if provided). url : Optional[str] Best-effort URL that triggered the error (if provided).
Convenience
.code -> extracted error code (if present in payload) .message_text -> human-friendly error message .retryable -> bool, True if typical transient status (429, 500-504) .to_dict() -> sanitized summary dict for logging
Source code in univapay/errors.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
code
property
Try to extract a structured error code from the payload if present.
message_text
property
Human-friendly message guessed from payload. Keeps it short and safe for logs.
method = method
instance-attribute
payload = payload
instance-attribute
request_id = request_id
instance-attribute
retryable
property
Return True for common transient HTTP statuses.
status = int(status)
instance-attribute
url = url
instance-attribute
__init__(status, payload, request_id=None, *, method=None, url=None)
Source code in univapay/errors.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
__repr__()
Source code in univapay/errors.py
145 146 |
|
__str__()
Source code in univapay/errors.py
142 143 |
|
to_dict()
Sanitized summary for logs/telemetry; includes only non-sensitive fields.
Source code in univapay/errors.py
148 149 150 151 152 153 154 155 156 157 158 |
|
Bases: UnivapaySDKError
Raised for webhook signature/format errors.
Source code in univapay/errors.py
17 18 19 |
|