GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
LWP::Authen::OAuth2::ServiceProvider::Dwolla(3) User Contributed Perl Documentation LWP::Authen::OAuth2::ServiceProvider::Dwolla(3)

LWP::Authen::OAuth2::ServiceProvider::Dwolla - Access Dwolla API v2

  my $oauth_dwolla = LWP::Authen::OAuth2->new(
    # client_id/client_secret come from your Dwolla account, under API Keys in
    # Registered Applications
    client_id        => DWOLLA_APP_KEY,
    client_secret    => DWOLLA_APP_SECRET,
    service_provider => 'Dwolla',
    # $use_test = 1 to use uat.dwolla.com in your dev sandbox, for test transactions
    use_test_urls    => $use_test ? 1 : 0,
    redirect_uri     => 'http://my.host/dwolla_redirect_handler',
    # scope for reading funding sources and sending money; see Dwolla docs for other scopes
    scope            => 'Send|Funding',
  );

  # read user's list of funding sources
  my $account = $oauth_dwolla->access_token()->{'_links'}->{'account'}->{'href'};
  my $funding_sources = eval { $oauth_dwolla->make_api_call($account.'/funding-sources') };

  # get all verified bank accounts
  my @verified_sources = grep {
    $_->{'status'} eq 'verified' && $_->{'type'} ne 'balance'
  } @{ $funding_sources->{'_embedded'}->{'funding-sources'} };

  # get user's Dwolla balance, if it has a positive balance
  my ($balance_source) = grep {
    $_->{'type'} eq 'balance'
  } @{ $funding_sources->{'_embedded'}->{'funding-sources'} };

  my $dwolla_balance = eval {
    $oauth_dwolla->make_api_call($balance_source->{'_links'}->{'with-available-balance'}->{'href'})
  };
  print 'Dwolla balance = '.$dwolla_balance->{'balance'}->{'value'}."\n";

  # send 100USD from first verified bank account to $recipient_account_id
  my $success = eval { $oauth2->make_api_call('/transfers', {
    _links => {
      destination => { href => $oauth2->api_url_base().'/accounts/'.$recipient_account_id },
      source      => { href => $verified_sources[0]->{'_links'}->{'account'}->{'href'} },
    },
    amount => { currency => 'USD', value => '100.00' },
  }) };

  # (to send via Dwolla balance, use $balance_source->{'_links'}->{'account'}->{'href'}
  # as source href instead)

First get a Dwolla account, by signing up at dwolla.com. Then create a new application via API Keys -> Create an application. Set up the OAuth Redirect to match the "redirect_uri" in your LWP::Authen::OAuth2 object, and use the application's Key and Secret values in client_id and client_secret.

Full Dwolla API v2 docs can be found here:

<https://docsv2.dwolla.com/>, <https://developers.dwolla.com/>

Adi Fairbank, "<https://github.com/adifairbank>"

You can find documentation for this module with the perldoc command.

    perldoc LWP::Authen::OAuth2::ServiceProvider

You can also look for information at:

Github (submit patches here)
CPAN maintainer's branch: <https://github.com/domm/perl-oauth2>

Branch where I work on Dwolla support: <https://github.com/adifairbank/perl-oauth2>

RT: CPAN's request tracker (report bugs here)
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=LWP-Authen-OAuth2>
AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/LWP-Authen-OAuth2>
CPAN Ratings
<http://cpanratings.perl.org/d/LWP-Authen-OAuth2>
2019-02-25 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.