Business-OnlinePayment-BitPay-Client

 view release on metacpan or  search on metacpan

t/client.t  view on Meta::CPAN

use URI;
use lib 'lib';

BEGIN{
    my $tokensResponse = '{"data":[{"policies":[{"policy":"id", "method":"inactive", "params":["TfFkHfxvFx7wvLtnqrudrZRqPEuwCpE8X9L"]}], "token":"DCvbrN5iXzo4X4s4bgBiDjS624o72MVQfacoghGWhCqz", "dateCreated":1436809787782, "pairingExpiration":14368961...
    my $paircodeResponse = '{"data":[{"policies":[{"policy":"id", "method":"require", "params":["TfLAXsWtvWpSgqMYjJ1QvJEx2Bdob1mDeK4"]}], "resource":"Gd1q7mZJQU5zGoHAFsh1bmYEcWYQnzHZW6sjWatxtEr2", "token":"9nYwJ7KRRAcH1rXwJZRonXYrJJjcwAUowTC63UVLSYaC...
    my $invoiceResponse = '{"facade":"pos/invoice", "data": {"url":"https://paul.bp:8088/invoice?id=FAdAZK8FwmHyUZSzRvT9GW", "status":"new", "btcPrice":"0.035314", "btcDue":"0.035314", "price":10, "currency":"USD", "exRates":{"USD":283.1700000000001}...
    my $getTokens = '{"data": [{"pos/invoice":"7zjXTgeWaTj7xXNBA1qV7iBGGHJZNiLjPXNquHdk8BUN"}, {"pos":"HwC497kDGihPFUDiPfbedj6etbrVHyKQaiFHPGspYHHV"}]}';
    my $httpd = run_http_server {
        my $request = shift;
        my $decoded = decode_json($request->content) if $request->content;
        my $uri = $request->uri;
        my $method = $request->method;
        if ($uri->path eq '/postthis') {
        }
        return do {
            if ($method eq "POST") {
                if( $uri->path eq '/postthis' && $decoded->{"token"} && $decoded->{"facade"} ) {
                    [
                        200,
                        [ 'Content-Type' => 'application/json' ],
                        [ '{"facade":"correct", "token":"correct"}']
                    ]
                } elsif( $decoded->{"pairingCode"} && $uri->path eq '/tokens' ) {
                    [
                        200,
                        [ 'Content-Type' => 'application/json' ],
                        [ $paircodeResponse ]
                    ]
                } elsif( $uri->path eq '/tokens' ){
                    [
                        200,
                        [ 'Content-Type' => 'application/json' ],
                        [ $tokensResponse ]



( run in 0.971 second using v1.01-cache-2.11-cpan-26ccb49234f )