The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

SYNOPSIS

 # 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',
 );
 if(my $e = $res->error){
   print "Error;
   print $e->{message}."\n";
 }
 # Id of charge.
 print $res->id;

 # Retrieve a charge
 $payjp->id($res->id); # Set id of charge
 $res = $payjp->charge->retrieve; # or $payjp->charge->retrieve($res->id);

DESCRIPTION

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.

new Method

This creates a new Payjp api object. The following parameters are accepted:

api_key

This is required. You get this from your Payjp Account settings.

Charge Methods

create

Create a new charge

https://pay.jp/docs/api/#支払いを作成

 $payjp->charge->create(
   card => 'tok_76e202b409f3da51a0706605ac81',
   amount => 3500,
   currency => 'jpy',
   description => 'yakiimo',
 );

retrieve

Retrieve a charge

https://pay.jp/docs/api/#支払いを情報を取得

 $payjp->charge->retrieve('ch_fa990a4c10672a93053a774730b0a');

save

Update a charge

https://pay.jp/docs/api/#支払いを情報を取得

 $payjp->id('ch_fa990a4c10672a93053a774730b0a');
 $payjp->charge->save(description => 'update description.');

refund

Refund a charge

https://pay.jp/docs/api/#返金する

 $payjp->id('ch_fa990a4c10672a93053a774730b0a');
 $payjp->charge->refund(amount => 1000, refund_reason => 'test.');

capture

Capture a charge

https://pay.jp/docs/api/#支払い処理を確定する

 $payjp->id('ch_fa990a4c10672a93053a774730b0a');
 $payjp->charge->capture(amount => 2000);

all

Returns the charge list

https://pay.jp/docs/api/#支払いリストを取得

 $payjp->charge->all("limit" => 2, "offset" => 1);

Customer Methods

create

Create a cumtomer

https://pay.jp/docs/api/#顧客を作成

 $payjp->customer->create(
   "description" => "test",
 );

retrieve

Retrieve a customer

https://pay.jp/docs/api/#顧客情報を取得

 $payjp->customer->retrieve('cus_121673955bd7aa144de5a8f6c262');

save

Update a customer

https://pay.jp/docs/api/#顧客情報を更新

 $payjp->id('cus_121673955bd7aa144de5a8f6c262');
 $payjp->customer->save(email => 'test@test.jp');

delete

Delete a customer

https://pay.jp/docs/api/#顧客を削除

 $payjp->id('cus_121673955bd7aa144de5a8f6c262');
 $payjp->customer->delete;

all

Returns the customer list

https://pay.jp/docs/api/#顧客リストを取得

$res = $payjp->customer->all(limit => 2, offset => 1);

Cutomer card Methods

Returns a customer's card object

 my $card = $payjp->customer->card('cus_4df4b5ed720933f4fb9e28857517');

create

Create a customer's card

https://pay.jp/docs/api/#顧客のカードを作成

 $card->create(
   card => 'tok_76e202b409f3da51a0706605ac81'
 );

retrieve

Retrieve a customer's card

https://pay.jp/docs/api/#顧客のカード情報を取得

 $card->retrieve('car_f7d9fa98594dc7c2e42bfcd641ff');

save

Update a customer's card

https://pay.jp/docs/api/#顧客のカードを更新

$card->id('car_f7d9fa98594dc7c2e42bfcd641ff'); $card->save(exp_year => "2026", exp_month => "05", name => 'test');

delete

Delete a customer's card

https://pay.jp/docs/api/#顧客のカードを削除

 $card->id('car_f7d9fa98594dc7c2e42bfcd641ff');
 $card->delete;

all

Returns the customer's card list

https://pay.jp/docs/api/#顧客のカードリストを取得

 $card->all(limit => 2, offset => 0);

Customer subscription Methods

Returns a customer's subscription object

 my $subscription = $payjp->customer->subscription('sub_567a1e44562932ec1a7682d746e0');

retrieve

Retrieve a customer's subscription

https://pay.jp/docs/api/#顧客の定期課金情報を取得

 $subscription->retrieve('sub_567a1e44562932ec1a7682d746e0');

all

Returns the customer's subscription list

