承接 givepay/givepay-gateway 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

givepay/givepay-gateway

Composer 安装命令:

composer require givepay/givepay-gateway

包简介

A library for interacting with FlatRatePay

README 文档

README

Build Status Scrutinizer Code QualityCode Coverage Code Intelligence Status

A library for interacting with FlatRatePay transactions APIs with the GivePay Gateway.

Installation

Install the library with Composer:

composer require givepay/givepay-gateway

Usage

Simple sale transaction example:

<?php

use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\Address;
use \GivePay\Gateway\Transactions\Card;
use \GivePay\Gateway\Transactions\Sale;
use \GivePay\Gateway\Transactions\TerminalType;

// Get configuration information
$client_id     = getenv("CLIENT_ID");
$client_secret = getenv("CLIENT_SECRET");
$merchant_id   = getenv("MERCHANT_ID");
$terminal_id   = getenv("TERMINAL_ID");

// Create the credit/debit card object
$card = Card::withCard(
    "411111111111", // Test Visa PAN
    "331", // CVV/CVV2
    "09", // Expiration month (MM)
    "23" // Expiration year (YY)
);

// Collect the payer's billing address 
$payer_address = new Address(
    "1 N Main St.",
    "",
    "Fort Worth",
    "TX",
    "76104"
);

$sale = new Sale(
    17.00, // Transaction amount in dollars
    TerminalType::$ECommerce,
    $payer_address,
    "tester@example.com", // Billing email address
    "5555555555", // Billing phone number
    $card
);

// Create the client. You may use this globally within your application
$client = new GivePayGatewayClient(
    $client_id, $client_secret
);

// Make the transaction
$transaction_result = $client->chargeAmount($merchant_id, $terminal_id, $sale);

if (true == $transaction_result->getSuccess()) {
    echo "Transaction ID: " . $transaction_result->getTransactionId();
} else {
    echo "Transaction failed with message: " . $transaction_result->getErrorMessage();
}

?>

Voiding a transaction

<?php

use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\V0id;
use \GivePay\Gateway\Transactions\TerminalType;

/**
* @var GivePayGatewayClient $client The client
 */
$client;

/**
* @var string $merchant_id Your merchant ID
 */
$merchant_id;

/**
* @var string $terminal_id Your terminal ID
 */
$terminal_id;

// The transaction ID of the transaction to void
$transaction_id = "<transaction id>";

$void = new V0id(
    TerminalType::$ECommerce,
    $transaction_id // The transaction ID
);

// Make the void transaction
$void_result = $client->voidTransaction(
    $transaction_id, 
    $merchant_id, 
    $terminal_id
);

if (true == $void_result->getSuccess()) {
    echo "Transaction ID: " . $void_result->getTransactionId();
} else {
    echo "Transaction failed with message: " . $void_result->getErrorMessage();
}

Creating and using tokens:

<?php

use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\Address;
use \GivePay\Gateway\Transactions\Card;
use \GivePay\Gateway\Transactions\Sale;
use \GivePay\Gateway\Transactions\TerminalType;

/**
* @var GivePayGatewayClient $client The client
 */
$client;

/**
* @var string $merchant_id Your merchant ID
 */
$merchant_id;

/**
* @var string $terminal_id Your terminal ID
 */
$terminal_id;

/**
* @var Address $payer_address The payer's billing address
 */
$payer_address;

// Create the credit/debit card object
$card_to_store = Card::withCard(
    "411111111111", // Test Visa PAN
    "331", // CVV/CVV2
    "09", // Expiration month (MM)
    "23" // Expiration year (YY)
);

// Store the card in the gateway and retrieve a payment token string
$token = $client->storeCard(
    $merchant_id,
    $terminal_id,
    $card_to_store
);

// Create a card from a token string
$payment_card = Card::withToken($token);

// Create the Sale request
$sale = new Sale(
    17.50, 
    TerminalType::$ECommerce, 
    $payer_address, 
    "tester@example.com", 
    "5555555555", 
    $payment_card
);

// Make the transaction
$sale_result = $client->chargeAmount(
    $merchant_id,
    $terminal_id,
    $sale
);

if (true == $sale_result->getSuccess()) {
    echo "Transaction ID: " . $sale_result->getTransactionId();
} else {
    echo "Transaction failed with message: " . $sale_result->getErrorMessage();
}

License

givepay/givepay-gateway is licensed under the GPLv3 license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2018-08-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固