Skip to content

Commit 63d3696

Browse files
committed
update docs
1 parent 142e814 commit 63d3696

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,49 @@
1-
# BrainBlocks
1+
# BrainBlocks for Laravel
2+
23
An integration helper for taking Nano payments via BrainBlocks.io
34

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

6-
# Installation
7+
## Installation
78

89
```
910
composer require binarycabin/brainblocks
1011
```
12+
13+
In .env, add your Nano wallet address the button will send to:
14+
15+
```
16+
BRAINBLOCKS_RECEIVE_ADDRESS=xrb_1999...
17+
```
18+
19+
## Adding Buttons
20+
21+
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:
22+
23+
```
24+
@include('brainblocks::button',['amountRai'=>1000,'action'=>url('/pay')])
25+
```
26+
27+
## Validating BrainBlocks Responses
28+
29+
In your POST route, call the
30+
31+
```
32+
Route::post('/pay', function(Request $request){
33+
$brainBlocksResponse = \BrainBlocks::getTokenResponse($request->brainblocks_token);
34+
$responseIsValid = \BrainBlocks::validateResponse($brainBlocksResponse,[
35+
'amount_rai' => 200,
36+
]);
37+
dump($brainBlocksResponse);
38+
if($responseIsValid){
39+
//.. do successful stuff
40+
}
41+
});
42+
```
43+
44+
BrainBlocks::getTokenResponse will return the full response from the BrainBlocks, this can be validated manually or you can use the "validateResponse" helper.
45+
46+
By default, the validateResponse helper will make sure:
47+
- the "fufilled" property is "true"
48+
- the "destination" address matches the address your config
49+
The second property takes an array of additional validations you would like to check, for example checking the amount.

0 commit comments

Comments
 (0)