nu1ww/clover-card-point-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nu1ww/clover-card-point-php

Composer 安装命令:

composer require nu1ww/clover-card-point-php

包简介

PHP adapter for CardConnect CardPointe API

README 文档

README

Overview

The CardPointe Gateway API allows you to securely accept a wide-range of credit, debit, and alternative payments.

Setup ENV (Sandbox)

CLOVER_SITE='isv-uat'
CLOVER_SITE_BASE_URL=https://isv-uat.cardconnect.com/
CLOVER_TOKENIZE_URL=https://isv-uat.cardconnect.com/cardsecure/api/v1/ccn/tokenize
CLOVER_MERCHANT_ID=123456123456
CLOVER_USER_NAME='username'
CLOVER_PASSWORD='password'
CLOVER_LOG=true // enable logs 

API documentation https://developer.cardpointe.com/cardconnect-api

Initializing

$merchant_id = '123456123456';
$user        = 'username';
$pass        = 'password';
$server      = 'https://isv-uat.cardconnect.com';

$client = new CardPointe($merchant_id, $user, $pass, $server);

Testing Credentials

$boolean = $client->testAuth();

Validate Merchant ID

$boolean = $client->validateMerchantId();

Tweaks

Responses are parsed and their amount fields are returned in cents int.

The client stores the last request made as an array $client->last_request which can be used to debug requests

Response Objects

Responses are returned as objects and can be accessed as arrays.

$response = $client->inquire($retref);
$response->amount; // returns int
$response->toJSON(); // Returns JSON encoded string, accepts format codes (JSON_PRETTY_PRINT, etc)
$response->toArray(); // Returns array of attributes

Authorizing Transactions

$request = new AuthorizationRequest([
    'account' => '4242424242424242',
    'amount'  => '100',
    'expiry'  => '0120',
]);
$authorization_response = $client->authorize($request);

You can also authorize and capture in the same request like so

$request = new AuthorizationRequest([
    'account' => '4111111111111111',
    'amount'  => '100',
    'expiry'  => '0124',
    'capture' => true,
    'profile' => true,
]);
$capture_response = $client->authorize($request);

You can also authorize and capture in the same request using a saved card with PROFILE_ID/ACCOUNT_ID like so

$request = new AuthorizationRequest([
    'account' => '4111111111111111',
    'amount'  => '100',
    'expiry'  => '0124',
    'capture' => true,
    'profile' => "$profile_id/$account_id", // using a profile/account
]);
$capture_response = $client->authorize($request);

To view all available fields see Authorization Request

All returned fields see Authorization Response

Capturing Transactions

$auth_retref = '123456654321';
$params = []; // optional
$capture_response = $client->capture($auth_retref, $params);

To view all available fields see Capture Request

All returned fields see Capture Response

Voiding Transactions

$auth_retref = '123456654321';
$params = []; // optional
$void_response = $client->void($auth_retref, $params);

To view all available fields see Void Request

All returned fields see Void Response

Refunding Transactions

$capture_retref = '123456654321';
$params = []; // optional
$void_response = $client->refund($capture_retref, $params);

To view all available fields see Refund Request

All returned fields see Refund Response

Transaction Status

$retref = '123456654321';
$inquire_response = $client->inquire($retref);

All returned fields see Inquire Response

Settlement Status

$date = '0118';
$settlements = $client->settleStat($date);
$first_settlement = $settlements[0];

All returned fields see Settlement Response

Create/Update Profile

// update a profile by providing 'profile' => $profile_id in the request
$request = [
    'defaultacct' => true,
    'account'     => "4444333322221111",
    'expiry'      => "0914",
    'name'        => "Test User",
    'address'     => "123 Test St",
    'city'        => "TestCity",
    'region'      => "TestState",
    'country'     => "US",
    'postal'      => "11111",
];
$res = $client->createProfile($request);

All returned fields see Create/Update Profile Request

Get Profile

$profile_id = '1023456789';
$account_id = null; // optional
$profile = $client->profile($profile_id, $account_id);