https://pay.jp/docs/api/#顧客の定期課金リストを取得

$subscription->all(limit => 1, offset => 0);

Plan Methods

create

Create a plan

https://pay.jp/docs/api/#プランを作成

 $payjp->plan->create(
   amount => 500,
   currency => "jpy",
   interval => "month",
   trial_days => 30,
   name => 'test_plan'
 );

retrieve

Retrieve a plan

https://pay.jp/docs/api/#プラン情報を取得

 $payjp->plan->retrieve('pln_45dd3268a18b2837d52861716260');

save

Update a plan

https://pay.jp/docs/api/#プランを更新

 $payjp->id('pln_45dd3268a18b2837d52861716260');
 $payjp->plan->save(name => 'NewPlan');

delete

Delete a plan

https://pay.jp/docs/api/#プランを削除

 $payjp->id('pln_45dd3268a18b2837d52861716260');
 $payjp->plan->delete;

all

Returns the plan list

https://pay.jp/docs/api/#プランリストを取得

 $payjp->plan->all("limit" => 5, "offset" => 0);

Subscription Methods

create

Create a subscription

https://pay.jp/docs/api/#定期課金を作成

 $payjp->subscription->create(
   customer => 'cus_4df4b5ed720933f4fb9e28857517',
   plan => 'pln_9589006d14aad86aafeceac06b60'
 );

retrieve

Retrieve a subscription

https://pay.jp/docs/api/#定期課金情報を取得

 $payjp->subscription->retrieve('sub_567a1e44562932ec1a7682d746e0');

save

Update a subscription

https://pay.jp/docs/api/#定期課金を更新

 $payjp->id('sub_567a1e44562932ec1a7682d746e0');
 $payjp->subscription->save(trial_end => 1473911903);

pause

Pause a subscription

https://pay.jp/docs/api/#定期課金を停止

 $payjp->id('sub_567a1e44562932ec1a7682d746e0');
 $payjp->subscription->pause;

resume

Resume a subscription

https://pay.jp/docs/api/#定期課金を再開

 $payjp->id('sub_567a1e44562932ec1a7682d746e0');
 $payjp->subscription->resume;

cancel

Cancel a subscription

https://pay.jp/docs/api/#定期課金をキャンセル

 $payjp->id('sub_567a1e44562932ec1a7682d746e0');
 $payjp->subscription->cancel;

delete

Delete a subscription

https://pay.jp/docs/api/#定期課金を削除

 $payjp->id('sub_567a1e44562932ec1a7682d746e0');
 $payjp->subscription->delete;

all

Returns the subscription list

https://pay.jp/docs/api/#定期課金のリストを取得

 $payjp->subscription->all(limit => 3, offset => 0);

Token Methods

retrieve

Retrieve a token

https://pay.jp/docs/api/#トークン情報を取得

$payjp->token->retrieve('tok_eff34b780cbebd61e87f09ecc9c6');

Transfer Methods

retrieve

Retrieve a transfer

https://pay.jp/docs/api/#入金情報を取得

 $payjp->transfer->retrieve('tr_8f0c0fe2c9f8a47f9d18f03959ba1');

all

Returns the transfer list

https://pay.jp/docs/api/#入金リストを取得

 $payjp->transfer->all("limit" => 3, offset => 0);

charges

Returns the charge list

https://pay.jp/docs/api/#入金の内訳を取得

 $payjp->transfer->charges(
   limit => 3,
   offset => 0
 );

Event Methods

retrieve

Retrieve a event

https://pay.jp/docs/api/#イベント情報を取得

 $res = $payjp->event->retrieve('evnt_2f7436fe0017098bc8d22221d1e');

all

Returns the event list

https://pay.jp/docs/api/#イベントリストを取得

$payjp->event->all(limit => 10, offset => 0);

Account Methods

retrieve

Retrieve a account

https://pay.jp/docs/api/#アカウント情報を取得

 $payjp->account->retrieve;

1 POD Error

The following errors were encountered while parsing the POD:

Around line 117:

Non-ASCII character seen before =encoding in 'L<https://pay.jp/docs/api/#支払いを作成>'. Assuming UTF-8