- Saved searches
- Use saved searches to filter your results more quickly
- License
- mobilpay/PHP_CARD
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- jlorente/php-credit-cards
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
PHP Modules implementation — CARD Payments Processing @mobilpay
License
mobilpay/PHP_CARD
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Card Payment Module in PHP language
This module made to use as an example of implementation for online payment via Card in PHP
Generic Payment Request/Response Flow
The user will be redirected from the Merchant’s website to NETOPIA Payments server together with a payment request. Based on the merchant account settings in NETOPIA’s platform, various payment input methods might be displayed (e.g. Google Pay)
- env_key : envelope key payment encryption
- data : encrypted data (see the openssl_seal function in PHP)
Where to send the Request
Payment Request Structure
In order to send the payment request to NETOPIA Payments , you need to encrypt the payment data on POST method and encapsulate the information using the following structure.
XXXX-XXXX-XXXX-XXXX-XXXX Payment Details first_name last_name email_address address mobile_phone param1Name param1Value http://www.your_website.com/confirm http://www.your_website.com/return
Payment Response Structure
The response from NETOPIA Payments to your confirm URL will be in following structure
action_type first_name last_name address email_address phone_no mobilPay_purchase_no XX.XX NN.NN X****YYYY ZZZZZZZ token_identifier YYYY-MM-DD HH:MM:SS error_message
For each call to your confirm URL, the Merchant will need to respond in XML format back to NETOPIA Payments, in order to help us understand whether you have successfully recorded the response or not.
For debugging purposes, you may view your response in mobilPay console (Order – Details – Merchant Communication Log)
The following annotated description of the XML response structure shows the elements sent by you to the NETOPIA Payments API.
The attributes of the crc element are only sent if you had any problem recording the IPN.
- set error_type to «1», if there is a temporary error (this means that a retry mechanism will be activated and the IPN will be attempted again later on)
- set error_type to «2», if there is a permanent error
The messages exchanged with NETOPIA Payments are protected to ensure that only authorized requests are done.
There are three levels of security:
- Request authentication using an API Signature included in the request (Signature field)
- The data exchanged between the client → NETOPIA Payments server and back is encrypted using RSA keys
- Secure Sockets Layer (SSL) data transport for the request, optional, if available on the merchant side, for the response.
NETOPIA Payments API service is supporting the 3-D Secure transactions (both v1 and v2)
0 – approved 16 – card has a risk (e.g. stolen card) 17 – card number is incorrect 18 – closed card 19 – card is expired 20 – insufficient funds 21 – cVV2 code incorrect 22 – issuer is unavailable 32 – amount is incorrect 33 – currency is incorrect 34 – transaction not permitted to cardholder 35 – transaction declined 36 – transaction rejected by antifraud filters 37 – transaction declined (breaking the law) 38 – transaction declined 48 – invalid request 49 – duplicate PREAUTH 50 – duplicate AUTH 51 – you can only CANCEL a preauth order 52 – you can only CONFIRM a preauth order 53 – you can only CREDIT a confirmed order 54 – credit amount is higher than auth amount 55 – capture amount is higher than preauth amount 56 – duplicate request 99 – generic error
About
PHP Modules implementation — CARD Payments Processing @mobilpay
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A PHP package to perform operations on debit and credit cards like validate brand, number and Luhn algorithm and formatting. It validates popular brands like Visa, Mastercard, American Express, etc.
License
jlorente/php-credit-cards
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A PHP package to perform operations on debit and credit cards like format, validate brand, number and Luhn algorithm. It validates popular brands like Visa, Mastercard, American Express, etc.
This package is based on the braintree/credit-card-type javascript package. All the card types configuration have been extracted from it.
Current Cart Type Validators
- Visa
- Mastercard
- American Express
- Diners Club
- Discover
- JCB
- UnionPay
- Maestro
- Elo
- Mir
- Hiper
- Hipercard
The preferred way to install this extension is through composer.
With Composer installed, you can then install the extension using the following commands:
$ php composer.phar require jlorente/php-credit-cards
. "require": < "jlorente/php-credit-cards": "*" >
to the require section of your composer.json file.
You can create an instance of the validator either by using the common constructor or the static make method.
$validator = new CreditCardValidator();
$validator = CreditCardValidator::make();
By default, the validator will load the configuration of all the card types that come along with the package, but you can limit the allowed types by providing an array with the card type codes.
$validator = new CreditCardValidator([ CreditCardValidator::TYPE_VISA, CreditCardValidator::TYPE_MASTERCARD, ]);
$validator = CreditCardValidator::make([ CreditCardValidator::TYPE_VISA, CreditCardValidator::TYPE_MASTERCARD, ]);
Validating a credit card number without knowing the type
$validator->isValid('4242424242424242');
Validating a credit card number knowing the type
$validator->is(CreditCardValidator::TYPE_VISA, '4242424242424242');
$validator->isVisa('4242424242424242');
Get the type configuration of a card number
$typeConfig = $validator->getType('4242424242424242');
With the type configuration you can know metadata info, perform some validation or format the card number using the class methods.
Method | Description | Return example |
---|---|---|
getType(): string | Get the type of the card type configuration | «visa», «mastercard» |
getNiceType(): string | Get the nice type of the card type configuration | «Visa», «Mastercard» |
getPatterns(): array | Get the patterns that the card type configuration uses to validate a card number | [50, [55, 59]] |
getGaps(): array | Get the index of the position in card number string where to put blank spaces on card formatting | [4, 8, 12] |
getLengths(): array | Get the allowed lengths that the card type configuration uses to validate the card numbers | [16, 19] |
getCode(): string | Get the security code configuration of the card type | [«name» => «CVC», «size» => 4] |
getLuhnCheck(): bool | Get the luhn check value of the configuration | true |
setLuhnCheck(bool $value): $this | Set the luhn check value. If true, the validator will validate the card number with the Luhn’s algorithm | |
matches(string $cardNumber): bool | Check if the given card number matches the card type configuration | false |
matchesPatterns(string $cardNumber): bool | Check if the card number matches one of the patterns array configuration | true |
matchesLengths(string $cardNumber): bool | Check if the card number matches one of the lengths array configuration | true |
satisfiesLuhn(string $cardNumber): bool | Check if the card number satisfies the luhn’s algorithm | true |
matchesSecurityCode(string $cardNumber): bool | Check if the card number satisfies the luhn’s algorithm | false |
format(string $cardNumber): string | Format the card number according to the gap configuration | «4242 4242 4242 4242» |
Feel free to add new credit card configurations or fix the current ones and create a pull request to keep the package up to date.
A credit type configuration has the following structure:
[ 'example-card' => [ 'niceType' => 'Test Card', // Display name 'type' => 'example-card', // Type/Code name 'patterns' => [ // Valid patterns for the card 272012, // Simple validator: true if the card begins with the pattern 272012 [5, 89], // Range validator: true if the card initial two digits value is between 5 and 89 both included ], 'gaps' => [4, 10], // Values where to put white spaces on pretty card formatting. In this example: XXXX XXXXXX XXXXXX 'lengths' => [ // Valid lengths for the card 15, // Simple validator: True if length is exactly 15 [17, 19], // Range validator: True if length is between 17 and 19 both included ], 'code' => [ // Security code configuration 'name' => 'CVV', // Name of the security code 'size' => 3, // Valid length of the security code ], 'luhnCheck' => true // To validate the Luhn's algorithm when calling matches ], ];
Copyright © 2020 José Lorente Martín jose.lorente.martin@gmail.com.
Licensed under the MIT License. See LICENSE.txt for details.
About
A PHP package to perform operations on debit and credit cards like validate brand, number and Luhn algorithm and formatting. It validates popular brands like Visa, Mastercard, American Express, etc.