5.10 or higher is required
In advance, you need to get a token by Checkout or payjp.js.
# Create charge
my $payjp = Net::Payjp->new(api_key => $API_KEY);
my $res = $payjp->charge->create(
card => 'token_id_by_Checkout_or_payjp.js',
amount => 3500,
currency => 'jpy',
description => 'test charge',
);
if(my $e = $res->error){
print "Error";
print $e->{message}."\n";
}
# Retrieve a charge
$payjp->id($res->id); # Set id of charge
$res = $payjp->charge->retrieve; # or $payjp->charge->retrieve($res->id);
This module is a wrapper around the Pay.jp HTTP API.Methods are generally named after the object name and the acquisition method.
This method returns json objects for responses from the API.
Please check API Reference
This creates a new Payjp api object by Net::Payjp->new()
.
The following parameters are accepted:
Type: Str
This attribute is required. You get this from your account settings on PAY.JP.
Type: Int
You can automatically retry the request when the client received HTTP 429 response caused by Rate Limit.
By default, this is 0 (=retry disabled). To activate, set max_retry
for 1 or more.
my $payjp = Net::Payjp->new(api_key => 'sk_live_xxx', max_retry => 2);
Type: Int
Please check max_retry
and Rate Limit.
By default, this is 2 (sec).
Type: Int
Please check max_retry
and Rate Limit.
By default, this is 32 (sec).
$ cmanm package
or
$ perl -MCPAN -e shell
cpan> install LWP::UserAgent
cpan> install LWP::Protocol::https
cpan> install HTTP::Request::Common
cpan> install JSON
cpan> install Test::More
cpan> install Test::Mock::LWP
$ perl Makefile.PL
$ make test
or Check GitHub Actions