
çŸæç¹ã§ã¯ãPayPalã¯æã人æ°ã®ããé»å決æžãã©ãããã©ãŒã ã§ãã åŸæ¥ã®æ¯æãã®åãåãæ¹æ³ãšæ¯èŒããŠãå£åº§ãéèšããŠè³éã®åãåããéå§ããããšãã©ãã»ã©ç°¡åããããã®ä¿¡ããããªãã»ã©ã®äººæ°ã®çç±ïŒ1ã§ãã 2çªç®ã®çç±ã¯ãå€ãã®äººãç§ã«åæããã§ãããããPayPalãæäŸãã匷åãªAPIã§ãã ãã®ãããã¯ã§ã¯ãPayPal APIã®æäœã«é¢é£ãããã¹ãŠã®ã¡ãœãããšããªãã¯ãé çªã«ã¬ã€ã¢ãŠãããŠãçµ±åã®åé¡ãåé¿ããŸãã
èŠåïŒ PayPal APIã¯ããããŸã§èŠãäžã§æããããããããã®ã®1ã€ã§ãã äžè²«æ§ã®ãªããå Žåã«ãã£ãŠã¯äžå®å
šãŸãã¯äžè²«æ§ã®ãªãããã¥ã¡ã³ããäºæž¬ã§ããªãé害ãããã³å®éã®ç¶æ
ãšãµã³ãããã¯ã¹ã§ã®APIã®åäœã®å€§ããªéãã¯ãããããã¹ãŠãæ¬è³ªçã«å¯ŸåŠããªããã°ãªããªãåé¡ã§ãã

PayPalã¯ãPPã«äžæ
£ããªäººãæ··ä¹±ãããã«ã¯ããããªãããŸããŸãªæ¯æãæ¹æ³ãæäŸããŸãã
ãšã¯ã¹ãã¬ã¹æ¯æãPayPalãæäŸããå€ãã®é¡äŒŒãããµãŒãã¹ã®ã¡ã€ã³ãµãŒãã¹ã ãšã¯ã¹ãã¬ã¹æ¯æãã§ã¯ã売ãæã®ã¢ã«ãŠã³ããªãã§è³éãåãåãããšãã§ããŸããéåžžãã¢ã«ãŠã³ãã®éåžžã®ç¢ºèªïŒéè¡å£åº§ãŸãã¯ã¯ã¬ãžãã/ããããã«ãŒãã®ããããïŒãé€ããç¹å¥ãªèŠä»¶ã¯ãããŸããã 以åã¯ããŠãŒã¶ãŒã¯ä»ã®PayPalãŠãŒã¶ãŒããã®æç€ºçãªæ¯æãã®ã¿ãåãå
¥ããããšãã§ããŸããããã·ã¹ãã ã¯ã¢ã«ãŠã³ããæã£ãŠããªã人ã®ããã«éè¡ã«ãŒãããçŽæ¥æ¯æãæ©èœãå°å
¥ãããããã«ãŒããæã£ãŠããã»ãŒå
šå¡ããæ¯æããåãåãããšãã§ããŸãã ãšã¯ã¹ãã¬ã¹æ¯æãã¯PayPalãã©ãããã©ãŒã ã§å®å
šãã€å®å
šã«å®è¡ãããããããã®æ¹æ³ãWebãµã€ãã«å®å
šã«çµ±åããããšã¯ã§ããŸããã
çŽæ¥æ¯æããã®æ¹æ³ã䜿çšãããšãç°¡åãªAPIåŒã³åºãã§éè¡ã«ãŒãããæ¯æããåãåãããšãã§ããŸãã ããã«ããã翻蚳ããã»ã¹å
šäœããŠã§ããµã€ãã«å®å
šã«çµ±åã§ããããã«ãªããå Žåã«ãã£ãŠã¯ãŠãŒã¶ãŒã®ã·ã§ããã³ã°ããã䟿å©ã«ãªããŸãã çŽæ¥æ¯æãã«ã¯å¥ââã®ããªãšãŒã·ã§ã³ããããäžå®ã®æéãçµéããåŸã«ã®ã¿æ¯æ¿ãèš±å¯ããŠå®è¡ããããšãã§ããŸãã é
å»¶æ¯æãæ¹æ³ã¯ãç±³åœãã«ãããããã³è±åœã®ãŠãŒã¶ãŒã®ã¿ãå©çšã§ããŸãã
å®ææ¯æããã®æ¹æ³ã䜿çšãããšããŠãŒã¶ãŒã®ã¢ã«ãŠã³ãããè³éãååŒãåºãã§ããŸãïŒããšãã°ããµãã¹ã¯ãªãã·ã§ã³ã®ææãã§äœ¿çšãããŸãïŒã
äžæ¬æ¯æãäžæ¬æ¯æãã䜿çšãããšãåãåã£ãè³éãè€æ°ã®ã¢ã«ãŠã³ãéã§å
±æã§ããŸãã
é©å¿æ¯æããã®ãªãã·ã§ã³ã¯åºæ¬çã«åã®ãã®ãšåãæ©èœãå®è¡ããŸãããããã€ãã®éãããããŸãïŒPayPal APIãæ··ä¹±ããããªã«ã«æºã¡ãŠããããšã¯æ¢ã«è¿°ã¹ãããã§ãïŒã
ãã®ãªã¹ãã¯å®å
šãšã¯èšããŸããããè³éãåãåãããã®æãäžè¬çãªæ¹æ³ããªã¹ããããŠããŸãïŒè©³çް-
ããã¥ã¡ã³ããžããããïŒã

