定制 benoth/boa-compra 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

benoth/boa-compra

最新稳定版本:1.0.3

Composer 安装命令:

composer require benoth/boa-compra

包简介

Unofficial BoaCompra billing PHP library

README 文档

README

Software License Build Status Coverage Status Quality Score SensioLabsInsight

This package is compliant with PSR-1, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Requirements

The following versions of PHP are supported:

  • PHP 5.4
  • PHP 5.5
  • PHP 5.6
  • PHP 7
  • HHVM

The following extensions are also required:

  • curl
  • mbstring

Usage

Create a payment

$vsi = new VirtualStoreIdentification($yourStoreId, $yourSecretKey);

try {
    $endUser = new EndUser('me@example.com');
    $endUser->setName('John Doe')
            // ...
            ->setLanguage('en_US');

    $payment = new Payment(
        $vsi,
        $endUser,
        $yourReturnUrl,
        $yourNotifyUrl,
        $yourCurrencyIso,
        $yourOrderId,
        $orderDescription,
        $amount // without dot or comma (ie: 500 for $5.00)
    );
    $payment->setTestMode(1)
            ->setProjectId(1)
            ->setPaymentId(1);
} catch (\Exception $e) {
	// Log or anything ...
}

$form = new PaymentFormGenerator($payment);

// Then in your HTML code, just call :
$form->render();

Validate BoaCompra notification

try {
    // $payment is your previously set Payment object
	$notif = new PaymentNotification(
	    $payment,
	    $_POST['store_id'],
	    $_POST['transaction_id'],
	    $_POST['order_id'],
	    $_POST['amount'],
	    $_POST['currency_code'],
	    $_POST['payment_id'],
	    $_SERVER['REMOTE_ADDR']
	);
	$postback = new PaymentPostBack($notif);
	$postback->validatePayment();
	return 'Ok !';
} catch (\Exception $e) {
	return 'Error validating the payment : '.$e->getMessage();
}

Check the status of a payment

try {
	$notif = new PaymentNotification(
	    $payment,
	    $storeId,
	    $transactionId,
	    $orderId,
	    $amount,
	    $currencyCode,
	    $paymentId
	);
	$status = new PaymentCheckStatus($notif);
	$status->validatePayment();
	return 'Ok !';
} catch (\Exception $e) {
	return 'Error validating the payment : '.$e->getMessage();
}

API

The API documentation is available on Github Pages

Testing

$ vendor/bin/phpunit

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-27