Changeset 2772073
- Timestamp:
- 08/18/2022 12:13:11 PM (4 years ago)
- Location:
- rave-woocommerce-payment-gateway
- Files:
-
- 208 added
- 4 edited
-
tags/2.3.0/LICENSE (added)
-
tags/2.3.0/README.md (added)
-
tags/2.3.0/assets/img (added)
-
tags/2.3.0/assets/img/rave.png (added)
-
tags/2.3.0/assets/img/rave.svg (added)
-
tags/2.3.0/assets/img/screen1.PNG (added)
-
tags/2.3.0/assets/img/screen2.PNG (added)
-
tags/2.3.0/assets/img/screen3.PNG (added)
-
tags/2.3.0/flutterwave-rave-php-sdk (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/README.md (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/ajax-loader.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/composer.json (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/classes (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/classes/Flutterwave.Rave.EventHandlerInterface.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/classes/Flutterwave.Rave.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/bootstrap-responsive.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/bootstrap-responsive.min.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/bootstrap.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/bootstrap.min.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/jquery.iviewer.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/prettify.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/css/template.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/deprecated.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/errors.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/graph_class.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/apple-touch-icon-114x114.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/apple-touch-icon-72x72.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/apple-touch-icon.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/favicon.ico (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/glyphicons-halflings-white.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/glyphicons-halflings.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/arrow_down.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/arrow_right.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/class.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/constant.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/favicon.ico (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/file-php.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/file.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/folder.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/function.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/icon-folder-open-big.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/icon-th-big.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/icon_template.svg (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/interface.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/method.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/ok.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/property.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/search.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/variable.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/view_source.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/visibility_private.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/visibility_protected.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/icons/visibility_public.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/grab.cur (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/hand.cur (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.rotate_left.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.rotate_right.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_fit.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_fit2.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_in.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_in2.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_out.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_out2.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_zero.png (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/iviewer/iviewer.zoom_zero2.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/img/loader.gif (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/index.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/SVGPan.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/bootstrap.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/bootstrap.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/MIT-LICENSE.txt (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/README.txt (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/changes.txt (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/copyright.txt (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/excanvas.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/gpl-2.0.txt (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/jquery.jqplot.min.css (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/jquery.jqplot.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.BezierCurveRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.barRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.blockRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.bubbleRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.canvasOverlay.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.canvasTextRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.ciParser.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.cursor.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.donutRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.dragable.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.funnelRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.highlighter.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.json2.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.logAxisRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.mekkoRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.meterGaugeRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.mobile.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.ohlcRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.pieRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.pointLabels.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.pyramidGridRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.pyramidRenderer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jqplot/plugins/jqplot.trendline.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery-1.4.2.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery-1.7.1.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery-ui-1.8.2.custom.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.cookie.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.iviewer.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.iviewer.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.mousewheel.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.panzoom.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.splitter.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.tools.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.treeview.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/jquery.xml2json.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/menu.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-apollo.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-clj.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-css.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-go.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-hs.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-lisp.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-lua.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-ml.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-n.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-proto.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-scala.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-sql.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-tex.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-vb.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-vhdl.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-wiki.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-xq.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/lang-yaml.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/prettify/prettify.min.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/sidebar.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/js/template.js (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/markers.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/namespaces (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/namespaces/Flutterwave.Rave.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/namespaces/Flutterwave.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/namespaces/default.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/packages (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/packages/Default.html (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-2e (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-2e/phpdoc-cache-settings.dat (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-48 (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-48/phpdoc-cache-file_62a3242662a071158a4e86b7224af888.dat (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-eb (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/docs/phpdoc-cache-eb/phpdoc-cache-file_c4042193263f11f57da814f4c0030189.dat (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/lib (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/lib/rave.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/lib/raveEventHandlerInterface.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/processPayment.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/autoload.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/ClassLoader.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/LICENSE (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/autoload_classmap.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/autoload_namespaces.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/autoload_psr4.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/autoload_real.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/autoload_static.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/composer/installed.json (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/LICENSE (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/README.md (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/composer.json (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/phpunit.xml (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Exception.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Method.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Request (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Request.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Request/Body.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/src/Unirest/Response.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/Unirest (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/Unirest/BodyTest.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/Unirest/RequestTest.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/Unirest/ResponseTest.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/bootstrap.php (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/fixtures (added)
-
tags/2.3.0/flutterwave-rave-php-sdk/vendor/mashape/unirest-php/tests/fixtures/upload.txt (added)
-
tags/2.3.0/includes (added)
-
tags/2.3.0/includes/class.flw_wc_payment_gateway.php (added)
-
tags/2.3.0/includes/class.flw_wc_subscription_payment.php (added)
-
tags/2.3.0/includes/eventHandler.php (added)
-
tags/2.3.0/readme.txt (added)
-
tags/2.3.0/woocommerce-rave.php (added)
-
trunk/assets/js/flw.js (modified) (2 diffs)
-
trunk/includes/class.flw_wc_payment_gateway.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-rave.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
rave-woocommerce-payment-gateway/trunk/assets/js/flw.js
r2694453 r2772073 64 64 onclose: function () {}, 65 65 callback: function (response) { 66 var tr = 67 response.data.data?.txRef || response.data.transactionobject?.txRef; 66 68 if ( 67 69 response.tx.chargeResponseCode == "00" || … … 69 71 ) { 70 72 // popup.close(); 71 redirectPost(cbUrl + "?txref=" + response.data.data.txRef, response.tx);73 redirectPost(cbUrl + "?txref=" + tr, response.tx); 72 74 } else { 73 75 alert(response.respmsg); -
rave-woocommerce-payment-gateway/trunk/includes/class.flw_wc_payment_gateway.php
r2754362 r2772073 1 1 <?php 2 2 3 if( ! defined( 'ABSPATH' ) ) { exit; } 4 5 define("BASEPATH", 1); 6 require_once( FLW_WC_DIR_PATH . 'flutterwave-rave-php-sdk/lib/rave.php' ); 7 require_once( FLW_WC_DIR_PATH . 'includes/eventHandler.php' ); 8 9 use Flutterwave\Rave; 10 11 /** 12 * Main Rave Gateway Class 13 */ 14 class FLW_WC_Payment_Gateway extends WC_Payment_Gateway { 3 if (!defined('ABSPATH')) { 4 exit; 5 } 6 7 define("BASEPATH", 1); 8 require_once(FLW_WC_DIR_PATH . 'flutterwave-rave-php-sdk/lib/rave.php'); 9 require_once(FLW_WC_DIR_PATH . 'includes/eventHandler.php'); 10 11 use Flutterwave\Rave; 12 13 /** 14 * Main Rave Gateway Class 15 */ 16 class FLW_WC_Payment_Gateway extends WC_Payment_Gateway 17 { 18 19 /** 20 * Constructor 21 * 22 * @return void 23 */ 24 public function __construct() 25 { 26 $this->base_url = 'https://api.ravepay.co'; 27 $this->id = 'rave'; 28 $this->icon = plugins_url('assets/img/rave.png', FLW_WC_PLUGIN_FILE); 29 $this->has_fields = false; 30 $this->method_title = __('Rave', 'flw-payments'); 31 $this->method_description = __('Rave allows you to accept payment from cards and bank accounts in multiple currencies. You can also accept payment offline via USSD and POS.', 'flw-payments'); 32 $this->supports = array( 33 'products', 34 ); 35 36 $this->init_form_fields(); 37 $this->init_settings(); 38 39 $this->title = $this->get_option('title'); 40 $this->description = $this->get_option('description'); 41 $this->enabled = $this->get_option('enabled'); 42 $this->test_public_key = $this->get_option('test_public_key'); 43 $this->test_secret_key = $this->get_option('test_secret_key'); 44 $this->live_public_key = $this->get_option('live_public_key'); 45 $this->live_secret_key = $this->get_option('live_secret_key'); 46 $this->auto_complete_order = get_option('autocomplete_order'); 47 $this->go_live = $this->get_option('go_live'); 48 $this->payment_options = $this->get_option('payment_options'); 49 $this->payment_style = $this->get_option('payment_style'); 50 $this->barter = $this->get_option('barter'); 51 $this->logging_option = $this->get_option('logging_option'); 52 $this->country = ""; 53 // $this->modal_logo = $this->get_option( 'modal_logo' ); 54 55 // enable saved cards 56 // $this->saved_cards = $this->get_option( 'saved_cards' ) === 'yes' ? true : false; 57 58 // declare support for Woocommerce subscription 59 $this->supports = array( 60 'products', 61 'tokenization', 62 'subscriptions', 63 'subscription_cancellation', 64 'subscription_suspension', 65 'subscription_reactivation', 66 'subscription_amount_changes', 67 'subscription_date_changes', 68 'subscription_payment_method_change', 69 'subscription_payment_method_change_customer', 70 'subscription_payment_method_change_admin', 71 'multiple_subscriptions', 72 ); 73 74 add_action('admin_notices', array($this, 'admin_notices')); 75 add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page')); 76 add_action('woocommerce_api_flw_wc_payment_gateway', array($this, 'flw_verify_payment')); 77 78 // Webhook listener/API hook 79 add_action('woocommerce_api_flw_wc_payment_webhook', array($this, 'flw_rave_webhooks')); 80 81 if (is_admin()) { 82 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); 83 } 84 85 $this->public_key = $this->test_public_key; 86 $this->secret_key = $this->test_secret_key; 87 88 89 90 91 if ('yes' === $this->go_live) { 92 // $this->base_url = 'https://api.ravepay.co'; 93 $this->public_key = $this->live_public_key; 94 $this->secret_key = $this->live_secret_key; 95 96 } 97 98 add_action('wp_enqueue_scripts', array($this, 'load_scripts')); 99 100 } 101 102 /** 103 * Initial gateway settings form fields 104 * 105 * @return void 106 */ 107 public function init_form_fields() 108 { 109 110 $this->form_fields = array( 111 112 'enabled' => array( 113 'title' => __('Enable/Disable', 'flw-payments'), 114 'label' => __('Enable Rave Payment Gateway', 'flw-payments'), 115 'type' => 'checkbox', 116 'description' => __('Enable Rave Payment Gateway as a payment option on the checkout page', 'flw-payments'), 117 'default' => 'no', 118 'desc_tip' => true 119 ), 120 'go_live' => array( 121 'title' => __('Mode', 'flw-payments'), 122 'label' => __('Live mode', 'flw-payments'), 123 'type' => 'checkbox', 124 'description' => __('Check this box if you\'re using your live keys.', 'flw-payments'), 125 'default' => 'no', 126 'desc_tip' => true 127 ), 128 'logging_option' => array( 129 'title' => __('Disable Logging', 'flw-payments'), 130 'label' => __('Disable Logging', 'flw-payments'), 131 'type' => 'checkbox', 132 'description' => __('Check this box if you\'re disabling logging.', 'flw-payments'), 133 'default' => 'no', 134 'desc_tip' => true 135 ), 136 'barter' => array( 137 'title' => __('Disable Barter', 'flw-payments'), 138 'label' => __('Disable Barter', 'flw-payments'), 139 'type' => 'checkbox', 140 'description' => __('Check the box if you want to disable barter.', 'flw-payments'), 141 'default' => 'no', 142 'desc_tip' => true 143 ), 144 'webhook' => array( 145 'title' => __('Webhook Instruction', 'flw-payments'), 146 'type' => 'hidden', 147 'description' => __('Please copy this webhook URL and paste on the webhook section on your dashboard <strong style="color: red"><pre><code>' . WC()->api_request_url('Flw_WC_Payment_Webhook') . '</code></pre></strong> (<a href="https://rave.flutterwave.com/dashboard/settings/webhooks" target="_blank">Rave Account</a>)', 'flw-payments'), 148 ), 149 'secret_hash' => array( 150 'title' => __('Enter Secret Hash', 'flw-payments'), 151 'type' => 'text', 152 'description' => __('Ensure that <b>SECRET HASH</b> is the same with the one on your Rave dashboard', 'flw-payments'), 153 'default' => 'Rave-Secret-Hash' 154 ), 155 'title' => array( 156 'title' => __('Payment method title', 'flw-payments'), 157 'type' => 'text', 158 'description' => __('Optional', 'flw-payments'), 159 'default' => 'Rave' 160 ), 161 'description' => array( 162 'title' => __('Payment method description', 'flw-payments'), 163 'type' => 'text', 164 'description' => __('Optional', 'flw-payments'), 165 'default' => 'Powered by Flutterwave: Accepts Mastercard, Visa, Verve, Discover, AMEX, Diners Club and Union Pay.' 166 ), 167 'test_public_key' => array( 168 'title' => __('Rave Test Public Key', 'flw-payments'), 169 'type' => 'text', 170 // 'description' => __( 'Required! Enter your Rave test public key here', 'flw-payments' ), 171 'default' => '' 172 ), 173 'test_secret_key' => array( 174 'title' => __('Rave Test Secret Key', 'flw-payments'), 175 'type' => 'text', 176 // 'description' => __( 'Required! Enter your Rave test secret key here', 'flw-payments' ), 177 'default' => '' 178 ), 179 'live_public_key' => array( 180 'title' => __('Rave Live Public Key', 'flw-payments'), 181 'type' => 'text', 182 // 'description' => __( 'Required! Enter your Rave live public key here', 'flw-payments' ), 183 'default' => '' 184 ), 185 'live_secret_key' => array( 186 'title' => __('Rave Live Secret Key', 'flw-payments'), 187 'type' => 'text', 188 // 'description' => __( 'Required! Enter your Rave live secret key here', 'flw-payments' ), 189 'default' => '' 190 ), 191 'payment_style' => array( 192 'title' => __('Payment Style on checkout', 'flw-payments'), 193 'type' => 'select', 194 'description' => __('Optional - Choice of payment style to use. Either inline or redirect. (Default: inline)', 'flw-payments'), 195 'options' => array( 196 'inline' => esc_html_x('Popup(Keep payment experience on the website)', 'payment_style', 'flw-payments'), 197 'redirect' => esc_html_x('Redirect', 'payment_style', 'flw-payments'), 198 ), 199 'default' => 'inline' 200 ), 201 'autocomplete_order' => array( 202 'title' => __('Autocomplete Order After Payment', 'flw-payments'), 203 'label' => __('Autocomplete Order', 'flw-payments'), 204 'type' => 'checkbox', 205 'class' => 'wc-flw-autocomplete-order', 206 'description' => __('If enabled, the order will be marked as complete after successful payment', 'flw-payments'), 207 'default' => 'no', 208 'desc_tip' => true, 209 ), 210 'payment_options' => array( 211 'title' => __('Payment Options', 'flw-payments'), 212 'type' => 'select', 213 'description' => __('Optional - Choice of payment method to use. Card, Account etc.', 'flw-payments'), 214 'options' => array( 215 '' => esc_html_x('Default', 'payment_options', 'flw-payments'), 216 'card' => esc_html_x('Card Only', 'payment_options', 'flw-payments'), 217 'account' => esc_html_x('Account Only', 'payment_options', 'flw-payments'), 218 'ussd' => esc_html_x('USSD Only', 'payment_options', 'flw-payments'), 219 'qr' => esc_html_x('QR Only', 'payment_options', 'flw-payments'), 220 'mpesa' => esc_html_x('Mpesa Only', 'payment_options', 'flw-payments'), 221 'mobilemoneyghana' => esc_html_x('Ghana MM Only', 'payment_options', 'flw-payments'), 222 'mobilemoneyrwanda' => esc_html_x('Rwanda MM Only', 'payment_options', 'flw-payments'), 223 'mobilemoneyzambia' => esc_html_x('Zambia MM Only', 'payment_options', 'flw-payments'), 224 'mobilemoneytanzania' => esc_html_x('Tanzania MM Only', 'payment_options', 'flw-payments'), 225 ), 226 'default' => '' 227 ), 228 229 ); 230 231 } 232 233 /** 234 * Process payment at checkout 235 * 236 * @return int $order_id 237 */ 238 public function process_payment($order_id) 239 { 240 241 $order = wc_get_order($order_id); 242 243 return array( 244 'result' => 'success', 245 'redirect' => $order->get_checkout_payment_url(true) 246 ); 247 248 } 249 250 251 /** 252 * Handles admin notices 253 * 254 * @return void 255 */ 256 public function admin_notices() 257 { 258 259 if ('no' == $this->enabled) { 260 return; 261 } 15 262 16 263 /** 17 * Constructor 18 * 19 * @return void 264 * Check if public key is provided 20 265 */ 21 public function __construct() { 22 23 24 25 $this->base_url = 'https://api.ravepay.co'; 26 $this->id = 'rave'; 27 $this->icon = plugins_url('assets/img/rave.png', FLW_WC_PLUGIN_FILE); 28 $this->has_fields = false; 29 $this->method_title = __( 'Rave', 'flw-payments' ); 30 $this->method_description = __( 'Rave allows you to accept payment from cards and bank accounts in multiple currencies. You can also accept payment offline via USSD and POS.', 'flw-payments' ); 31 $this->supports = array( 32 'products', 266 if (!$this->public_key || !$this->secret_key) { 267 $mode = ('yes' === $this->go_live) ? 'live' : 'test'; 268 echo '<div class="error"><p>'; 269 echo sprintf( 270 'Provide your ' . $mode . ' public key and secret key <a href="%s">here</a> to be able to use the Rave Payment Gateway plugin. If you don\'t have one, kindly sign up at <a href="https://rave.flutterwave.com" target="_blank>https://rave.flutterwave.com</a>, navigate to the settings page and click on API.', 271 admin_url('admin.php?page=wc-settings&tab=checkout§ion=rave') 33 272 ); 34 35 $this->init_form_fields(); 36 $this->init_settings(); 37 38 $this->title = $this->get_option( 'title' ); 39 $this->description = $this->get_option( 'description' ); 40 $this->enabled = $this->get_option( 'enabled' ); 41 $this->test_public_key = $this->get_option( 'test_public_key' ); 42 $this->test_secret_key = $this->get_option( 'test_secret_key' ); 43 $this->live_public_key = $this->get_option( 'live_public_key' ); 44 $this->live_secret_key = $this->get_option( 'live_secret_key' ); 45 $this->auto_complete_order = get_option('autocomplete_order'); 46 $this->go_live = $this->get_option( 'go_live' ); 47 $this->payment_options = $this->get_option( 'payment_options' ); 48 $this->payment_style = $this->get_option( 'payment_style' ); 49 $this->barter = $this->get_option( 'barter' ); 50 $this->logging_option = $this->get_option('logging_option'); 51 $this->country =""; 52 // $this->modal_logo = $this->get_option( 'modal_logo' ); 53 54 // enable saved cards 55 // $this->saved_cards = $this->get_option( 'saved_cards' ) === 'yes' ? true : false; 56 57 // declare support for Woocommerce subscription 58 $this->supports = array( 59 'products', 60 'tokenization', 61 'subscriptions', 62 'subscription_cancellation', 63 'subscription_suspension', 64 'subscription_reactivation', 65 'subscription_amount_changes', 66 'subscription_date_changes', 67 'subscription_payment_method_change', 68 'subscription_payment_method_change_customer', 69 'subscription_payment_method_change_admin', 70 'multiple_subscriptions', 71 ); 72 73 add_action( 'admin_notices', array( $this, 'admin_notices' ) ); 74 add_action( 'woocommerce_receipt_' . $this->id, array($this, 'receipt_page')); 75 add_action( 'woocommerce_api_flw_wc_payment_gateway', array($this, 'flw_verify_payment')); 76 77 // Webhook listener/API hook 78 add_action( 'woocommerce_api_flw_wc_payment_webhook', array($this, 'flw_rave_webhooks')); 79 80 if ( is_admin() ) { 81 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); 82 } 83 84 $this->public_key = $this->test_public_key; 85 $this->secret_key = $this->test_secret_key; 86 87 88 89 90 if ( 'yes' === $this->go_live ) { 91 // $this->base_url = 'https://api.ravepay.co'; 92 $this->public_key = $this->live_public_key; 93 $this->secret_key = $this->live_secret_key; 94 95 } 96 97 add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); 98 99 } 100 101 /** 102 * Initial gateway settings form fields 103 * 104 * @return void 105 */ 106 public function init_form_fields() { 107 108 $this->form_fields = array( 109 110 'enabled' => array( 111 'title' => __( 'Enable/Disable', 'flw-payments' ), 112 'label' => __( 'Enable Rave Payment Gateway', 'flw-payments' ), 113 'type' => 'checkbox', 114 'description' => __( 'Enable Rave Payment Gateway as a payment option on the checkout page', 'flw-payments' ), 115 'default' => 'no', 116 'desc_tip' => true 117 ), 118 'go_live' => array( 119 'title' => __( 'Mode', 'flw-payments' ), 120 'label' => __( 'Live mode', 'flw-payments' ), 121 'type' => 'checkbox', 122 'description' => __( 'Check this box if you\'re using your live keys.', 'flw-payments' ), 123 'default' => 'no', 124 'desc_tip' => true 125 ), 126 'logging_option' => array( 127 'title' => __( 'Disable Logging', 'flw-payments' ), 128 'label' => __( 'Disable Logging', 'flw-payments' ), 129 'type' => 'checkbox', 130 'description' => __( 'Check this box if you\'re disabling logging.', 'flw-payments' ), 131 'default' => 'no', 132 'desc_tip' => true 133 ), 134 'barter' => array( 135 'title' => __( 'Disable Barter', 'flw-payments' ), 136 'label' => __( 'Disable Barter', 'flw-payments' ), 137 'type' => 'checkbox', 138 'description' => __( 'Check the box if you want to disable barter.', 'flw-payments' ), 139 'default' => 'no', 140 'desc_tip' => true 141 ), 142 'webhook' => array( 143 'title' => __( 'Webhook Instruction', 'flw-payments' ), 144 'type' => 'hidden', 145 'description' => __( 'Please copy this webhook URL and paste on the webhook section on your dashboard <strong style="color: red"><pre><code>'.WC()->api_request_url('Flw_WC_Payment_Webhook').'</code></pre></strong> (<a href="https://rave.flutterwave.com/dashboard/settings/webhooks" target="_blank">Rave Account</a>)', 'flw-payments' ), 146 ), 147 'secret_hash' => array( 148 'title' => __( 'Enter Secret Hash', 'flw-payments' ), 149 'type' => 'text', 150 'description' => __( 'Ensure that <b>SECRET HASH</b> is the same with the one on your Rave dashboard', 'flw-payments' ), 151 'default' => 'Rave-Secret-Hash' 152 ), 153 'title' => array( 154 'title' => __( 'Payment method title', 'flw-payments' ), 155 'type' => 'text', 156 'description' => __( 'Optional', 'flw-payments' ), 157 'default' => 'Rave' 158 ), 159 'description' => array( 160 'title' => __( 'Payment method description', 'flw-payments' ), 161 'type' => 'text', 162 'description' => __( 'Optional', 'flw-payments' ), 163 'default' => 'Powered by Flutterwave: Accepts Mastercard, Visa, Verve, Discover, AMEX, Diners Club and Union Pay.' 164 ), 165 'test_public_key' => array( 166 'title' => __( 'Rave Test Public Key', 'flw-payments' ), 167 'type' => 'text', 168 // 'description' => __( 'Required! Enter your Rave test public key here', 'flw-payments' ), 169 'default' => '' 170 ), 171 'test_secret_key' => array( 172 'title' => __( 'Rave Test Secret Key', 'flw-payments' ), 173 'type' => 'text', 174 // 'description' => __( 'Required! Enter your Rave test secret key here', 'flw-payments' ), 175 'default' => '' 176 ), 177 'live_public_key' => array( 178 'title' => __( 'Rave Live Public Key', 'flw-payments' ), 179 'type' => 'text', 180 // 'description' => __( 'Required! Enter your Rave live public key here', 'flw-payments' ), 181 'default' => '' 182 ), 183 'live_secret_key' => array( 184 'title' => __( 'Rave Live Secret Key', 'flw-payments' ), 185 'type' => 'text', 186 // 'description' => __( 'Required! Enter your Rave live secret key here', 'flw-payments' ), 187 'default' => '' 188 ), 189 'payment_style' => array( 190 'title' => __( 'Payment Style on checkout', 'flw-payments' ), 191 'type' => 'select', 192 'description' => __( 'Optional - Choice of payment style to use. Either inline or redirect. (Default: inline)', 'flw-payments' ), 193 'options' => array( 194 'inline' => esc_html_x( 'Popup(Keep payment experience on the website)', 'payment_style', 'flw-payments' ), 195 'redirect' => esc_html_x( 'Redirect', 'payment_style', 'flw-payments' ), 196 ), 197 'default' => 'inline' 198 ), 199 'autocomplete_order' => array( 200 'title' => __( 'Autocomplete Order After Payment', 'flw-payments' ), 201 'label' => __( 'Autocomplete Order', 'flw-payments' ), 202 'type' => 'checkbox', 203 'class' => 'wc-flw-autocomplete-order', 204 'description' => __( 'If enabled, the order will be marked as complete after successful payment', 'flw-payments' ), 205 'default' => 'no', 206 'desc_tip' => true, 207 ), 208 'payment_options' => array( 209 'title' => __( 'Payment Options', 'flw-payments' ), 210 'type' => 'select', 211 'description' => __( 'Optional - Choice of payment method to use. Card, Account etc.', 'flw-payments' ), 212 'options' => array( 213 '' => esc_html_x( 'Default', 'payment_options', 'flw-payments' ), 214 'card' => esc_html_x( 'Card Only', 'payment_options', 'flw-payments' ), 215 'account' => esc_html_x( 'Account Only', 'payment_options', 'flw-payments' ), 216 'ussd' => esc_html_x( 'USSD Only', 'payment_options', 'flw-payments' ), 217 'qr' => esc_html_x( 'QR Only', 'payment_options', 'flw-payments' ), 218 'mpesa' => esc_html_x( 'Mpesa Only', 'payment_options', 'flw-payments' ), 219 'mobilemoneyghana' => esc_html_x( 'Ghana MM Only', 'payment_options', 'flw-payments' ), 220 'mobilemoneyrwanda' => esc_html_x( 'Rwanda MM Only', 'payment_options', 'flw-payments' ), 221 'mobilemoneyzambia' => esc_html_x( 'Zambia MM Only', 'payment_options', 'flw-payments' ), 222 'mobilemoneytanzania' => esc_html_x( 'Tanzania MM Only', 'payment_options', 'flw-payments' ), 223 ), 224 'default' => '' 225 ), 226 227 ); 228 229 } 230 231 /** 232 * Process payment at checkout 233 * 234 * @return int $order_id 235 */ 236 public function process_payment( $order_id ) { 237 238 $order = wc_get_order( $order_id ); 239 240 return array( 241 'result' => 'success', 242 'redirect' => $order->get_checkout_payment_url( true ) 243 ); 244 245 } 246 247 248 /** 249 * Handles admin notices 250 * 251 * @return void 252 */ 253 public function admin_notices() { 254 255 if ( 'no' == $this->enabled ) { 256 return; 257 } 258 259 /** 260 * Check if public key is provided 261 */ 262 if ( ! $this->public_key || ! $this->secret_key ) { 263 $mode = ('yes' === $this->go_live) ? 'live' : 'test'; 264 echo '<div class="error"><p>'; 265 echo sprintf( 266 'Provide your '.$mode .' public key and secret key <a href="%s">here</a> to be able to use the Rave Payment Gateway plugin. If you don\'t have one, kindly sign up at <a href="https://rave.flutterwave.com" target="_blank>https://rave.flutterwave.com</a>, navigate to the settings page and click on API.', 267 admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=rave' ) 268 ); 269 echo '</p></div>'; 270 return; 271 } 272 273 } 274 275 /** 276 * Checkout receipt page 277 * 278 * @return void 279 */ 280 public function receipt_page( $order ) { 281 282 $order = wc_get_order( $order ); 283 284 echo '<p>'.__( 'Thank you for your order, please click the <b>Make Payment</b> button below to make payment. You will be redirected to a secure page where you can enter you card details or bank account details. <b>Please, do not close your browser at any point in this process.</b>', 'flw-payments' ).'</p>'; 285 echo '<a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">'; 286 echo __( 'Cancel order & restore cart', 'flw-payments' ) . '</a> '; 287 echo '<button class="button alt wc-forward" id="flw-pay-now-button">Make Payment</button> '; 288 289 290 } 291 292 /** 293 * Loads (enqueue) static files (js & css) for the checkout page 294 * 295 * @return void 296 */ 297 public function load_scripts() { 298 299 if ( ! is_checkout_pay_page() ) return; 300 $p_key = $this->public_key; 301 $payment_options = $this->payment_options; 302 303 if( $this->payment_style == 'inline'){ 304 wp_enqueue_script( 'flwpbf_inline_js', $this->base_url . '/flwv3-pug/getpaidx/api/flwpbf-inline.js', array(), '1.0.0', true ); 305 } 306 307 wp_enqueue_script( 'flw_js', plugins_url( 'assets/js/flw.js', FLW_WC_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', true ); 308 309 if ( get_query_var( 'order-pay' ) ) { 310 311 $order_key = urldecode( $_REQUEST['key'] ); 312 $order_id = absint( get_query_var( 'order-pay' ) ); 313 $cb_url = WC()->api_request_url( 'FLW_WC_Payment_Gateway' ).'?rave_id='.$order_id; 314 315 if( $this->payment_style == 'inline'){ 316 wp_enqueue_script( 'flwpbf_inline_js', $this->base_url . '/flwv3-pug/getpaidx/api/flwpbf-inline.js', array(), '1.0.0', true ); 317 $cb_url = WC()->api_request_url('FLW_WC_Payment_Gateway'); 318 } 319 320 $order = wc_get_order( $order_id ); 321 322 $txnref = "WOOC_" . $order_id . '_' . time(); 323 $txnref = filter_var($txnref, FILTER_SANITIZE_STRING);//sanitizr=e this field 324 325 if (version_compare(WOOCOMMERCE_VERSION, '2.7.0', '>=')){ 326 $amount = $order->get_total(); 327 $email = $order->get_billing_email(); 328 $currency = $order->get_currency(); 329 $main_order_key = $order->get_order_key(); 330 }else{ 331 $args = array( 332 'name' => $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(), 333 'email' => $order->get_billing_email(), 334 'contact' => $order->get_billing_phone(), 335 ); 336 $amount = $order->get_total(); 337 $main_order_key = $order->get_order_key(); 338 $email = $order->get_billing_email(); 339 $currency = $order->get_currency(); 340 } 341 342 // $amount = $order->order_total; 343 // $email = $order->billing_email; 344 // $currency = $order->get_order_currency(); 345 346 //set the currency to route to their countries 347 switch ($currency) { 348 case 'KES': 349 $this->country = 'KE'; 350 break; 351 case 'GHS': 352 $this->country = 'GH'; 353 break; 354 case 'ZAR': 355 $this->country = 'ZA'; 356 break; 357 case 'TZS': 358 $this->country = 'TZ'; 359 break; 360 361 default: 362 $this->country = 'NG'; 363 break; 364 } 365 366 $country = $this->country; 367 $payment_style = $this->payment_style; 368 369 if ( $main_order_key == $order_key ) { 370 371 $payment_args = compact( 'amount', 'email', 'txnref', 'p_key', 'currency', 'country', 'payment_options','cb_url','payment_style'); 372 $payment_args['desc'] = filter_var($this->description, FILTER_SANITIZE_STRING); 373 $payment_args['title'] = filter_var($this->title, FILTER_SANITIZE_STRING); 374 // $payment_args['logo'] = filter_var($this->modal_logo, FILTER_SANITIZE_URL); 375 $payment_args['firstname'] = $order->get_billing_first_name(); 376 $payment_args['lastname'] = $order->get_billing_last_name(); 377 $payment_args['barter'] = $this->barter; 378 } 379 380 update_post_meta( $order_id, '_flw_payment_txn_ref', $txnref ); 381 382 } 383 384 wp_localize_script( 'flw_js', 'flw_payment_args', $payment_args ); 385 } 386 387 /** 388 * Verify payment made on the checkout page 389 * 390 * @return void 391 */ 392 public function flw_verify_payment() { 393 394 $publicKey = $this->public_key; 395 $secretKey = $this->secret_key; 396 $logging_option = $this->logging_option; 397 398 399 // if($this->go_live === 'yes'){ 400 // $env = 'live'; 401 // }else{ 402 // $env = 'staging'; 273 echo '</p></div>'; 274 return; 275 } 276 277 } 278 279 /** 280 * Checkout receipt page 281 * 282 * @return void 283 */ 284 public function receipt_page($order) 285 { 286 287 $order = wc_get_order($order); 288 289 echo '<p>' . __('Thank you for your order, please click the <b>Make Payment</b> button below to make payment. You will be redirected to a secure page where you can enter you card details or bank account details. <b>Please, do not close your browser at any point in this process.</b>', 'flw-payments') . '</p>'; 290 echo '<a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">'; 291 echo __('Cancel order & restore cart', 'flw-payments') . '</a> '; 292 echo '<button class="button alt wc-forward" id="flw-pay-now-button">Make Payment</button> '; 293 294 295 } 296 297 /** 298 * Loads (enqueue) static files (js & css) for the checkout page 299 * 300 * @return void 301 */ 302 public function load_scripts() 303 { 304 305 if (!is_checkout_pay_page()) 306 return; 307 $p_key = $this->public_key; 308 $payment_options = $this->payment_options; 309 310 if ($this->payment_style == 'inline') { 311 wp_enqueue_script('flwpbf_inline_js', $this->base_url . '/flwv3-pug/getpaidx/api/flwpbf-inline.js', array(), '1.0.0', true); 312 } 313 314 wp_enqueue_script('flw_js', plugins_url('assets/js/flw.js', FLW_WC_PLUGIN_FILE), array('jquery'), '1.0.0', true); 315 316 if (get_query_var('order-pay')) { 317 318 $order_key = urldecode($_REQUEST['key']); 319 $order_id = absint(get_query_var('order-pay')); 320 $cb_url = WC()->api_request_url('FLW_WC_Payment_Gateway') . '?rave_id=' . $order_id; 321 322 if ($this->payment_style == 'inline') { 323 wp_enqueue_script('flwpbf_inline_js', $this->base_url . '/flwv3-pug/getpaidx/api/flwpbf-inline.js', array(), '1.0.0', true); 324 $cb_url = WC()->api_request_url('FLW_WC_Payment_Gateway'); 325 } 326 327 $order = wc_get_order($order_id); 328 329 $txnref = "WOOC_" . $order_id . '_' . time(); 330 $txnref = filter_var($txnref, FILTER_SANITIZE_STRING); //sanitizr=e this field 331 332 if (version_compare(WOOCOMMERCE_VERSION, '2.7.0', '>=')) { 333 $amount = $order->get_total(); 334 $email = $order->get_billing_email(); 335 $currency = $order->get_currency(); 336 $main_order_key = $order->get_order_key(); 337 } 338 else { 339 $args = array( 340 'name' => $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(), 341 'email' => $order->get_billing_email(), 342 'contact' => $order->get_billing_phone(), 343 ); 344 $amount = $order->get_total(); 345 $main_order_key = $order->get_order_key(); 346 $email = $order->get_billing_email(); 347 $currency = $order->get_currency(); 348 } 349 350 // $amount = $order->order_total; 351 // $email = $order->billing_email; 352 // $currency = $order->get_order_currency(); 353 354 //set the currency to route to their countries 355 switch ($currency) { 356 case 'KES': 357 $this->country = 'KE'; 358 break; 359 case 'GHS': 360 $this->country = 'GH'; 361 break; 362 case 'ZAR': 363 $this->country = 'ZA'; 364 break; 365 case 'TZS': 366 $this->country = 'TZ'; 367 break; 368 369 default: 370 $this->country = 'NG'; 371 break; 372 } 373 374 $country = $this->country; 375 $payment_style = $this->payment_style; 376 377 if ($main_order_key == $order_key) { 378 379 $payment_args = compact('amount', 'email', 'txnref', 'p_key', 'currency', 'country', 'payment_options', 'cb_url', 'payment_style'); 380 $payment_args['desc'] = filter_var($this->description, FILTER_SANITIZE_STRING); 381 $payment_args['title'] = filter_var($this->title, FILTER_SANITIZE_STRING); 382 // $payment_args['logo'] = filter_var($this->modal_logo, FILTER_SANITIZE_URL); 383 $payment_args['firstname'] = $order->get_billing_first_name(); 384 $payment_args['lastname'] = $order->get_billing_last_name(); 385 $payment_args['barter'] = $this->barter; 386 } 387 388 update_post_meta($order_id, '_flw_payment_txn_ref', $txnref); 389 390 } 391 392 wp_localize_script('flw_js', 'flw_payment_args', $payment_args); 393 } 394 395 /** 396 * Verify payment made on the checkout page 397 * 398 * @return void 399 */ 400 public function flw_verify_payment() 401 { 402 403 $publicKey = $this->public_key; 404 $secretKey = $this->secret_key; 405 $logging_option = $this->logging_option; 406 407 408 // if($this->go_live === 'yes'){ 409 // $env = 'live'; 410 // }else{ 411 // $env = 'staging'; 412 // } 413 $overrideRef = true; 414 415 if (isset($_GET['rave_id']) && urldecode($_GET['rave_id'])) { 416 $order_id = urldecode($_GET['rave_id']); 417 418 if (!$order_id) { 419 $order_id = urldecode($_GET['order_id']); 420 } 421 $order = wc_get_order($order_id); 422 423 $redirectURL = WC()->api_request_url('FLW_WC_Payment_Gateway') . '?order_id=' . $order_id; 424 425 $ref = uniqid("WOOC_" . $order_id . "_" . time() . "_"); 426 427 $payment = new Rave($publicKey, $secretKey, $ref, $overrideRef, $logging_option); 428 429 // if($this->modal_logo){ 430 // $rave_m_logo = $this->modal_logo; 403 431 // } 404 $overrideRef = true; 405 406 if(isset($_GET['rave_id']) && urldecode( $_GET['rave_id'] )){ 407 $order_id = urldecode( $_GET['rave_id'] ); 408 409 if(!$order_id){ 410 $order_id = urldecode( $_GET['order_id'] ); 411 } 412 $order = wc_get_order( $order_id ); 413 414 $redirectURL = WC()->api_request_url( 'FLW_WC_Payment_Gateway' ).'?order_id='.$order_id; 415 416 $ref = uniqid("WOOC_". $order_id."_".time()."_"); 417 418 $payment = new Rave($publicKey, $secretKey, $ref, $overrideRef,$logging_option); 419 420 // if($this->modal_logo){ 421 // $rave_m_logo = $this->modal_logo; 422 // } 423 424 //set variables 425 $modal_desc = $this->description != '' ? filter_var($this->description, FILTER_SANITIZE_STRING) : "Payment for Order ID: $order_id on ". get_bloginfo('name'); 426 $modal_title = $this->title != '' ? filter_var($this->title, FILTER_SANITIZE_STRING) : get_bloginfo('name'); 427 428 // Make payment 429 $payment 432 433 //set variables 434 $modal_desc = $this->description != '' ? filter_var($this->description, FILTER_SANITIZE_STRING) : "Payment for Order ID: $order_id on " . get_bloginfo('name'); 435 $modal_title = $this->title != '' ? filter_var($this->title, FILTER_SANITIZE_STRING) : get_bloginfo('name'); 436 437 // Make payment 438 $payment 430 439 ->eventHandler(new myEventHandler($order)) 431 440 ->setAmount($order->get_total()) … … 443 452 // ->setMetaData(array('metaname' => 'SomeDataName', 'metavalue' => 'SomeValue')) // can be called multiple times. Uncomment this to add meta datas 444 453 // ->setMetaData(array('metaname' => 'SomeOtherDataName', 'metavalue' => 'SomeOtherValue')) // can be called multiple times. Uncomment this to add meta datas 445 ->initialize(); 454 ->initialize(); 455 die(); 456 } 457 else { 458 if (isset($_GET['cancelled']) && isset($_GET['order_id'])) { 459 if (!$order_id) { 460 $order_id = urldecode($_GET['order_id']); 461 } 462 $order = wc_get_order($order_id); 463 $redirectURL = $order->get_checkout_payment_url(true); 464 header("Location: " . $redirectURL); 446 465 die(); 447 }else{ 448 if(isset($_GET['cancelled']) && isset($_GET['order_id'])){ 449 if(!$order_id){ 450 $order_id = urldecode( $_GET['order_id'] ); 451 } 452 $order = wc_get_order( $order_id ); 453 $redirectURL = $order->get_checkout_payment_url( true ); 454 header("Location: ".$redirectURL); 455 die(); 456 } 457 458 if ( isset( $_POST['txRef'] ) || isset($_GET['txref']) ) { 459 $txn_ref = isset($_POST['txRef']) ? $_POST['txRef'] : urldecode($_GET['txref']); 460 $o = explode('_', $txn_ref); 461 $order_id = intval( $o[1] ); 462 $order = wc_get_order( $order_id ); 463 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef,$this->logging_option); 464 465 $payment->logger->notice('Payment completed. Now requerying payment.'); 466 467 $payment->eventHandler(new myEventHandler($order))->requeryTransaction(urldecode($txn_ref)); 468 469 $redirect_url = $this->get_return_url( $order ); 470 header("Location: ".$redirect_url); 471 die(); 472 }else{ 473 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 474 475 $payment->logger->notice('Error with requerying payment.'); 476 die(); 477 } 478 } 479 } 480 481 /** 482 * Process Webhook 483 */ 484 public function flw_rave_webhooks() { 466 } 467 468 if (isset($_POST['txRef']) || isset($_GET['txref'])) { 469 $txn_ref = isset($_POST['txRef']) ? $_POST['txRef'] : urldecode($_GET['txref']); 470 $o = explode('_', $txn_ref); 471 $order_id = intval($o[1]); 472 $order = wc_get_order($order_id); 473 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 474 475 $payment->logger->notice('Payment completed. Now requerying payment.'); 476 477 $payment->eventHandler(new myEventHandler($order))->requeryTransaction(urldecode($txn_ref)); 478 479 $redirect_url = $this->get_return_url($order); 480 header("Location: " . $redirect_url); 481 die(); 482 } 483 else { 484 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 485 486 $payment->logger->notice('Error with requerying payment.'); 487 die(); 488 } 489 } 490 } 491 492 /** 493 * Process Webhook 494 */ 495 public function flw_rave_webhooks() 496 { 485 497 // Retrieve the request's body 486 498 $body = @file_get_contents("php://input"); … … 490 502 491 503 /* It is a good idea to log all events received. Add code * 492 * here to log the signature and body to db or file */504 * here to log the signature and body to db or file */ 493 505 494 506 if (!$signature) { 495 // only a post with rave signature header gets our attention496 echo "Access Denied Hash does not match";497 exit();507 // only a post with rave signature header gets our attention 508 echo "Access Denied Hash does not match"; 509 exit(); 498 510 } 499 511 … … 502 514 503 515 // confirm the event's signature 504 if ( $signature !== $local_signature ){516 if ($signature !== $local_signature) { 505 517 // silently forget this ever happened 506 518 exit(); … … 518 530 if ($response_version) { 519 531 520 switch ($response_version) { 521 case 'v3': 522 $getOrderId = explode('_', $response->data->tx_ref); 523 $orderId = $getOrderId[1]; 524 // $order = wc_get_order( $orderId ); 525 $order = new WC_Order($orderId); 526 $secretKey = $this->secret_key; 527 $publicKey = $this->public_key; 528 $order->add_order_note('Webhook verification initiated - v3'); 529 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 530 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->data->tx_ref); 531 do_action('flw_webhook_after_action', json_encode($response->data, TRUE)); 532 break; 533 default: 534 $getOrderId = explode('_', $response->txRef); 535 $orderId = $getOrderId[1]; 536 // $order = wc_get_order( $orderId ); 537 $order = new WC_Order($orderId); 538 $secretKey = $this->secret_key; 539 $publicKey = $this->public_key; 540 $order->add_order_note('Webhook verification initiated - v2'); 541 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 542 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->txRef); 543 do_action('flw_webhook_after_action', json_encode($response, TRUE)); 544 break; 545 } 546 } 547 exit(); 548 549 } 550 551 /** 552 * Save Customer Card Details 553 */ 554 public static function save_card_details( $rave_response, $user_id, $order_id ) { 555 556 if ( isset( $rave_response->card->card_tokens[0]->embedtoken ) ) { 557 $token_code = $rave_response->card->card_tokens[0]->embedtoken; 558 } else { 559 $token_code = ''; 560 } 561 562 // save payment token to the order 563 self::save_subscription_payment_token( $order_id, $token_code ); 564 // $save_card = get_post_meta( $order_id, '_wc_rave_save_card', true ); 565 } 566 567 /** 568 * Save payment token to the order for automatic renewal for further subscription payment 569 */ 570 public static function save_subscription_payment_token( $order_id, $payment_token ) { 571 572 if ( ! function_exists ( 'wcs_order_contains_subscription' ) ) { 573 return; 574 } 575 576 if ( WC_Subscriptions_Order::order_contains_subscription( $order_id ) && ! empty( $payment_token ) ) { 577 578 // Also store it on the subscriptions being purchased or paid for in the order 579 if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { 580 581 $subscriptions = wcs_get_subscriptions_for_order( $order_id ); 582 583 } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { 584 585 $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); 586 587 } else { 588 589 $subscriptions = array(); 590 591 } 592 593 foreach ( $subscriptions as $subscription ) { 594 595 $subscription_id = $subscription->get_id(); 596 597 update_post_meta( $subscription_id, '_rave_wc_token', $payment_token ); 598 599 } 600 } 601 } 602 603 } 604 532 switch ($response_version) { 533 case 'v3': 534 $getOrderId = explode('_', $response->data->tx_ref); 535 $orderId = $getOrderId[1]; 536 // $order = wc_get_order( $orderId ); 537 $order = new WC_Order($orderId); 538 $secretKey = $this->secret_key; 539 $publicKey = $this->public_key; 540 $order->add_order_note('Webhook verification initiated - v3'); 541 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 542 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->data->tx_ref); 543 do_action('flw_webhook_after_action', json_encode($response->data, TRUE)); 544 break; 545 default: 546 $getOrderId = explode('_', $response->txRef); 547 $orderId = $getOrderId[1]; 548 // $order = wc_get_order( $orderId ); 549 $order = new WC_Order($orderId); 550 $secretKey = $this->secret_key; 551 $publicKey = $this->public_key; 552 $order->add_order_note('Webhook verification initiated - v2'); 553 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option); 554 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->txRef); 555 do_action('flw_webhook_after_action', json_encode($response, TRUE)); 556 break; 557 } 558 } 559 exit(); 560 561 } 562 563 /** 564 * Save Customer Card Details 565 */ 566 public static function save_card_details($rave_response, $user_id, $order_id) 567 { 568 569 if (isset($rave_response->card->card_tokens[0]->embedtoken)) { 570 $token_code = $rave_response->card->card_tokens[0]->embedtoken; 571 } 572 else { 573 $token_code = ''; 574 } 575 576 // save payment token to the order 577 self::save_subscription_payment_token($order_id, $token_code); 578 // $save_card = get_post_meta( $order_id, '_wc_rave_save_card', true ); 579 } 580 581 /** 582 * Save payment token to the order for automatic renewal for further subscription payment 583 */ 584 public static function save_subscription_payment_token($order_id, $payment_token) 585 { 586 587 if (!function_exists('wcs_order_contains_subscription')) { 588 return; 589 } 590 591 if (WC_Subscriptions_Order::order_contains_subscription($order_id) && !empty($payment_token)) { 592 593 // Also store it on the subscriptions being purchased or paid for in the order 594 if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) { 595 596 $subscriptions = wcs_get_subscriptions_for_order($order_id); 597 598 } 599 elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) { 600 601 $subscriptions = wcs_get_subscriptions_for_renewal_order($order_id); 602 603 } 604 else { 605 606 $subscriptions = array(); 607 608 } 609 610 foreach ($subscriptions as $subscription) { 611 612 $subscription_id = $subscription->get_id(); 613 614 update_post_meta($subscription_id, '_rave_wc_token', $payment_token); 615 616 } 617 } 618 } 619 620 } 621 622 605 623 ?> -
rave-woocommerce-payment-gateway/trunk/readme.txt
r2754379 r2772073 4 4 Requires at least: 3.1 5 5 Tested up to: 6.0 6 Stable tag: 2. 2.96 Stable tag: 2.3.0 7 7 License: MIT 8 8 License URI: https://github.com/Flutterwave/rave-woocommerce/blob/master/LICENSE … … 100 100 101 101 == Changelog == 102 = 2.3.0 = 103 * Fix: Handled MobileMoney Payment Handler Error. 102 104 = 2.2.9 = 103 105 * Fixed: PHP 8 support for v3 Webhook Handler. -
rave-woocommerce-payment-gateway/trunk/woocommerce-rave.php
r2754379 r2772073 5 5 Plugin URI: https://rave.flutterwave.com/ 6 6 Description: Official WooCommerce payment gateway for Rave. 7 Version: 2. 2.97 Version: 2.3.0 8 8 Author: Flutterwave Developers 9 9 Author URI: http://developer.flutterwave.com
Note: See TracChangeset
for help on using the changeset viewer.