PerlでPayPal エクスプレスチェックアウトAPIのLandingPageオプションを使う
 
		  		        
      Perlモジュール Business::PayPal::API
PayPalのAPIを使う時は Business::PayPal::API というモジュールが便利。
先日のエントリー PayPal利用時の決済フローを考える でLandingPageオプションの事を書いたのですが、Business::PayPal::API で実装するとそのままでは利用出来ないので、Business::PayPal::API::ExpressCheckout のソースを変更する必要があります。
PayPalの英語版APIの解説書(PDF)にはLandingPageの記載が無いようでしたので日本独自の仕様なのでしょうか??変更方法は簡単です。
パスは自分の環境ですと
/usr/lib/perl5/site_perl/5.8.5/Business/PayPal/API/ExpressCheckout.pm でした。
変更方法
Business::PayPal::API::ExpressCheckoutの21行目付近に、
my %types = ( Token => 'ebl:ExpressCheckoutTokenType', OrderTotal => 'cc:BasicAmountType', currencyID => '', MaxAmount => 'cc:BasicAmountType', OrderDescription => 'xs:string', Custom => 'xs:string', InvoiceID => 'xs:string', ReturnURL => 'xs:string', CancelURL => 'xs:string', Address => 'ebl:AddressType', ReqConfirmShipping => 'xs:string', NoShipping => 'xs:string', AddressOverride => 'xs:string', LocaleCode => 'xs:string', PageStyle => 'xs:string', 'cpp-header-image' => 'xs:string', 'cpp-header-border-color' => 'xs:string', 'cpp-header-back-color' => 'xs:string', 'cpp-payflow-color' => 'xs:string', PaymentAction => '', BuyerEmail => 'ebl:EmailAddressType' );
というハッシュの定義があるのでそこに1項目追加するだけです。
以下の様に追記します。
my %types = ( Token                     => 'ebl:ExpressCheckoutTokenType',
		  OrderTotal                => 'cc:BasicAmountType',
		  currencyID                => '',
		  MaxAmount                 => 'cc:BasicAmountType',
		  OrderDescription          => 'xs:string',
		  Custom                    => 'xs:string',
		  InvoiceID                 => 'xs:string',
		  ReturnURL                 => 'xs:string',
		  CancelURL                 => 'xs:string',
		  Address                   => 'ebl:AddressType',
		  ReqConfirmShipping        => 'xs:string',
		  NoShipping                => 'xs:string',
		  AddressOverride           => 'xs:string',
		  LocaleCode                => 'xs:string',
		  PageStyle                 => 'xs:string',
		  'cpp-header-image'        => 'xs:string',
		  'cpp-header-border-color' => 'xs:string',
		  'cpp-header-back-color'   => 'xs:string',
		  'cpp-payflow-color'       => 'xs:string',
		  PaymentAction             => '',
		  BuyerEmail                => 'ebl:EmailAddressType',
		  LandingPage               => '' );
これでLandingPageをBillingにした際にクレジットカード情報入力フォームが最初に表示される様になります。
- 
            前の記事  PayPal利用時の決済フローを考える 2010.03.29
- 
            次の記事  同一ディレクトリ内の配下に作成出来るディレクトリ数制限 2010.04.01
