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
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Ayesha Khan
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
dollysharma2066
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Perera
ictsugar
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
dollysharma2066
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
DallasHaselhorst
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
ashishs7044
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
HajeJanKamps
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
Seta Wicaksana
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory: summary 2024
Matteo Carbone
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
Khaled Al Awadi
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample Report
Mintel Group
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
ashishs7044
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
ictsugar
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
Ariel592675
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
ictsugar
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
Anamaria Contreras
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
ashishs7044
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
ssuserf63bd7
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
ictsugar
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
Kirill Klimov
Recently uploaded
(20)
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Perera
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
IoT Insurance Observatory: summary 2024
IoT Insurance Observatory: summary 2024
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
India Consumer 2024 Redacted Sample Report
India Consumer 2024 Redacted Sample Report
8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
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