All returned fields see Profile Response

Delete Profile

$profile_id = '1023456789';
$account_id = null; // optional
$profile = $client->deleteProfile($profile_id, $account_id);

All returned fields see Delete Profile Response

Tokenize ApplePay

$this->client = new CardPointe($this->merchant_id, $this->user, $this->pass, $this->server, $this->currency, true);
//"devicedata":"<data>&ectype=apple&ecsig=<signature>&eckey=<ephemeralPublicKey>&ectid=<transactionId>&echash=<applicationDataHash>&ecpublickeyhash=<publicKeyHash>"
$request = [
    "devicedata" => $deviceData // response you getting from apple pay authorized 
];

$response = $this->client->tokenizeApplePay($request);

Tokenizing Apple Pay using the CardSecure API tokenize ApplePay

Tokenize GooglePay

$this->client = new CardPointe($this->merchant_id, $this->user, $this->pass, $this->server, $this->currency, true);
//"devicedata" : "{\"signature\":\"MEYCIQCwmJRWgG8cT1et/SgjLXr8+dmZ2BZpiLEg/T474g2NZAIhAKVmDiozWuQoPED7qaGNDyoYslL2YzHSFM724Md89+33\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgY3czp0xq5QW3NTQgYvmDJ2i+Oj3YtFwfXHed6ZjtDIju/FkfPIT66AOAAEIe2UqS8dTL/AZkM98KAp4LdekAQ\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1585761306143\\\"}\",\"signatures\":[\"MEYCIQDb+LBzB21jEBRr0r/RqH6QDoYWqpcY5nJFdFKIpNmB5QIhAN3RdiHK0bl6kBigXnIe8qUEnrGqdC6q5NQWJHwEhF12\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"mJVt1VLA/CJMosu8s/C3ixVgNHW3ZuJSBx4mSU8HbQtB1Ll9jV0jgeSZ9CVnmCr9w9RiPKvdo1mJGz69aNky4oYMKt/2gUWsRDMKf0LOktjYQ9kLUpyJvkX5YGrwkeL12qUceIYcMX84L+tlV+FVVfhCcxsDNWKnKSxqzP5/KAN3is6YQ5YnTxfz7xEVXTFoAHv78XBowQq2GSioK7uV2MubHO+o5+G5+i/OJBNMsZevM27nE8gO5OQUOugkX7/cLbFHYlvJEpy7rWHj7yUV9r7eeji2uC0cKorOGdgoFjY6Hax8gtwiBJM56TlkChOA6JI8e3pO5a3r+ZkSMB95c/lAOSbesush02KNvIAKan5A6435mQ7VnQK3FJcX3s7cGO0yP2FHnbki+Oewzfoix1tNg1WuNiPXk2Cn1IM4cvk+GErEqDG1Uqh1KGb/P4F/bBDtwiqKR8FP/1dIVtgj8gi/sRG55Nm+SfRIprXv3g\\\\u003d\\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BK9KRSzyuwWyy9LUh2S2ue7M02xheyVtn42plZb6bp0EhZUyu0iL0QsvDsczs2fPGtJ3h0GsC9NE1Oa0BbMoIHs\\\\u003d\\\",\\\"tag\\\":\\\"KVHidXy9urg15Sjw/DeibMgxuqw73VajbEN/NZ7YEik\\\\u003d\\\"}\"}"
$request = [
    "devicedata" => $deviceData // response you getting from google pay authorized 
];

$response = $this->client->tokenizeGooglePay($request);

Tokenizing Google Pay Data using the CardSecure API tokenize GooglePay

Tests

composer test

Note: small or large authorization/capture amounts don't seem to work with the test merchant credentials.

Special Thanks

  1. LAYOUTindex
  2. Dewbud\CardConnect

nu1ww/clover-card-point-php 适用场景与选型建议

nu1ww/clover-card-point-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cardconnect」 「cardpointe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nu1ww/clover-card-point-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nu1ww/clover-card-point-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 nu1ww/clover-card-point-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-08