swichpay_flutter 2.1.2
swichpay_flutter: ^2.1.2 copied to clipboard
Flutter SDK for integrating Swich payment services.
Changelog #
2.1.2 #
Fixed #
- A successful Bank Transfer (bank account) payment no longer shows an error.
The gateway answers the OTP verify step with
data: false, and the SDK's strictdatacast threw (type 'bool' is not a subtype of type 'Map<String, dynamic>?') even though the payment had gone through. Every gateway/direct response field documented as an object is now read defensively, so an unexpected type is ignored instead of throwing.
2.1.1 #
Fixed #
- A 401 on a cached OAuth token now drops the token, fetches a fresh one and retries the call once, instead of failing every call (checkout start, bank lists, payments) with HTTP 401 until the cached token's local expiry.
- "Unable to start checkout" now shows the short user-facing message instead
of the raw exception text (e.g.
SwichPayApiException: ... (HTTP 401)).
2.1.0 #
Fixed #
-
Card payments that still need 3-D Secure are no longer reported as successful.
ProcessPayment/PaymentEnrollmentanswer a pending DDC/OTP step withsuccess: true; the result is nowpendinguntil that step finishes. Previously some cards (e.g. Meezan-acquired 3DS2) showed the success screen and closed the sheet without the customer ever authenticating. -
3-D Secure pages returned straight from
ProcessPayment(no device-data collection, no JWT) now open in the payment sheet andpresentCardCheckout. They're POSTed with their own query parameters as the form body - the acquirer rejects GET, and parameters sent in both places. -
A direct card response with
nextAction.type == "complete"is treated as final: a successful payment closespresentCardCheckoutinstead of opening the merchant redirect URL in the 3-D Secure view. -
A direct card payment the vendor reports as pending (HTTP 400 with
status: "pending") shows the pending screen and polls its status instead of "Payment declined", so customers aren't prompted to pay twice. -
Session card status checks after 3-D Secure use
InquireV3with the payment'sorderIdwhere the environment has a payment-api host;CheckCardPaymentStatusremains the fallback. -
Environment.productionnow uses the production gateway (api.swichnow.com) and checkout (checkout.swichnow.com) hosts instead of sandbox ones. Direct card payments and discount lookups have no production host yet, so they now fail with aSwichPayValidationExceptionin production instead of sending live data to sandbox (discount lookups are best-effort, so checkout is unaffected). -
Direct card status checks no longer report a declined payment as successful:
transactionStatusdecides the outcome,completedalone never means success, andInitiatedis treated as still pending. -
A direct card response with no next step and no
0000code is verified via a status check instead of being treated as success; a payment still pending after polling is returned aspendingrather than shown as declined. -
The card Pay button can no longer start a second payment while 3-D Secure device verification is in progress (payment sheet and
presentCardCheckout); switching payment-method tiles is blocked for that window too. -
The 3-D Secure redirect request now times out instead of hanging the spinner forever.
-
Bank Transfer "Resend OTP" no longer crashes.
-
Direct card payments send
isApias a boolean again - PaymentV3 was rejecting every request with a 400 for the string form. -
A card declined with HTTP 4xx (e.g. "Transaction Failed") now shows the "Payment declined" screen in
presentCardCheckoutinstead of "Something went wrong". -
IBAN fields (RTP Now / RTP E-Wallet, payment sheet and direct checkouts) now require the Pakistani IBAN format (
PK+ 22 characters) and send it without spaces, upper-cased; previously any 16+ characters were accepted and sent to the gateway. -
Errors shown to users are now short, non-technical messages (
SwichPayException.userMessage); technical details stay in debug logs. -
README: install snippet now references
^2.0.0; documents the iOSNSPhotoLibraryAddUsageDescriptionneeded for saving QR codes.
Added #
SwichPayApiException.serverStatus,.orderIdand.isPending.SwichPayClient.checkCardPaymentStatustakes an optionalorderId.
Security #
- The
Authorizationheader and Bank Transfer'saccountNoare now redacted from debug logs, and error response bodies are logged with the same redaction as requests.
2.0.0 #
Changed #
- Breaking:
SwichPay.initialize()no longer takesgetAccessTokenorgetPaymentSessionDetailscallbacks - merchants now only provideclientId,clientSecret,referrer,merchantId,appId, andenvironment. GivenclientSecret, the SDK exchanges it for an OAuth2 bearer token itself (client_credentialsgrant, refreshed automatically) instead of requiring a merchant backend to do it; the SDK also creates payment sessions and fetches their details internally.clientSecretis technically optional - without one, every call falls back to sendingclientIdas a plainx-public-keyheader, which only a subset of endpoints accept, so pass it whenever you have it. - Breaking: Renamed
SwichPayConfig/SwichPay.initialize()'spublicKeytoclientId.secretHashKeykeeps its name - it's a separate, different secret than the newclientSecret(native'sPaymentConfighas always had both:secretKeyfor OAuth,secretHashKeyfor the card-payment checksum). Passing the same value for both gets aninvalid_client401 from the token endpoint. - Breaking: Removed
SwichPayAuthException- no longer thrown, since there's no host-app callback left to fail. - Breaking: Removed
package:swichpay_flutter/sandbox.dart-SwichPaySandboxexisted only to fake what the SDK now does internally by default. - Added direct (session-less) card payment (
SwichPay.presentCardCheckout), mirroring native'sCardBottomSheet: 3-D Secure device-data-collection, optional OTP step-up, and status polling. RequiressecretHashKeyonSwichPay.initialize(). - Added a "Scan card" shortcut to both the built-in payment sheet's and
presentCardCheckout's card forms - camera-based, viapackage:card_scanner, fills in the card number and expiry automatically. Android/iOS only; not shown on other platforms. Needs a camera permission - see the README's Platform notes for the one-line iOS setup step.
1.0.0 #
Initial public release.
Added #
- Built-in payment sheet (
SwichPay.presentPaymentSheet) supporting:- Card payments (Visa/Mastercard), including saved cards and 3-D Secure (device-data-collection and OTP step-up).
- E-Wallet payments (EasyPaisa/JazzCash), including saved wallets.
- Bank Account payments, including an OTP confirmation step.
- Biller (1Bill) payments.
- QR (RAAST dynamic) payments.
- RTP Now payments (Raast mobile/IBAN or bank account).
- RTP E-Wallet payments.
- Automatic discount lookup and display for E-Wallet and Card payments.
- Standalone, session-less "direct" checkouts for E-Wallet, Bank Transfer,
1Bill, QR, RTP Now, and RTP E-Wallet (
SwichPay.present*Checkout), for integrations that don't need the full payment-method picker. - Hosted checkout (
SwichPay.presentHostedCheckout/presentHostedCheckoutSheet) for a WebView-based flow. - Direct card payment (
SwichPay.pay) for fully custom card UI. - Payment session inquiry (
SwichPay.inquirePaymentSession) and cancellation. - App-wide payment result stream (
SwichPay.onResult). - Sandbox and production environment configuration
(
Environment.sandbox/Environment.production), with base URL overrides for local backend testing. - Typed exception hierarchy (
SwichPayNotInitializedException,SwichPayValidationException,SwichPayNetworkException,SwichPayApiException,SwichPayAuthException) so callers can handle SDK errors without parsing raw HTTP responses.
Security #
- Card number, CVC, CNIC, MSISDN, account number/alias, IBAN, OTP, and discount-lookup reference values are redacted from debug logs.
- Debug logging (
swichpayLog) is a no-op outside debug builds.