Closed JC5 closed 6 years ago
Alright, and now with less frustration.
So I realized this week that bunq has changed the way their API's work. I cannot access the sandbox anymore. The bunq php kit doesn't work anymore when pointing to the sandbox and applying an API key. OK, that's a problem but nothing we can't fix, right?
According to the helpdesk I'm supposed to use Tinker. Tinker has no instructions except to run some bash script from the web. Luckily it turns out that this script clones a git repository and has some example code. But that doesn't help me at all. I already have code that works. I'm not a paying bunqer (I'm in the old 1 euro program) so I can't get a production key. But I shouldn't have to test against production anyway.
So what do I do to access any kind of sandbox environment? I should not have to use different libraries to access the sandbox vs. accessing the production environment, right? So what do I do now?
Thanks.
Trying to get access to the bunq API has been a very frustrating experience so far and as cool and hip as you are, being a startup and all, I would really appreciate some common sense and stability.
@OGKevin
How is the little menu that appears after running the bash command no instructions
?
Maybe we can add a little text that say Run any command to generate sandbox API key
. Feel free to make a PR for this tho.
All you do is run any command and a bunq-sandbox.conf
is generated in that folder with credentials :)
Yes, that would be helpful. I appreciate that I no longer need the "service" desk to do this for me.
vagrant@ubuntu-bionic:~/tinker$ bash <(curl -s https://tinker.bunq.com/php/setup.sh)
Cloning into '.'...
remote: Counting objects: 140, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 140 (delta 0), reused 2 (delta 0), pack-reused 137
Receiving objects: 100% (140/140), 57.11 KiB | 343.00 KiB/s, done.
Resolving deltas: 100% (56/56), done.
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'master'
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 5 installs, 0 updates, 0 removals
- Installing psr/http-message (1.0.1): Loading from cache
- Installing guzzlehttp/psr7 (1.4.2): Loading from cache
- Installing guzzlehttp/promises (v1.3.1): Loading from cache
- Installing guzzlehttp/guzzle (6.3.3): Loading from cache
- Installing bunq/sdk_php (0.13.2): Loading from cache
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Generating autoload files
██████╗ ██████╗ ████████╗██╗███╗ ██╗██╗ ██╗███████╗██████╗
██╔════╝ ██╔═══██╗ ╚══██╔══╝██║████╗ ██║██║ ██╔╝██╔════╝██╔══██╗
██║ ███╗██║ ██║ ██║ ██║██╔██╗ ██║█████╔╝ █████╗ ██████╔╝
██║ ██║██║ ██║ ██║ ██║██║╚██╗██║██╔═██╗ ██╔══╝ ██╔══██╗
╚██████╔╝╚██████╔╝ ██║ ██║██║ ╚████║██║ ██╗███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
🎨 Tinker the bunq API - An API so powerful that we built bunq on it
┌───────────────────────┬─────────────────────────────────┐
│ │ Run │
├───────────────────────┼─────────────────────────────────┤
│ ✅ Show Overview │ tinker/user-overview.php │
├───────────────────────┼─────────────────────────────────┤
│ 🔼 Make a payment │ tinker/make-payment.php │
│ │ │
│ │ Additional parameters: │
│ │ --amount [euro] │
│ │ --recipient [email] │
│ │ --description [string] │
├───────────────────────┼─────────────────────────────────┤
│ 🔽 Make a request │ tinker/make-request.php │
│ │ │
│ │ Additional parameters: │
│ │ --amount [euro] │
│ │ --recipient [email] │
│ │ --description [string] │
├───────────────────────┼─────────────────────────────────┤
│ 🔗 Link Card │ tinker/link-card.php │
│ │ │
│ │ Additional parameters: │
│ │ --card-id [id] │
│ │ --account-id [id] │
├───────────────────────┼─────────────────────────────────┤
│ ✏️ Update Account │ tinker/update-account.php │
│ │ │
│ │ Additional parameters: │
│ │ --account-id [id] │
│ │ --name [string] │
├───────────────────────┼─────────────────────────────────┤
│ 📫️ Add Callback Url │ tinker/add-callback-url.php │
│ │ │
│ │ Additional parameters: │
│ │ --url [url] │
└───────────────────────┴─────────────────────────────────┘
Check out the Source files and tinker with them!
Want to use PRODUCTION? Run: ./go-pro
vagrant@ubuntu-bionic:~/tinker$ ls
base.sh CHANGELOG.md composer.json composer.lock go-pro go-tinker setup.sh src tinker vendor
vagrant@ubuntu-bionic:~/tinker$ ls -lsh
total 64K
4.0K -rw-rw-r-- 1 vagrant vagrant 990 Jul 9 18:32 base.sh
4.0K -rw-rw-r-- 1 vagrant vagrant 813 Jul 9 18:32 CHANGELOG.md
4.0K -rw-rw-r-- 1 vagrant vagrant 857 Jul 9 18:32 composer.json
12K -rw-rw-r-- 1 vagrant vagrant 11K Jul 9 18:32 composer.lock
12K -rwxrwxr-x 1 vagrant vagrant 9.2K Jul 9 18:32 go-pro
8.0K -rwxrwxr-x 1 vagrant vagrant 5.7K Jul 9 18:32 go-tinker
8.0K -rwxrwxr-x 1 vagrant vagrant 5.2K Jul 9 18:32 setup.sh
4.0K drwxrwxr-x 2 vagrant vagrant 4.0K Jul 9 18:32 src
4.0K drwxrwxr-x 2 vagrant vagrant 4.0K Jul 9 18:32 tinker
4.0K drwxrwxr-x 7 vagrant vagrant 4.0K Jul 9 18:32 vendor
vagrant@ubuntu-bionic:~/tinker$ tinker/user-overview.php
████████╗██╗███╗ ██╗██╗ ██╗███████╗██████╗ ██╗███╗ ██╗ ██████╗
╚══██╔══╝██║████╗ ██║██║ ██╔╝██╔════╝██╔══██╗██║████╗ ██║██╔════╝
██║ ██║██╔██╗ ██║█████╔╝ █████╗ ██████╔╝██║██╔██╗ ██║██║ ███╗
██║ ██║██║╚██╗██║██╔═██╗ ██╔══╝ ██╔══██╗██║██║╚██╗██║██║ ██║
██║ ██║██║ ╚████║██║ ██╗███████╗██║ ██║██║██║ ╚████║╚██████╔╝
╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═════╝
An unexpected error occurred: HTTP Response Code: 400
The response id to help bunq debug: 3e7ee185-14b1-4cd7-a0b6-e431bc146263
Error message: User credentials are incorrect. Incorrect API key or IP address.
PHP Fatal error: Uncaught bunq\Exception\BunqException: Could not find the API context file "bunq-sandbox.conf". in /home/vagrant/tinker/vendor/bunq/sdk_php/src/Context/ApiContext.php:198
Stack trace:
#0 /home/vagrant/tinker/vendor/bunq/sdk_php/src/Context/ApiContext.php(182): bunq\Context\ApiContext::getContextJsonString('bunq-sandbox.co...')
#1 /home/vagrant/tinker/src/BunqLib.php(91): bunq\Context\ApiContext::restore('bunq-sandbox.co...')
#2 /home/vagrant/tinker/src/BunqLib.php(76): bunq\tinker\BunqLib->setupContext()
#3 /home/vagrant/tinker/tinker/user-overview.php(14): bunq\tinker\BunqLib->__construct(Object(bunq\Util\BunqEnumApiEnvironmentType))
#4 {main}
thrown in /home/vagrant/tinker/vendor/bunq/sdk_php/src/Context/ApiContext.php on line 198
I've played around with it, but I'm not sure what I can do to fix this.
My experience with these type of environments is that the IP address does not match for some network setup related issue that i did not manage to solve yet. Same issue happens when running CI test (Travis) on the php SDK.
I would suggest to run this on the host instead of inside a container, or try and fix the network issue where that causes the IP miss-match.
Wait, it seems that sandbox is broken indeed. Looking into it.
Should be fixed. Might be that you will still run in the container issue i explained above tho.
I'm sorry Kevin, completely forgot to give you feedback. Your solution worked and I got my key. Thanks for the quick fix!
kthxbye