binarycabin/brainblocks 问题修复 & 功能扩展

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

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

binarycabin/brainblocks

最新稳定版本:1.4.3

Composer 安装命令:

composer require binarycabin/brainblocks

包简介

An integration helper for taking Nano payments via BrainBlocks

README 文档

README

An integration helper for taking Nano payments via BrainBlocks.io

This package adds a few helpers when adding a BrainBlocks button with Laravel

Installation

composer require binarycabin/brainblocks

In .env, add your Nano wallet address the button will send to:

BRAINBLOCKS_RECEIVE_ADDRESS=nano_1999...

Adding Buttons

Simply include the button view where you would like the button to appear. Be sure to include the amount (in rai) that the button will take as well as the url the button will POST to with a valid brainblocks token:

@include('brainblocks::button',['amount'=>1000,'action'=>url('/pay')])

You can add multiple buttons on this page using this include. Then at the bottom of the page, be sure to add your javascript

@include('brainblocks::scripts')

Validating BrainBlocks Responses

In your POST route, call the

Route::post('/pay', function(Request $request){
    $brainBlocksResponse = \BrainBlocks::getTokenResponse($request->brainblocks_token);
    $responseIsValid = \BrainBlocks::validateResponse($brainBlocksResponse,[
        'amount_rai' => 200,
    ]);
    dump($brainBlocksResponse);
    if($responseIsValid){
    	//.. do successful stuff
    }
});

BrainBlocks::getTokenResponse will return the full response from the BrainBlocks, this can be validated manually or you can use the validateResponse helper.

By default, the validateResponse helper will make sure:

  • the fulfilled property is true
  • the "destination" address matches the address your config The second property takes an array of additional validations you would like to check, for example checking the amount.

Custom Currencies

In addition to the default "rai", you can change the currency used to any of the supported currencies listed on brainblocks.io

@include('brainblocks::button',['amount'=>5,'currency'=>'usd','action'=>url('/pay')])

Be sure to update your validator to look for the correct currency and amount

$responseIsValid = \BrainBlocks::validateResponse($brainBlocksResponse,[
	'amount' => 5,
	'currency' => 'usd',
]);

Custom Destination

If you need a specific button to go to a destination address other than the one set in your configuration, you can add it as an option as well

@include('brainblocks::button',['amount'=>1000,'destination'=>'nano_11223344...','action'=>url('/pay')])

Be sure to update your validator to look for the changed destination instead of the default

$responseIsValid = \BrainBlocks::validateResponse($brainBlocksResponse,[
	'amount_rai' => 1000,
	'destination' => 'xrb_1kojnrrw8rtybqsqk5uh7bcioo8thkiqjkibmn43togd416gzfye6j44b9sc',
]);

Donate

Donate with NaNote

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固