PayPalã¯ãããŒã¿ãHTTPçµç±ã§éä¿¡ããããã®2ã€ã®åœ¢åŒãNVPãšSOAPããµããŒãããŠããŸãã NVPã¯Name-Value Pairã®ç¥ã§ãSOAPã¯Simple Object Access Protocolã®ç¥ã§ãã NVPã¯SOAPãããã¯ããã«æè»æ§ãé«ããããNVPã«ã€ããŠã®ã¿èª¬æããŸãã
ããŒã1ã«ãªã¹ããããŠãããã¹ãŠã®ã¡ãœããã«ã¯ç¬èªã®ãã©ã¡ãŒã¿ãŒããããŸãããAPIã¢ã«ãŠã³ããèå¥ããŠæ¯æããæ¿èªããããã«éä¿¡ãããããã€ãã®åäžã®åºæ¬ãã©ã¡ãŒã¿ãŒããããŸãã
USER
PayPal APIã¢ã«ãŠã³ãã®ååã
PWD
PayPal APIã¢ã«ãŠã³ãã®ãã¹ã¯ãŒãã
VERSION
NVP APIã®ããŒãžã§ã³çªå·ãããšãã°74.0 ïŒå·çæç¹ã®ææ°ããŒãžã§ã³ïŒã
SIGNATURE
é»å眲åPayPal APIã ãã®ãã©ã¡ãŒã¿ãŒã¯ãèªèšŒã«èšŒææžã䜿çšããŠããå Žåã«ã®ã¿äœ¿çšããŠãã ããã
æåŸã®å¿
é ãã©ã¡ãŒã¿ãŒã¯
METHOD
ã䜿çšããè³éã転éããæ¹æ³ãéç¥ããŸãã
èŠæ±ã¯HTTPSãããã³ã«ã䜿çšããŠéä¿¡ãããŸãã ããšãã°ãcURLã䜿çšããŠåçŽãªãªã¯ãšã¹ããäœæããããã»ã¹å
šäœãå¥ã®ã¯ã©ã¹ã«é
眮ããŸãã
class Paypal { protected $_errors = array(); protected $_credentials = array( 'USER' => 'seller_1297608781_biz_api1.lionite.com', 'PWD' => '1297608792', 'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p', ); protected $_endPoint = 'https://api-3t.sandbox.paypal.com/nvp'; protected $_version = '74.0'; public function request($method,$params = array()) { $this -> _errors = array(); if( empty($method) ) {
SSLæ€èšŒã«CAèšŒææžã䜿çšããããšã«æ³šæããŠãã ããã èšŒææžãã¡ã€ã«
ã¯cURL Webãµã€ãã«ãããŸãã ããŠã³ããŒãããå Žæã«å¿ããŠãèšŒææžãžã®ãã¹ãå¿ããã«å€æŽããŠãã ããã
ãªã¯ãšã¹ããžã®å¿çã¯NVP圢åŒã«ãªããé
åã«åå²ããŸããã
ACK
ãã©ã¡ãŒã¿ã¯ããªã¯ãšã¹ãã®åŠççµæã瀺ããŸãããªã¯ãšã¹ããæåããå Žåã¯
Success
ãŸãã¯
SuccessWithWarning
ããªã¯ãšã¹ãã倱æããå Žåã¯
Error
ãŸãã¯
Warning
ã§ãã
ãªã¯ãšã¹ãã¯ããŸããŸãªçç±ã§æåŠãããå¯èœæ§ããããæ¯æãæ¹æ³ããšã«
ããã¥ã¡ã³ãã§è©³çްã«èª¬æãããŠããçç±ããã
ãŸã ã å°ãåŸã«ãããã®ããã€ããæ€èšããããããæé€ããæ¹æ³ãåŠã³ãŸãã ãšããã§ããªã¯ãšã¹ãå
ã®ãã¹ãŠã®ãã©ã¡ãŒã¿ã¯å€§æåãšå°æåãåºå¥ããããšããäºå®ã«æ³šæããŠãã ãããå€ãã®å Žåãããã倱æã®çç±ã§ãã

è³éã転éããæãäžè¬çãªæ¹æ³ã®1ã€ã¯é鿝æãã§ãç¹å¥ãªã¢ã«ãŠã³ãïŒWebsite Payments ProïŒãéããã«è³éãåãåãããšãã§ããŸããããã¯ç±³åœåžæ°ã®ã¿ãå©çšå¯èœã§ãæ¯æãã¯ä¿è·ãå¿
èŠãšããªãPayPalåŽã§è¡ãããŸãã
æ¯æãå
šäœã¯ã次ã®ã¢ã«ãŽãªãºã ã«åŸã£ãŠåŠçãããŸãã
- PayPalããã¢ã¯ã»ã¹ããŒã¯ã³ããªã¯ãšã¹ãããééã®è©³çްãéä¿¡ããŸãã
- ããŒã¯ã³ãåä¿¡ããå Žåãåä¿¡ããããŒã¯ã³ã䜿çšããŠãŠãŒã¶ãŒãPayPal Webãµã€ãã«ãªãã€ã¬ã¯ãããŸãã
- ãŠãŒã¶ãŒã¯ãPayPalãã©ãããã©ãŒã ã§æ¯æããè¡ãããã£ã³ã»ã«ãããšãåœç€Ÿã®Webãµã€ãã«ãªãã€ã¬ã¯ããããŸãã
- ãŠãŒã¶ãŒããªãã€ã¬ã¯ãããããã å³ææ¯æãéç¥ïŒIPNïŒãä»ããŠæ¯æããå®äºããŸãã

ãšã¯ã¹ãã¬ã¹æ¯æãããã»ã¹ã¯ãæ¯æãããŒã¿ãPayPal APIã«éä¿¡ããããšã§éå§ããããã®åŸããã©ã³ã¶ã¯ã·ã§ã³ãèå¥ããããŒã¯ã³ãåãåããŸãã ãã®ããŒã¯ã³ã¯ããŠãŒã¶ãŒãPayPalãã©ãããã©ãŒã ã«èªå°ããæ¬¡ã®ã¹ãããã§åœ¹ç«ã¡ãŸãã
ãªã¯ãšã¹ãã§ã¯ã次ã®ãã©ã¡ãŒã¿ãŒãæå®ããå¿
èŠããããŸãã
METHOD
ããã§ãéžæããæ¯æãæ¹æ³ïŒ SetExpressCheckout
ïŒãæå®ããå¿
èŠããããŸãã
RETURNURL
æ¯æããæåããåŸã«ãŠãŒã¶ãŒããªãã€ã¬ã¯ããããã¢ãã¬ã¹ã
CANCELURL
æ¯æãäžã«ãšã©ãŒãçºçããå Žåã«ãŠãŒã¶ãŒããªãã€ã¬ã¯ããããã¢ãã¬ã¹ã
PAYMENTREQUEST_0_AMT
転éã®åèšéé¡ã ããªãªãïŒ .
ïŒã§åºåããã2ã€ã®10鲿°ãæå®ããå¿
èŠããããŸãã ãªãã·ã§ã³ã§ãã³ã³ãïŒ ,
ïŒã䜿çšããŠæ°åãåºåãããšãã§ããŸãã
PAYMENTREQUEST_0_ITEMAMT
ææ°æãææ°æãéæããã®ä»ã®å
ç·ãå«ãŸãªãç·è²»çšã è²»çšã 䜿çšå¯èœãªãã®ããªãå Žåããã®ãã©ã¡ãŒã¿ãŒã®å€ã¯PAYMENTREQUEST_0_AMT
ã®å€ãšäžèŽããå¿
èŠããããŸãã
æ¯æãã«é¢ããäžé£ã®æ
å ±ãæ¡åŒµãã远å ã®ãã©ã¡ãŒã¿ãŒãæž¡ãããšãã§ããŸããäžéšã®ãã©ã¡ãŒã¿ãŒã«ã¯ããã©ã«ãå€ããããŸãã
PAYMENTREQUEST_0_CURRENCYCODE
ãã®ãã©ã¡ãŒã¿ãŒã¯ããã¹ãŠã®æäœãå®è¡ãããéè²šãæ±ºå®ããŸãã 3æ¡ã®ã³ãŒããæå®ããå¿
èŠããããŸãã ããã©ã«ãå€ã¯USD
ã§ãã
PAYMENTREQUEST_0_SHIPPINGAMT
泚æã®éæã
PAYMENTREQUEST_0_TAXAMT
ãã¹ãŠã®ã³ããã·ã§ã³ã®å
šé¡ïŒæ³šæã«è€æ°ã®ããžã·ã§ã³ããããåã³ããã·ã§ã³ã«ç¬èªã®ã³ããã·ã§ã³ãããå Žåã«ã®ã¿å¿
èŠïŒã
PAYMENTREQUEST_0_DESC
翻蚳ã®èª¬æã
ãŠãŒã¶ãŒãäžåºŠã«è€æ°ã®è£œåã®æ¯æããè¡ãå Žåã䟿å®äžã補åã®ãªã¹ããäœæã§ããŸãã
L_PAYMENTREQUEST_0_NAMEm
補åå;
L_PAYMENTREQUEST_0_DESCm
補åã®èª¬æ;
L_PAYMENTREQUEST_0_AMTm
å䟡
L_PAYMENTREQUEST_0_QTYm
ååã®æ°éã
倿°
m
ã¯ç¹å®ã®è£œåãèå¥ããŸãïŒåã補åã«é©çšå¯èœãªãã©ã¡ãŒã¿ãŒã«ã¯åã倿°ã€ã³ããã¯ã¹ã䜿çšããŸãïŒã
ããã¥ã¡ã³ããŒã·ã§ã³ã§ç°¡åã«èŠã€ããããšãã§ããå€ãã®ãªãã·ã§ã³ã®ãã©ã¡ãŒã¿ãŒããããŸãã
åã«ããŒã2ã§äœæãã颿°ã䜿çšããŠã
SetExpressCheckout
ãªã¯ãšã¹ããçæã
SetExpressCheckout
ã

èŠæ±ãæåããå ŽåãPayPalããã®å¿çã®
TOKEN
ãã©ã¡ãŒã¿ãŒã§ããŒã¯ã³ãåãåããŸãã
if(is_array($response) && $response['ACK'] == 'Success') {
ããã§ããŠãŒã¶ãŒã¯PayPalãã©ãããã©ãŒã ã«éãããããã§è»¢éããã»ã¹å
šäœãåŠçãããŸãã ãŠãŒã¶ãŒãæ¯æããæ£åžžã«è¡ãããã£ã³ã»ã«ãããšããªã¯ãšã¹ãã§æå®ãã察å¿ããããŒãžã®ããããã«éä¿¡ãããŸãã

ãŠãŒã¶ãŒã転éã確èªããåŸã転éãåœç€Ÿã®Webãµã€ãã«è¿éããããšããŸãã ãã®æç¹ã§ã2ã€ã®å¯Ÿå¿ããAPI颿°ã䜿çšããå¿
èŠããããŸã
DoExpressCheckoutPayment
ã¯è»¢éãå®äºããŸããããã®åã«
GetExpressCheckoutDetails
ã䜿çšããŠãã€ã€ãŒã«é¢ãã詳现æ
å ±ãååŸããå¿
èŠããããŸãã
PayPalã¯ããããã®é¢æ°ãåŒã³åºãããã«äœ¿çšããããŒã¯ã³ãšãšãã«ããŠãŒã¶ãŒãWebãµã€ãã«ãªãã€ã¬ã¯ãããŸãã ããŒã¯ã³ã¯ã
token
ãã©ã¡ãŒã¿ãŒã®URLã§æå®ãããŸãã ãŠãŒã¶ãŒããªãã€ã¬ã¯ããããã¢ãã¬ã¹ã«ãã®ååšã確èªãããŠãŒã¶ãŒãååšããå Žåã«å¿
èŠãªAPIãªã¯ãšã¹ããéä¿¡ããŸãã
GetExpressCheckoutDetails
颿°ã«ã¯1ã€ã®ããŒã¯ã³ã®ã¿ãå¿
èŠã§ã
DoExpressCheckoutPayment
ã¯ããã€ãã®è¿œå ãã©ã¡ãŒã¿ãŒãå¿
èŠã§ãã
PAYMENTREQUEST_0_PAYMENTACTION
ãã®ãã©ã¡ãŒã¿ãŒã¯ãå¿
èŠãªã¢ã¯ã·ã§ã³ã決å®ããŸãã SetExpressCheckout
颿°ã§å¥ã®ã¢ã¯ã·ã§ã³ãæå®ããªãã£ãå Žåãå€ã¯Sale
ã瀺ãå¿
èŠããããŸãïŒå¯èœãªå€ã®äžã«ã¯Authorization
ãšCapture
ïŒã
PAYERID
ãã®ãã©ã¡ãŒã¿ãŒã¯ãPayPalã¢ã«ãŠã³ãã®äžæã®èå¥åãæå®ããŸãã ããŒã¯ã³ãšåæ§ã«ããŠãŒã¶ãŒããªãã€ã¬ã¯ãããããšïŒ PayerID
ãã©ã¡ãŒã¿ãŒã§ïŒURLã«è¿ãããŸãã
if( isset($_GET['token']) && !empty($_GET['token']) ) {

çŽæ¥æ¯æãã䜿çšãããšããµã€ãã«çŽæ¥ééããããã»ã¹å
šäœãå®å
šã«å¶åŸ¡ã§ããŸãã äœããã®äžæãªçç±ã«ããããã®å ŽåãPayPalã¢ã«ãŠã³ããæããªã賌å
¥è
ã¯ãµã€ãäžã®ãµãŒãã¹ãååã®ä»£éãæ¯æãããšãã§ããŸããããããã»ã¹å
šäœãå¯èœãªéãã·ã³ãã«ã«ããããšãã§ãããŠãŒã¶ãŒã®æèŠã«ãã©ã¹ã®åœ±é¿ãäžããŸãã ããã»ã¹ãå®å
šã«å¶åŸ¡ããããšã§ãå®éã«å£²äžãæé©åããå¢ããããšãã§ããŸãã
ãã®æ¹æ³ã¯ããã¹ãŠã®ãŠãŒã¶ãŒã€ã³ã¿ã©ã¯ã·ã§ã³ãWebãµã€ãã§è¡ãããAPIã«å¯ŸããŠ1ã€ã®ãªã¯ãšã¹ã
DoDirectPayment
ãå®è¡ããã ããªã®ã§ãé鿝æããããå°ãç°¡å
DoDirectPayment
ã
ãã ããäžå®ã®æéïŒããšãã°ãååãé
éãµãŒãã¹ã«é
éãããã®ãåŸ
ã£ãŠãããšãïŒã«ãŠãŒã¶ãŒã®å£åº§ãããéãååŽããå Žåãããã«ããã€ãã®èŠæ±ãè¡ãå¿
èŠããããšããäºå®ã«æ³šæããå¿
èŠããããŸãã ãã®ããã«ã
Authorization
ãš
Capture
ã¡ãœããã䜿çšããŸããããããã«ã€ããŠã¯èª¬æããŸãããããããã®ååšã«ã€ããŠã¯ãŸã ç¥ãå¿
èŠããããŸãã

åè¿°ã®ããã«ãçŽæ¥æ¯æãã§ã¯ããŸã£ããç°ãªããã©ã¡ãŒã¿ãŒãæå®ããå¿
èŠããããŸãã æ¯æ¿ã®è©³çްã瀺ããã©ã¡ãŒã¿ã¯é鿝æãã«äŒŒãŠãããšããäºå®ïŒåãå®å
ãä»ã®ååã®æ¹ã楜ããïŒã«ããããããããã®æ¹æ³ã§ã¯éè¡ã«ãŒããšäœæã«é¢ããæ
å ±ãå¿
èŠã§ãã
çŽæ¥æ¯æãã®äž»ãªãã©ã¡ãŒã¿ãŒïŒMETHOD
æããã«ããã®ãã©ã¡ãŒã¿ãŒã§DoDirectPaymentãæå®ããå¿
èŠããããŸãã
IPADDRESS
ãã®ãã©ã¡ãŒã¿ãŒã§ã¯ã賌å
¥è
ã®IPã¢ãã¬ã¹ãæå®ããå¿
èŠããããŸãã PHPã䜿çšãããšã $_SERVER['REMOTE_ADDR']
ã䜿çšããŠç°¡åã«ååŸã§ããŸããããµãŒããŒäžã§PHPã仲ä»è
ãä»ããŠå€éšãšéä¿¡ããå ŽåïŒããšãã°ãnginxã䜿çšããå ŽåïŒã ããå°ãäœæ¥ãå¿
èŠã§ãã
PAYMENTACTION
ãã®ãã©ã¡ãŒã¿ãŒã¯ãç®çã®ã¢ã¯ã·ã§ã³ã決å®ããŸãã æ°ååã«èšãããããã«ããã®äžã§Sale
ãæå®ããå¿
èŠããããŸãã
éè¡ã«ãŒãã®è©³çްïŒCREDITCARDTYPE
éè¡ã«ãŒãã®çš®é¡ïŒäŸïŒVisaãMasterCardãªã©ïŒ;
ACCT
éè¡ã«ãŒãçªå·ïŒãããã®çŽ æŽãããç¥èªã奜ãã§ããïŒïŒ;
EXPDATE
MMYYYY圢åŒã®ã«ãŒãã®æå¹æéïŒæ2æ¡ã幎4æ¡ïŒ;
CVV2
3ã4æ¡ã®ã³ãŒãã¯ã»ãã¥ãªãã£ã³ãŒããšãåŒã°ããŸãã ã«ãŒãã®è£é¢ã«ç€ºãããŠããŸãã
賌å
¥è
ã®è©³çްïŒFIRSTNAME, LASTNAME
ãã€ã€ãŒã®ååãšå§ïŒå¥ã
ã®ãã£ãŒã«ãïŒã ãªãã·ã§ã³ã§ãEMAILãã©ã¡ãŒã¿ãŒã§ãŠãŒã¶ãŒã®ã¡ãŒã«ã転éããããšãã§ããŸãã
CITY, STATE, COUNTRYCODE, ZIP
éœåžãå·ã 2æ¡ã®åœã³ãŒã ãéµäŸ¿çªå·ãããããã¹ãŠã®ãã£ãŒã«ãã¯å¿
é ã§ãã
STREET, STREET2
ã¢ãã¬ã¹ã®2è¡ã æåã®ãã®ã®ã¿ãå¿
èŠã§ãã
ã¢ãã¬ã¹ã¯
ãã¢ãã¬ã¹æ€èšŒã·ã¹ãã ïŒAVSïŒã«ãã£ãŠåŠç
ãããŸã ã äœæãééã£ãŠããããã«ååŒãæåŠãããå Žåãç¹å®ã®ãšã©ãŒãè¿ãããŸãã
æ¯æãã®è©³çްãæå®ãããã©ã¡ãŒã¿ãŒã¯ããšã¯ã¹ãã¬ã¹æ¯æãã®ãã©ã¡ãŒã¿ãŒãšäŒŒãŠããŸãããååãå€å°ç°ãªããŸãïŒ
AMT
ã
ITEMAMT
ã
CURRENCYCODE
ã
SHIPPINGAMT
ã
TAXAMT
ããã³
DESC
ã䜿çšããå¿
èŠããããŸãïŒã 詳现ã«ã€ããŠã¯ãããã¥ã¡ã³ããåç
§ããŠãã ããã
åæ§ã«ã次ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠè£œåæ
å ±ãå
¥åããå¿
èŠããããŸãïŒ
L_NAMEm
ã
L_DESCm
ã
L_AMTm
ããã³
L_QTYm
ã 倿°mã¯ãåã
ã®è£œåã®ãã©ã¡ãŒã¿ãŒãåºåãããã«äœ¿çšãããŸãïŒé åºå
ã®çªå·ä»ãã¢ã€ãã ã®å Žåã¯ã0ã1ãããã³ãã以äžã«çœ®ãæããŸãïŒã
ããå®å
šãªãªã¹ãã«ã€ããŠã¯ãããã¥ã¡ã³ããåç
§ããŠãã ããã

åã«æžãã颿°ã䜿çšããŠãªã¯ãšã¹ããéä¿¡ããããšã¯ããšã¯ã¹ãã¬ã¹æ¯æãã®å Žåãšéåžžã«äŒŒãŠããŸãã ãã¹ãŠã®ãã©ã¡ãŒã¿ãŒããŸã£ããåãæ¹æ³ã§
DoDirectPayment
ãŸãããã¡ãœãããšããŠ
DoDirectPayment
ãæå®ããŸãã
$requestParams = array( 'IPADDRESS' => $_SERVER['REMOTE_ADDR'], 'PAYMENTACTION' => 'Sale' ); $creditCardDetails = array( 'CREDITCARDTYPE' => 'Visa', 'ACCT' => '4929802607281663', 'EXPDATE' => '062012', 'CVV2' => '984' ); $payerDetails = array( 'FIRSTNAME' => 'John', 'LASTNAME' => 'Doe', 'COUNTRYCODE' => 'US', 'STATE' => 'NY', 'CITY' => 'New York', 'STREET' => '14 Argyle Rd.', 'ZIP' => '10010' ); $orderParams = array( 'AMT' => '500', 'ITEMAMT' => '496', 'SHIPPINGAMT' => '4', 'CURRENCYCODE' => 'GBP' ); $item = array( 'L_NAME0' => 'iPhone', 'L_DESC0' => 'White iPhone, 16GB', 'L_AMT0' => '496', 'L_QTY0' => '1' ); $paypal = new Paypal(); $response = $paypal -> request('DoDirectPayment', $requestParams + $creditCardDetails + $payerDetails + $orderParams + $item ); if( is_array($response) && $response['ACK'] == 'Success') { $transactionId = $response['TRANSACTIONID']; }

çæ³çãªäžçã«äœãã§ãããªãããã®éšåã¯ååšããŸããã å®éã«ã¯ãä»ã®èšäºã®ãã®éšåãŸãã¯åæ§ã®ã»ã¯ã·ã§ã³ãé »ç¹ã«åç
§ããå¿
èŠããããŸãã PayPalã¯ã倿°ã®ãšã©ãŒã®ããããã«å¯Ÿããæ¯æããæåŠããå Žåãããããããã®ä¿®æ£ã¯åœç€Ÿã®ç®¡çäžã«ã¯ãããŸããã
paypalApiRequest()
颿°ããã®å¿çãå«ã
$response
倿°ã«ã¯ã
Success
ã«å¯Ÿå¿ããªã
ACK
ãã©ã¡ãŒã¿ãŒã®å€ãå«ãŸããå ŽåããããŸãã
Success
æäœã¯æåããŸããã
SuccessWithWarning
æäœã¯æåããŸããããå®ç§ã§ã¯ãããŸããã§ããã APIã¯ãäœãä¿®æ£ããå¿
èŠããããã説æããã¡ãã»ãŒãžãè¿ããŸããã
Failure
æäœã¯æåããŸããã§ãã;å¿çã«ã¯ã倱æã説æãããšã©ãŒã³ãŒããå«ãŸããŠããŸãã
FailureWithWarning
æäœã¯æåããŸããã§ãããå¿çã«ã¯ã確èªããå¿
èŠããããšã©ãŒã³ãŒããšã¡ãã»ãŒãžãå«ãŸããŠããŸãã
2ã€ã®æåããã¹ããŒã¿ã¹ãš2ã€ã®å€±æããã¹ããŒã¿ã¹ãããããšãããããŸãã äžèšã®ã³ãŒãã¯ãã¹ãŠæåã¹ããŒã¿ã¹ã§ã®ã¿æ©èœããŸããã
SuccessWithWarning
ç°¡åã«çœ®ãæããããšãã§ããŸãããåé¡ã®å
容ãšèŠåã®å
容ã確èªããããšãå¿ããªãã§ãã ããã çŽæ¥æ¯æãã®æãäžè¬çãªãšã©ãŒã·ããªãªã¯ããªã¯ãšã¹ããæ£åžžã«åãå
¥ãããæ€èšŒãããããéè¡ãã«ãŒãããã®è³éã®åŒãåºããªã¯ãšã¹ããæåŠããããšã§ãã
PayPalã«ãã£ãŠè¿ããããšã©ãŒã¯ãå¿çã®4ã€ã®ãã©ã¡ãŒã¿ãŒã«å²ãŸããŠããŸãã
L_ERRORCODE0
PayPalãšã©ãŒã³ãŒããªã¹ãã䜿çšããŠè§£èªã§ããããžã¿ã«ãšã©ãŒã³ãŒãã
L_SHORTMESSAGE0
åé¡ã説æããçãã¡ãã»ãŒãžã
L_LONGMESSAGE0
åé¡ã説æãã詳现ãªã¡ãã»ãŒãžã
L_SEVERITYCODE0
é£æåºŠã³ãŒãã ç§ã¯ããããªãå¿
èŠãªã®ãåãããŸãããããã«ã€ããŠã®ããã¥ã¡ã³ãã¯éãã§ãããŸãã倧äžå€«ããããå¿ããŸãããã
ãã©ã¡ãŒã¿ãŒã®æåŸã®å€æ°
0
ã¯ãçºçãããšã©ãŒã®ã·ãªã¢ã«çªå·ã§ãïŒè€æ°ã®ãšã©ãŒãããå Žåã倿°ã«ã¯1ã2ãªã©ããããŸãïŒã
æãäžè¬çãªãšã©ãŒã®çããªã¹ããæ¬¡ã«ç€ºããŸãã
10002
APIèªèšŒããŒã¿ã¯æ€èšŒã«åæ ŒããŸããã§ããã
81***
å¿
é ãã©ã¡ãŒã¿ãŒã®1ã€ãæ¬ èœããŠããŸãã
104**
ç¡å¹ãªå€ããã©ã¡ãŒã¿ãŒã®1ã€ã§æž¡ãããŸããã

äžéšã®PayPalãšã©ãŒã«ã¯ããŠãŒã¶ãŒã«è¡šç€ºããå¯èœæ§ãäœãå人æ
å ±ã説æã«å«ãŸããŠããå ŽåããããŸãã ãã®ãããããšãæçšã§ãã£ãŠãããšã©ãŒè¡šç€ºããªãã«ããããšããå§ãããŸãã
ã»ãšãã©ã®å Žåãæ¬¡ã®ããšãè¡ãããšããå§ãããŸãã
- ãŠãŒã¶ãŒã«è¡šç€ºã§ãããšã©ãŒã®ãã¯ã€ããªã¹ããäœæããŸãïŒããšãã°ãã¯ã¬ãžããã«ãŒãã®èª€ã£ãããŒã¿ïŒã
- ãšã©ãŒãè¿ããšãã«ããã¯ã€ããªã¹ããšç
§åããããã«ããŠãã ããã
- ãã®ãªã¹ãã«ãšã©ãŒããªãå ŽåããŠãŒã¶ãŒã¯äžè¬çãªãšã©ãŒã衚瀺ããå¿
èŠããããŸããããšãã°ããæ¯æãã®åŠçäžã«ãšã©ãŒãçºçããŸããã æ°ååŸ
ã€ãããã®åé¡ã解決ããããã«ç§éã«é£çµ¡ããŠãã ãããã

ãã®ãããã¯ã§ã¯ãæã人æ°ã®ãã2ã€ã®APIãšãšã©ãŒã®åŠçã«ã€ããŠèª¬æããŸããã ããã¯ããããã¯ãŒã¯äžã§æã人æ°ã®ããæ¯æãã·ã¹ãã ãéå§ã§ããããã«ååãªã¯ãã§ãã
PayPal APIã«ã¯ãããå€ãã®ã¡ãœãããšæ¹æ³ãè€æ°ã®ãããã¯ããããŸãã æãäžè¬çãª2ã€ã®æ¹æ³ã§äœæ¥ããæ¹æ³ãåŠç¿ãããšãæ®ãã®åŠç¿æ¹æ³ãã¯ããã«ç°¡åã«ãªããŸãã ãã®ã¬ã€ãããAPIã®äœ¿çšã®è¯ãåºçºç¹ãšãªãããšãé¡ã£ãŠããŸãã

å
ã®èšäºïŒ
PayPal APIå
¥é ãEran Galperinã2011幎9æ5æ¥ã
ãã®ç¿»èš³ãhabrasocietyã«æ¬åœã«åœ¹ç«ã€ããšãæ¬åœã«é¡ã£ãŠããŸãã ã€ãŸãã9æ24æ¥ã®äŒæ¥ã®åžæãä»ã§ã倱ããŸããã åŸ
ã£ãŠãèŠãŠã


ãã®ããã¹ãã¯ã
Creative Commons Attribution-NonCommercial-ShareAlike 3.0ã©ã€ã»ã³ã¹ã®äžã§ã©ã€ã»ã³ã¹ãããŠããŸãã
ãªãªãžãã«ã®ã©ã€ã»ã³ã¹ã®äœæãšä¿åã矩åä»ããŠããã®ããã¹ããéå¶å©ç®çã§ã³ããŒãç·šéã䜿çšã§ããŸãã