Submit Search
Upload
Paypal REST api ( Japanese version )
•
Download as PPTX, PDF
•
3 likes
•
3,822 views
Yoshi Sakai
Follow
Paypal payment using REST API for BluemoonXoops / XoopsEC and XOOPS Cube.
Read less
Read more
Business
Technology
Economy & Finance
Report
Share
Report
Share
1 of 29
Download now
Recommended
RESTful web services
RESTful web services
Tudor Constantin
Mojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
Mojolicious
Mojolicious
Marcos Rebelo
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
Anatoly Sharifulin
Mojolicious on Steroids
Mojolicious on Steroids
Tudor Constantin
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
Dirk Haun
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
vvaswani
Recommended
RESTful web services
RESTful web services
Tudor Constantin
Mojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
Mojolicious
Mojolicious
Marcos Rebelo
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
Anatoly Sharifulin
Mojolicious on Steroids
Mojolicious on Steroids
Tudor Constantin
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
Dirk Haun
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
vvaswani
Saferpay Checkout Page - PHP Sample (Hosting)
Saferpay Checkout Page - PHP Sample (Hosting)
webhostingguy
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
Cosimo Streppone
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
Vic Metcalfe
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Caldera Labs
Zend Server: Not just a PHP stack
Zend Server: Not just a PHP stack
Jeroen van Dijk
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
Vance Lucas
Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
琛琳 饶
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
Curso Symfony - Clase 4
Curso Symfony - Clase 4
Javier Eguiluz
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
Jacopo Romei
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
Caldera Labs
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
Backand Cohen
Perl5i
Perl5i
Marcos Rebelo
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
WP Engine UK
Dart and AngularDart
Dart and AngularDart
Loc Nguyen
Payments On Rails
Payments On Rails
E-xact Transactions
Apostrophe (improved Paris edition)
Apostrophe (improved Paris edition)
tompunk
Curso Symfony - Clase 2
Curso Symfony - Clase 2
Javier Eguiluz
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2
Jonathan LeBlanc
Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
Nordic APIs
More Related Content
What's hot
Saferpay Checkout Page - PHP Sample (Hosting)
Saferpay Checkout Page - PHP Sample (Hosting)
webhostingguy
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
Cosimo Streppone
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
Vic Metcalfe
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Caldera Labs
Zend Server: Not just a PHP stack
Zend Server: Not just a PHP stack
Jeroen van Dijk
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
Vance Lucas
Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
琛琳 饶
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
Curso Symfony - Clase 4
Curso Symfony - Clase 4
Javier Eguiluz
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
Jacopo Romei
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
Caldera Labs
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
Backand Cohen
Perl5i
Perl5i
Marcos Rebelo
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
WP Engine UK
Dart and AngularDart
Dart and AngularDart
Loc Nguyen
Payments On Rails
Payments On Rails
E-xact Transactions
Apostrophe (improved Paris edition)
Apostrophe (improved Paris edition)
tompunk
Curso Symfony - Clase 2
Curso Symfony - Clase 2
Javier Eguiluz
What's hot
(20)
Saferpay Checkout Page - PHP Sample (Hosting)
Saferpay Checkout Page - PHP Sample (Hosting)
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Zend Server: Not just a PHP stack
Zend Server: Not just a PHP stack
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
Curso Symfony - Clase 4
Curso Symfony - Clase 4
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
PerlでWeb API入門
PerlでWeb API入門
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
Perl5i
Perl5i
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
Dart and AngularDart
Dart and AngularDart
Payments On Rails
Payments On Rails
Apostrophe (improved Paris edition)
Apostrophe (improved Paris edition)
Curso Symfony - Clase 2
Curso Symfony - Clase 2
Similar to Paypal REST api ( Japanese version )
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2
Jonathan LeBlanc
Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
Nordic APIs
PayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving Business
Aduci
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Francois Marier
Modern Web Development with Perl
Modern Web Development with Perl
Dave Cross
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment Platforms
Jonathan LeBlanc
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5
Jonathan LeBlanc
Silex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
Silex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
An introduction to Laravel Passport
An introduction to Laravel Passport
Michael Peacock
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
rajkamaltibacademy
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Francois Marier
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
Masahiro Nagano
WordPress REST API hacking
WordPress REST API hacking
Jeroen van Dijk
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
Appweb Coders
Mojolicious
Mojolicious
Lenz Gschwendtner
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada
Dealing with Legacy PHP Applications
Dealing with Legacy PHP Applications
Clinton Dreisbach
Passwords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answer
Francois Marier
Similar to Paypal REST api ( Japanese version )
(20)
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2
Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
PayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving Business
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Modern Web Development with Perl
Modern Web Development with Perl
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment Platforms
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5
Silex Cheat Sheet
Silex Cheat Sheet
Silex Cheat Sheet
Silex Cheat Sheet
An introduction to Laravel Passport
An introduction to Laravel Passport
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
WordPress REST API hacking
WordPress REST API hacking
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
Mojolicious
Mojolicious
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Blog Hacks 2011
Blog Hacks 2011
Dealing with Legacy PHP Applications
Dealing with Legacy PHP Applications
Passwords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answer
More from Yoshi Sakai
いきなりAi tensor flow gpuによる画像分類と生成
いきなりAi tensor flow gpuによる画像分類と生成
Yoshi Sakai
Access で Excel ファイルの操作を行う為のライブラリ設定
Access で Excel ファイルの操作を行う為のライブラリ設定
Yoshi Sakai
Rhodes mobile Framework
Rhodes mobile Framework
Yoshi Sakai
Rhodes mobile Framework (Japanese)
Rhodes mobile Framework (Japanese)
Yoshi Sakai
Xoopsec
Xoopsec
Yoshi Sakai
Osc2009tokyofall xoops groupware
Osc2009tokyofall xoops groupware
Yoshi Sakai
XOOPS EC Distribution
XOOPS EC Distribution
Yoshi Sakai
XOOPS and Twitter Bootstrap
XOOPS and Twitter Bootstrap
Yoshi Sakai
XOOPS EC on C4SA Paas deployment
XOOPS EC on C4SA Paas deployment
Yoshi Sakai
Xcc2012
Xcc2012
Yoshi Sakai
Xoops x
Xoops x
Yoshi Sakai
Oss活動指針
Oss活動指針
Yoshi Sakai
Weeklycms20120218
Weeklycms20120218
Yoshi Sakai
XOOPS Cube 2.2 Pack 2011
XOOPS Cube 2.2 Pack 2011
Yoshi Sakai
XOOPS Securilty flow
XOOPS Securilty flow
Yoshi Sakai
Seminer20110119
Seminer20110119
Yoshi Sakai
Satlab20101127
Satlab20101127
Yoshi Sakai
Xoops Cube Saturday Lab. 2010/09/25
Xoops Cube Saturday Lab. 2010/09/25
Yoshi Sakai
More from Yoshi Sakai
(18)
いきなりAi tensor flow gpuによる画像分類と生成
いきなりAi tensor flow gpuによる画像分類と生成
Access で Excel ファイルの操作を行う為のライブラリ設定
Access で Excel ファイルの操作を行う為のライブラリ設定
Rhodes mobile Framework
Rhodes mobile Framework
Rhodes mobile Framework (Japanese)
Rhodes mobile Framework (Japanese)
Xoopsec
Xoopsec
Osc2009tokyofall xoops groupware
Osc2009tokyofall xoops groupware
XOOPS EC Distribution
XOOPS EC Distribution
XOOPS and Twitter Bootstrap
XOOPS and Twitter Bootstrap
XOOPS EC on C4SA Paas deployment
XOOPS EC on C4SA Paas deployment
Xcc2012
Xcc2012
Xoops x
Xoops x
Oss活動指針
Oss活動指針
Weeklycms20120218
Weeklycms20120218
XOOPS Cube 2.2 Pack 2011
XOOPS Cube 2.2 Pack 2011
XOOPS Securilty flow
XOOPS Securilty flow
Seminer20110119
Seminer20110119
Satlab20101127
Satlab20101127
Xoops Cube Saturday Lab. 2010/09/25
Xoops Cube Saturday Lab. 2010/09/25
Recently uploaded
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Tina Ji
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Dave Litwiller
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Apsara Of India
GD Birla and his contribution in management
GD Birla and his contribution in management
chhavia330
M.C Lodges -- Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
Aaiza Hassan
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
lizamodels9
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
Recruitment Process Outsourcing Association
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
Data Analytics Company - 47Billion Inc.
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
lizamodels9
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
Orient Homes
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
anilsa9823
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
KeppelCorporation
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
Paul Menig
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
soniya singh
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
Newman George Leech
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
divyansh0kumar0
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptx
AbhayThakur200703
VIP Call Girls Pune Kirti 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Kirti 8617697112 Independent Escort Service Pune
Call girls in Ahmedabad High profile
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
Suhani Kapoor
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
discovermytutordmt
Recently uploaded
(20)
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
GD Birla and his contribution in management
GD Birla and his contribution in management
M.C Lodges -- Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Mehrauli Delhi 💯Call Us 🔝8264348440🔝
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptx
VIP Call Girls Pune Kirti 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Kirti 8617697112 Independent Escort Service Pune
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
Paypal REST api ( Japanese version )
1.
PayPal REST API Yoshi.sakai@gmail.com @bluemooninc
2.
Live Demo Site https://www.xoopsec.com
3.
GitHub / bluemooninc •
XoopsEC Distoribution(GPL V3) – https://github.com/bluemooninc/xoopsec • BmPayPal – REST Api Modulehttps://github.com/bluemooninc/bmp aypal
4.
REST API Document •
https://developer.paypal.com/webapps/develope r/docs/api/#create-a-payment
5.
API利用に必要なパラメータ • EndPoint • Client
ID • Secret
6.
Developer登録 • https://developer.paypal.com/
7.
Test Account 作成 •
Country=USでPersonalとBusinessを作る
8.
REST API apps作成
9.
REST API Credentials
確認
10.
注意点 • Cookie,Session変数で制御しているので、実PayPalアカウントでログ インしたブラウザでは、Sandboxアカウントは利用出来ない。 PayPal 実アカウント ログイン
Browser Sandboxアカウントの作成と 実行結果の確認 別のBrowserで ショッピングと PayPalアカウント支払いのテス トを行う Web Service App
11.
テストアカウントサイトへログ イン • https://www.sandbox.paypal.com/ >ブラウザを変更する もしくはCookie clear
12.
テスト口座の確認
13.
Make your first
call • https://developer.paypal.com/webapps/developer/doc s/integration/direct/make-your-first-call/
14.
PayPalアカウント決済($)
15.
円ドル換算 private function getRatefromGoogle($to,$from){ $exchangeEndpoint
= sprintf("http://rate- exchange.appspot.com/currency?from=%s&to=%s",$from,$to); $json = file_get_contents($exchangeEndpoint); $data = json_decode($json, TRUE); if($data){ return $data['rate']; } } private function exchangeToUSD($amount,$currency="USD"){ if ($currency!="USD"){ $this->rate = $this->getRatefromGoogle($currency,"USD"); $amount_usd = round($amount / $this->rate, 2); }else{ $amount_usd = $amount; } return $amount_usd; }
16.
API渡すパラメータの準備 • https://www.xoopsec.com/modules/bmpaypal/b mpaypal/index?order_id=38&amount=82.450000 ¤cy=USD
17.
PayPal API準備完了 • REST
APIでパラメータをセットしてPayPalアカウント決済の準備をす る • https://www.xoopsec.com/modules/bmpaypal/AcceptPayment/index/25
18.
コントローラ部(AcceptPayment) public function __construct(){ parent::__construct(); $this->mModel
= Model_Payment::forge(); $this->Model_PayPal = Model_PayPal::forge(); $this->return_url = XOOPS_URL . "/modules/bmpaypal/ExecutePayment/return/"; $this->cencel_url = XOOPS_URL . "/modules/bmpaypal/ExecutePayment/cancel/"; } public function action_index(){ $payment_id = $this->mParams[0]; $this->template = 'AcceptPayment.html'; $object = $this->mModel->get($payment_id); $uid = $this->root->mContext->mXoopsUser->get('uid'); $this->Model_PayPal->set($object); $json_resp = $this->Model_PayPal->AcceptPayment( $this->return_url, $this->cencel_url ); // call REST api $this->mModel->SavePaymentInfo( $payment_id, $json_resp['id'], $json_resp['state'] ); $this->links = $this->Model_PayPal->getLinks(); if ($json_resp){ $_SESSION['bmpaypal'] = $json_resp; } }
19.
モデルその2(get_access_token) function get_access_token($url, $postdata)
{ $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_USERPWD, $this->clientId . ":" . $this->clientSecret); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($curl, CURLOPT_VERBOSE, TRUE); $response = curl_exec( $curl ); if (empty($response)) { // some kind of an error happened die(curl_error($curl)); curl_close($curl); // close cURL handler } else { $info = curl_getinfo($curl); $this->message[] = "Time took: " . $info['total_time']*1000 . "ms<br />"; curl_close($curl); // close cURL handler if($info['http_code'] != 200 && $info['http_code'] != 201 ) { $this->message[] = "Received error: " . $info['http_code']. "<br />"; $this->message[] = "Raw response:".$response."<br />"; return NULL; } } // Convert the result from JSON format to a PHP array $jsonResponse = json_decode( $response ); return $jsonResponse->access_token; }
20.
モデル部(AcceptPayment)public function &AcceptPayment($returnUrl,$cancelUrl) { //
Get token for Authorization: Bearer $this->token = $this->get_access_token($this->host.$this->token_endpoint,$this->token_postArgs); if(is_null($this->token)) echoMessage($this->message); $url = $this->host.'/v1/payments/payment'; $payment = array( 'intent' => 'sale', 'redirect_urls' => array( 'return_url' => $returnUrl, 'cancel_url' => $cancelUrl ), 'payer' => array( 'payment_method' => 'paypal' ), 'transactions' => array (array( 'amount' => array( 'total' => $this->object->getVar('amount'), 'currency' => $this->object->getVar('currency') ), 'description' => 'Pass payment information to create a payment' )) ); $json = json_encode($payment); $this->json_resp = $this->make_post_call($url, $json); return $this->json_resp; }
21.
PayPal決済リンク取得 public function getLinks(){ if($this->json_resp)
{ return $this->json_resp['links']; }else{ return NULL; } }
22.
PayPalサイトへ
23.
ログインして支払う
24.
Return URL に戻る
25.
管理画面の記録 • 鍵をクリックすると、受け取りが実行される • https://www.xoopsec.com/modules/bmpaypal/admin/index.php?action=payment Execute&id=25
26.
27.
受け取り実行 public function executePayment($paypal_id,$payer_id){ //
Get token for Authorization: Bearer $this->token = $this->get_access_token($this->host.$this- >token_endpoint,$this->token_postArgs); if ( is_null($this->token) ) echoMessage($this->message); $url = $this->host.'/v1/payments/payment/'.$paypal_id."/execute/"; $payment = array( 'payer_id' => $payer_id ); $json = json_encode($payment); $this->json_resp = $this->make_post_call($url, $json); return $this->json_resp; }
28.
モデルその2 function make_post_call($url, $postdata)
{ $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer '.$this->token, 'Accept: application/json', 'Content-Type: application/json' )); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); #curl_setopt($curl, CURLOPT_VERBOSE, TRUE); $response = curl_exec( $curl ); if (empty($response)) { // some kind of an error happened die(curl_error($curl)); curl_close($curl); // close cURL handler } else { $info = curl_getinfo($curl); echo "Time took: " . $info['total_time']*1000 . "ms<br />"; curl_close($curl); // close cURL handler if($info['http_code'] != 200 && $info['http_code'] != 201 ) { echo "Received error: " . $info['http_code']. "<br />"; echo "Raw response:".$response."<br />"; die(); } }
29.
受け取り完了
Download now