Download the PHP package zrkb/bancard without Composer

On this page you can find all versions of the php package zrkb/bancard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bancard

Bancard

PHP SDK for the Bancard vPOS 2.0 payment gateway API

CI Total Downloads Latest Stable Version License

Installation

Requirements: PHP >= 8.1

Configuration

Requests time out after 30 seconds (10 seconds to connect) by default. Override with the timeout and connect_timeout Guzzle options.

The private key is hidden from var_dump()/print_r() and stack traces.

Usage

All operations return typed response objects with convenience methods.

Single Buy

Single Buy (Zimple)

Single Buy Confirm

Generates the confirm token for the iframe callback (no HTTP request is made).

Payment Form (bancard-checkout.js)

singleBuy(), singleBuyZimple() and cardsNew() return a process_id. Bancard's iframe collects the card data with it:

Use Bancard.Zimple.createForm for Zimple, Bancard.Cards.createForm for card registration and Bancard.Charge3DS.createForm for 3DS. The URL follows the staging flag (bancard-checkout-4.0.0.js, Bancard::CHECKOUT_JS_VERSION).

The payment form also offers QR and PIX when they are enabled in the application profile of the commerce portal. They need no extra integration: the result arrives at the same confirmation callback.

Confirmation Callback

Bancard POSTs the payment result to your confirmation URL. parseConfirmation() verifies its token (constant-time comparison) and returns a typed object:

In Laravel: $bancard->parseConfirmation($request->getContent()) and return response()->json(ConfirmationCallback::ACKNOWLEDGEMENT);.

With electronic invoicing (billing), getInvoiceNumber() and getCdc() return the generated invoice number and control code.

Bancard expects HTTP 200 within 30 seconds. If it does not get one, the payment is not necessarily denied: check it with singleBuyGetConfirmation().

To check an already decoded operation array, use $bancard->verifyConfirmation($operation) (returns bool).

Single Buy Get Confirmation

While the customer has not paid yet, this throws ApiException with key PaymentNotFoundError.

singleBuyGetConfirmation(), preauthorizationConfirm() and charge() responses have the same getters as the confirmation callback (getResponseCode(), getAuthorizationNumber(), getTicketNumber(), getCardSource(), getRiskIndex(), ...).

Single Buy Rollback

Register a New Card

Mount Bancard.Cards.createForm with the process_id (Payment Form). Bancard then redirects to return_url with ?status=add_new_card_success, or ?status=add_new_card_fail&description=.... Check the result with usersCards(). A user can have at most 5 registered cards. On staging, use cédula 9661000.

List User Cards

Charge (Token-Based Payment)

charge() sends number_of_payments: 1, additional_data: "" and extra_response_attributes: ["confirmation.process_id"] (which enables 3DS detection) unless you pass other values. Pass null to omit one.

Charge a Saved Card (Recurring Payments)

Alias tokens are single-use and expire within minutes, so don't store them. Store user_id + card_id and use chargeCard(): it fetches a fresh alias token with usersCards() and then charges.

To pick the alias token yourself, use $bancard->usersCards([...])->findCard($cardId).

Delete Card

Preauthorization Confirm

Billing Client Info

Billing Cancel

Response Objects

All responses extend Bancard\Response\Response and provide:

Specialized responses add operation-specific methods (e.g., getProcessId(), isApproved(), getCards()).

Error Handling

Every exception extends BancardException, so one catch (BancardException $e) covers them all.

After a NetworkException on a payment the outcome is unknown: Bancard may have processed it. Check with singleBuyGetConfirmation() before retrying with the same shop_process_id.

Error keys worth handling:

Key Meaning
DuplicatePaymentError Same card and amount charged in the last 5 minutes.
PaymentNotFoundError The customer has not paid this shop_process_id yet.
BuyNotFoundError No payment with that shop_process_id.
InvalidOperationError A field is missing or invalid (see getMessage()).

Bancard blocks a card at the commerce for 30 days after 7 rejected payments in 24 hours or 35 in 30 days ("MANDATO MC MAC 03 y 21"). Don't retry rejected payments automatically.

Field Validation

Fields are checked against the vPOS spec before sending, so mistakes fail locally with the field names instead of as InvalidOperationError:

Amounts and Currency

amount and iva_amount accept ints, floats or numeric strings and are sent and signed as "10000.00". Strings with more than two decimals, separators like "10,000" or negative values throw ValidationException.

currency accepts the Currency enum or its string value:

Upgrading from 1.0

See UPGRADE.md for the migration guide.

Development

Staging Smoke Test

tests/Smoke runs real requests against Bancard staging. It is not part of the default suite or CI, and skips itself without credentials:

Variable Purpose
BANCARD_STAGING_PUBLIC_KEY, BANCARD_STAGING_PRIVATE_KEY Required. Staging keys from the Bancard commerce portal.
BANCARD_STAGING_USER_ID Runs users_cards, and is used for cards_new.
BANCARD_STAGING_CARD_ID card_id of a card registered for that user. Runs chargeCard() (with and without the 3DS attribute) and singleBuyGetConfirmation() with extra attributes, then rolls back.
BANCARD_STAGING_RETURN_URL Return/cancel URL sent to Bancard (default https://example.com/bancard/return).
BANCARD_SMOKE_TEST_CLIENT=1 Sends test_client so the runs don't count toward Bancard's staging test list.

Keep the variables in .env.smoke (gitignored) and load them with set -a; . ./.env.smoke; set +a.

To get a BANCARD_STAGING_CARD_ID, serve tests/Smoke/register-card.php, for example with php -S localhost:8000 tests/Smoke/register-card.php or through Valet. It reads .env.smoke, opens Bancard's card form, and after registration shows the card_id to use. On staging, the card 5418630110000014 (expiry 08/21, CVV 258) with cédula 9661000 works.

Each request and response is written to build/smoke/<run>/ with keys, tokens and alias tokens redacted, so real response shapes can be compared with what the SDK expects.

Security

If you discover any security related issues, please use the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of bancard with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zrkb/bancard contains the following files

Loading the files please wait ...