-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from payjp/nyamanaka/add_3ds_features
add 3DS features(token tds_finish, ThreeDSecureRequest)
- Loading branch information
Showing
5 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package Net::Payjp::ThreeDSecureRequest; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Net::Payjp'; | ||
|
||
sub create{ | ||
my $self = shift; | ||
my %p = @_; | ||
|
||
$self->_request(method => 'POST', url => $self->_class_url, param => \%p); | ||
} | ||
|
||
sub retrieve{ | ||
my $self = shift; | ||
my $id = shift; | ||
$self->id($id) if $id; | ||
|
||
$self->_request(method => 'GET', url => $self->_instance_url); | ||
} | ||
|
||
sub all{ | ||
my $self = shift; | ||
my %p = @_; | ||
|
||
$self->_request(method => 'GET', url => $self->_class_url, param => \%p); | ||
} | ||
|
||
sub _class_url{ | ||
my $self = shift; | ||
return $self->api_base.'/v1/three_d_secure_requests'; | ||
} | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::Mock::LWP; | ||
use Net::Payjp; | ||
use Test::More tests => 11; | ||
|
||
my $payjp = Net::Payjp->new(api_key => 'api_key'); | ||
|
||
isa_ok($payjp->three_d_secure_request, 'Net::Payjp::ThreeDSecureRequest'); | ||
can_ok($payjp->three_d_secure_request, qw(retrieve create all)); | ||
|
||
$Mock_resp->mock( content => sub { '{"id":"tdsr_xxx"}' } ); | ||
$Mock_resp->mock( code => sub {200} ); | ||
$Mock_ua->mock( timeout => sub {} ); | ||
$Mock_ua->mock( default_header => sub {} ); | ||
|
||
#Create | ||
$Mock_req->mock( content => sub { | ||
my $p = $_[1]; | ||
is($p, 'resource_id=car_xxxx'); | ||
} ); | ||
my $tds_request = $payjp->three_d_secure_request; | ||
my $res = $tds_request->create(resource_id => 'car_xxxx'); | ||
is($Mock_req->{new_args}[1], 'POST'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/three_d_secure_requests'); | ||
is($res->id, 'tdsr_xxx'); | ||
is($tds_request->id, 'tdsr_xxx'); | ||
|
||
#Retrieve | ||
$tds_request->retrieve; | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/three_d_secure_requests/tdsr_xxx'); | ||
|
||
#tds_finish | ||
$tds_request->all; | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/three_d_secure_requests'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters