initial commit 2

This commit is contained in:
equippedcoding-master
2025-09-17 15:19:57 -05:00
parent e2c98790b2
commit 1c59875b8a
55391 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
CLIENT_ID=AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN
APP_SECRET=EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-

View File

@@ -0,0 +1,143 @@
<?php
class PaypalIPN
{
/** @var bool Indicates if the sandbox endpoint is used. */
private $use_sandbox = false;
/** @var bool Indicates if the local certificates are used. */
private $use_local_certs = true;
/** Production Postback URL */
const VERIFY_URI = 'https://ipnpb.paypal.com/cgi-bin/webscr';
/** Sandbox Postback URL */
const SANDBOX_VERIFY_URI = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr';
/** Response from PayPal indicating validation was successful */
const VALID = 'VERIFIED';
/** Response from PayPal indicating validation failed */
const INVALID = 'INVALID';
/**
* Sets the IPN verification to sandbox mode (for use when testing,
* should not be enabled in production).
* @return void
*/
public function useSandbox()
{
$this->use_sandbox = true;
}
/**
* Sets curl to use php curl's built in certs (may be required in some
* environments).
* @return void
*/
public function usePHPCerts()
{
$this->use_local_certs = false;
}
/**
* Determine endpoint to post the verification data to.
*
* @return string
*/
public function getPaypalUri()
{
if ($this->use_sandbox) {
return self::SANDBOX_VERIFY_URI;
} else {
return self::VERIFY_URI;
}
}
/**
* Verification Function
* Sends the incoming post data back to PayPal using the cURL library.
*
* @return bool
* @throws Exception
*/
public function verifyIPN()
{
if ( ! count($_POST)) {
throw new Exception("Missing POST Data");
}
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode('=', $keyval);
if (count($keyval) == 2) {
// Since we do not want the plus in the datetime string to be encoded to a space, we manually encode it.
if ($keyval[0] === 'payment_date') {
if (substr_count($keyval[1], '+') === 1) {
$keyval[1] = str_replace('+', '%2B', $keyval[1]);
}
}
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
}
// Build the body of the verification post request, adding the _notify-validate command.
$req = 'cmd=_notify-validate';
$get_magic_quotes_exists = false;
if (function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// Post the data back to PayPal, using curl. Throw exceptions if errors occur.
$ch = curl_init($this->getPaypalUri());
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
// This is often required if the server is missing a global cert bundle, or is using an outdated one.
if ($this->use_local_certs) {
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . "/cert/cacert.pem");
}
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: PHP-IPN-Verification-Script',
'Connection: Close',
));
$res = curl_exec($ch);
if ( ! ($res)) {
$errno = curl_errno($ch);
$errstr = curl_error($ch);
curl_close($ch);
throw new Exception("cURL error: [$errno] $errstr");
}
$info = curl_getinfo($ch);
$http_code = $info['http_code'];
if ($http_code != 200) {
throw new Exception("PayPal responded with http code $http_code");
}
curl_close($ch);
// Check if PayPal verifies the IPN data, and if so, return true.
if ($res == self::VALID) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,9 @@
# Advanced Integration Example
## Instructions
1. Add `CLIENT_ID` and `APP_SECRET` to the `.env` file
2. Run `npm install`
3. Run `npm start`
4. Open http://localhost:8888
5. Enter the credit card number provided from one of your [sandbox accounts](https://developer.paypal.com/dashboard/accounts) or [generate a new credit card](https://developer.paypal.com/dashboard/creditCardGenerator)

View File

@@ -0,0 +1,149 @@
/*
Content-Length: 2142
X-B3-Spanid: 3908e7a46bef5bda
Correlation-Id: 3cccaeb33a473
User-Agent: PayPal/AUHD-214.0-58228326
Content-Type: application/json
Paypal-Auth-Algo: SHA256withRSA
Paypal-Cert-Url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
Paypal-Auth-Version: v2
Paypal-Transmission-Sig: H/qC8vLJ3evL3sCsfghMpFvXkCRAtUra4zjONE6DEireGZyd29DSHN2luo2Wc7pWo6rHGV4zT8+hBPllI8oPsr2XHGrn7yITGJUyMhPu7MrYLwzBVZTpyO4vmKxgwgstgPZl5l8Tkqh9hEM+maG73ac5+kHkVMdBWSpLod9UMZo+0IgPGAFJsRZEFiYYmHVNUhWzE3nYRDTnZ/oe8lNhYEWntNMPqfOMm3c8PhTf/L7LGIs5hjXTdeGynEK56RzlnOlYs6/IPt4vjF8awOxWZN1KJ1GmbigiBo8V9M+RfZOmZtMrYkFJVs+W9PMrradAXMp/fzQBc1AShf4HppjdkQ==
Paypal-Transmission-Time: 2023-12-08T01:57:04Z
Paypal-Transmission-Id: 159c1af0-956d-11ee-9d07-d17444562949
Accept:
Host: www15.cradle2careertx.org
auth-algo: SHA256withRSA
User-Agent: PayPal/AUHD-214.0-58228326
cert-url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
auth-version: v2
transmission-sig: H/qC8vLJ3evL3sCsfghMpFvXkCRAtUra4zjONE6DEireGZyd29DSHN2luo2Wc7pWo6rHGV4zT8+hBPllI8oPsr2XHGrn7yITGJUyMhPu7MrYLwzBVZTpyO4vmKxgwgstgPZl5l8Tkqh9hEM+maG73ac5+kHkVMdBWSpLod9UMZo+0IgPGAFJsRZEFiYYmHVNUhWzE3nYRDTnZ/oe8lNhYEWntNMPqfOMm3c8PhTf/L7LGIs5hjXTdeGynEK56RzlnOlYs6/IPt4vjF8awOxWZN1KJ1GmbigiBo8V9M+RfZOmZtMrYkFJVs+W9PMrradAXMp/fzQBc1AShf4HppjdkQ==
transmission-time: 2023-12-08T01:57:04Z
transmission-id: 159c1af0-956d-11ee-9d07-d17444562949
*/
let x = {
"id": "WH-COC11055RA711503B-4YM959094A144403T",
"create_time": "2018-04-16T21:21:49.000Z",
"event_type": "CHECKOUT.ORDER.COMPLETED",
"resource_type": "checkout-order",
"resource_version": "2.0",
"summary": "Checkout Order Completed",
"resource": {
"id": "5O190127TN364715T",
"status": "COMPLETED",
"intent": "CAPTURE",
"gross_amount": {
"currency_code": "USD",
"value": "100.00"
},
"payer": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "buyer@example.com",
"payer_id": "QYR5Z8XDVJNXQ"
},
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"payee": {
"email_address": "seller@example.com"
},
"shipping": {
"method": "United States Postal Service",
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
},
"payments": {
"captures": [
{
"id": "3C679366HH908993F",
"status": "COMPLETED",
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"final_capture": true,
"seller_receivable_breakdown": {
"gross_amount": {
"currency_code": "USD",
"value": "100.00"
},
"paypal_fee": {
"currency_code": "USD",
"value": "3.00"
},
"net_amount": {
"currency_code": "USD",
"value": "97.00"
}
},
"create_time": "2018-04-01T21:20:49Z",
"update_time": "2018-04-01T21:20:49Z",
"links": [
{
"href": "https:\/\/api.paypal.com\/v2\/payments\/captures\/3C679366HH908993F",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.paypal.com\/v2\/payments\/captures\/3C679366HH908993F\/refund",
"rel": "refund",
"method": "POST"
}
]
}
]
}
}
],
"create_time": "2018-04-01T21:18:49Z",
"update_time": "2018-04-01T21:20:49Z",
"links": [
{
"href": "https:\/\/api.paypal.com\/v2\/checkout\/orders\/5O190127TN364715T",
"rel": "self",
"method": "GET"
}
]
},
"links": [
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/notifications\/webhooks-events\/WH-COC11055RA711503B-4YM959094A144403T",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/notifications\/webhooks-events\/WH-COC11055RA711503B-4YM959094A144403T\/resend",
"rel": "resend",
"method": "POST"
}
],
"zts": 1494957670,
"event_version": "1.0"
}

View File

@@ -0,0 +1,35 @@
/*
auth-algo: SHA256withRSA
User-Agent: PayPal/AUHD-214.0-58228326
cert-url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
auth-version: v2
transmission-sig: LhOTxbycvxea/jxeHc0HUMF7xdP/JJ8mm6tYS5J2lBv9omICfBdSzs8pibxxCoYD2Pyk8gLdekmiloJUfMfNOf7+/8KAPOzc9wyFpU7MeS8YAPyxnLWAJrhKDVgQleiF7I2TaTKdLBpGfdOUkPutxkhMfQuNMVy3EA3hOFKQuT3CoaaGlU15MRKHMaWl0k+J955FQ6Tx6Y8+3GAGe+helomEoGuUXZyx4ee1ZJ2Jx/EHU9NUqOXXtQ4MwLnnhe08Hz33occm42BQPUaepQKNBbf0Ff0ppEs7Ga++upk8a3Tm2DsIsBC71/fqlVsuPlbf3856ms44qZb1g/hBBufRPg==
transmission-time: 2023-12-07T22:27:56Z
transmission-id: de659ba0-954f-11ee-b7a2-ef38e48b54d0
*/
let h = {
"id": "WH-6W4482673W002281V-61985753LP2332451",
"create_time": "2018-19-12T22:20:32.000Z",
"event_type": "CHECKOUT.CHECKOUT.BUYER-APPROVED",
"event_version": "1.0",
"resource_type": "payment",
"summary": "Checkout Payment is created and approved by buyer.",
"resource": {
"id": "EC-7JW39463WG7174715",
"payload": "payment_type=instant&payment_date=10%3A46%3A54%20Apr%2028%2C%202019%20PDT&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller@paypalsandbox.com&receiver_email=seller@paypalsandbox.com&receiver_id=seller@paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=274113719&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AmoLQMSQnFNTX4UH11dp7XvPK.4bAfd10dnRIZeo9cONJNn0b9NquIGb"
},
"links": [
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451\/resend",
"rel": "resend",
"method": "POST"
}
]
}

View File

@@ -0,0 +1,33 @@
auth-algo: SHA256withRSA
User-Agent: PayPal/AUHD-214.0-58228326
cert-url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
auth-version: v2
transmission-sig: LhOTxbycvxea/jxeHc0HUMF7xdP/JJ8mm6tYS5J2lBv9omICfBdSzs8pibxxCoYD2Pyk8gLdekmiloJUfMfNOf7+/8KAPOzc9wyFpU7MeS8YAPyxnLWAJrhKDVgQleiF7I2TaTKdLBpGfdOUkPutxkhMfQuNMVy3EA3hOFKQuT3CoaaGlU15MRKHMaWl0k+J955FQ6Tx6Y8+3GAGe+helomEoGuUXZyx4ee1ZJ2Jx/EHU9NUqOXXtQ4MwLnnhe08Hz33occm42BQPUaepQKNBbf0Ff0ppEs7Ga++upk8a3Tm2DsIsBC71/fqlVsuPlbf3856ms44qZb1g/hBBufRPg==
transmission-time: 2023-12-07T22:27:56Z
transmission-id: de659ba0-954f-11ee-b7a2-ef38e48b54d0
{
"id": "WH-6W4482673W002281V-61985753LP2332451",
"create_time": "2018-19-12T22:20:32.000Z",
"event_type": "CHECKOUT.CHECKOUT.BUYER-APPROVED",
"event_version": "1.0",
"resource_type": "payment",
"summary": "Checkout Payment is created and approved by buyer.",
"resource": {
"id": "EC-7JW39463WG7174715",
"payload": "payment_type=instant&payment_date=10%3A46%3A54%20Apr%2028%2C%202019%20PDT&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller@paypalsandbox.com&receiver_email=seller@paypalsandbox.com&receiver_id=seller@paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=274113719&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AmoLQMSQnFNTX4UH11dp7XvPK.4bAfd10dnRIZeo9cONJNn0b9NquIGb"
},
"links": [
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451\/resend",
"rel": "resend",
"method": "POST"
}
]
}

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,2 @@
# PayPal Developer Docs Example Code
Examples from the official PayPal Developer Docs

View File

@@ -0,0 +1,2 @@
CLIENT_ID=AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN
APP_SECRET=EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-

View File

@@ -0,0 +1,9 @@
# Advanced Integration Example
## Instructions
1. Add `CLIENT_ID` and `APP_SECRET` to the `.env` file
2. Run `npm install`
3. Run `npm start`
4. Open http://localhost:8888
5. Enter the credit card number provided from one of your [sandbox accounts](https://developer.paypal.com/dashboard/accounts) or [generate a new credit card](https://developer.paypal.com/dashboard/creditCardGenerator)

View File

@@ -0,0 +1,971 @@
{
"name": "@paypalcorp/advanced-integration",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@paypalcorp/advanced-integration",
"version": "1.0.0",
"license": "Apache-2.0",
"dependencies": {
"dotenv": "^16.0.0",
"ejs": "^3.1.6",
"express": "^4.17.3",
"html-entities": "^2.4.0",
"mysql2": "^3.6.0",
"node-fetch": "^3.2.1"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.11.0",
"raw-body": "2.5.1",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dependencies": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"engines": {
"node": ">= 12"
}
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/denque": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
"engines": {
"node": ">=0.10"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/ejs": {
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
"dependencies": {
"jake": "^10.8.5"
},
"bin": {
"ejs": "bin/cli.js"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.1",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.5.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.2.0",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.7",
"qs": "6.11.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.18.0",
"serve-static": "1.15.0",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/filelist": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
"integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
"dependencies": {
"minimatch": "^5.0.1"
}
},
"node_modules/filelist/node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/filelist/node_modules/minimatch": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/finalhandler": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/generate-function": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
"integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==",
"dependencies": {
"is-property": "^1.0.2"
}
},
"node_modules/get-intrinsic": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/html-entities": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz",
"integrity": "sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/mdevils"
},
{
"type": "patreon",
"url": "https://patreon.com/mdevils"
}
]
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/is-property": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="
},
"node_modules/jake": {
"version": "10.8.7",
"resolved": "https://registry.npmjs.org/jake/-/jake-10.8.7.tgz",
"integrity": "sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==",
"dependencies": {
"async": "^3.2.3",
"chalk": "^4.0.2",
"filelist": "^1.0.4",
"minimatch": "^3.1.2"
},
"bin": {
"jake": "bin/cli.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/long": {
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q=="
},
"node_modules/lru-cache": {
"version": "8.0.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz",
"integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==",
"engines": {
"node": ">=16.14"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/mysql2": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.6.0.tgz",
"integrity": "sha512-EWUGAhv6SphezurlfI2Fpt0uJEWLmirrtQR7SkbTHFC+4/mJBrPiSzHESHKAWKG7ALVD6xaG/NBjjd1DGJGQQQ==",
"dependencies": {
"denque": "^2.1.0",
"generate-function": "^2.3.1",
"iconv-lite": "^0.6.3",
"long": "^5.2.1",
"lru-cache": "^8.0.0",
"named-placeholders": "^1.1.3",
"seq-queue": "^0.0.5",
"sqlstring": "^2.3.2"
},
"engines": {
"node": ">= 8.0"
}
},
"node_modules/mysql2/node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/mysql2/node_modules/sqlstring": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.3.tgz",
"integrity": "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/named-placeholders": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz",
"integrity": "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==",
"dependencies": {
"lru-cache": "^7.14.1"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/named-placeholders/node_modules/lru-cache": {
"version": "7.18.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
"integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==",
"engines": {
"node": ">=12"
}
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/seq-queue": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
"integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="
},
"node_modules/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.18.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/web-streams-polyfill": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"engines": {
"node": ">= 8"
}
}
}
}

View File

@@ -0,0 +1,22 @@
{
"name": "@paypalcorp/advanced-integration",
"version": "1.0.0",
"description": "",
"main": "server.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"start2": "node server2.js"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"dotenv": "^16.0.0",
"ejs": "^3.1.6",
"express": "^4.17.3",
"html-entities": "^2.4.0",
"mysql2": "^3.6.0",
"node-fetch": "^3.2.1"
}
}

View File

@@ -0,0 +1,380 @@
import fetch from "node-fetch";
// set some important variables
// const { CLIENT_ID, APP_SECRET } = process.env;
// const base = "https://api-m.sandbox.paypal.com";
async function handleResponse(response) {
if (response.status === 200 || response.status === 201) {
return response.json();
}
const errorMessage = await response.text();
throw new Error(errorMessage);
}
// generate access token
export async function generateAccessToken(base,PaypalClientId,PaypalAppSecret) {
console.log(PaypalClientId + ":" + PaypalAppSecret);
const auth = Buffer.from(PaypalClientId + ":" + PaypalAppSecret).toString("base64");
console.log(auth);
const response = await fetch(`${base}/v1/oauth2/token`, {
method: "post",
body: "grant_type=client_credentials",
headers: {
Authorization: `Basic ${auth}`,
},
});
const jsonData = await handleResponse(response);
return jsonData.access_token;
}
// generate client token
export async function generateClientToken(base,PaypalClientId,PaypalAppSecret) {
const accessToken = await generateAccessToken(base, PaypalClientId,PaypalAppSecret);
const response = await fetch(`${base}/v1/identity/generate-token`, {
method: "post",
headers: {
Authorization: `Bearer ${accessToken}`,
"Accept-Language": "en_US",
"Content-Type": "application/json",
},
});
console.log('response', response.status)
const jsonData = await handleResponse(response);
return jsonData.client_token;
}
// call the create order method
export async function createOrder(base,data,PaypalClientId,PaypalAppSecret) {
const purchaseAmount = data.price;//"100.00"; // TODO: pull prices from a database
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v2/checkout/orders`;
console.log(url)
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "USD",
value: purchaseAmount,
},
},
],
}),
});
return handleResponse(response);
}
// capture payment for an order
export async function capturePayment(base,orderId,PaypalClientId,PaypalAppSecret) {
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v2/checkout/orders/${orderId}/capture`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
return handleResponse(response);
}
export async function verifyWebHook(base,PaypalClientId,PaypalAppSecret){
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v1/notifications/verify-webhook-signature`;
// fetch('https://api-m.sandbox.paypal.com/v1/notifications/verify-webhook-signature', {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
"transmission_id": "69cd13f0-d67a-11e5-baa3-778b53f4ae55",
"transmission_time": "2016-02-18T20:01:35Z",
"cert_url": "cert_url", // PAYPAL-CERT-URL
"auth_algo": "SHA256withRSA", // PAYPAL-AUTH-ALGO
"transmission_sig": "lmI95Jx3Y9nhR5SJWlHVIWpg4AgFk7n9bCHSRxbrd8A9zrhdu2rMyFrmz+Zjh3s3boXB07VXCXUZy/UFzUlnGJn0wDugt7FlSvdKeIJenLRemUxYCPVoEZzg9VFNqOa48gMkvF+XTpxBeUx/kWy6B5cp7GkT2+pOowfRK7OaynuxUoKW3JcMWw272VKjLTtTAShncla7tGF+55rxyt2KNZIIqxNMJ48RDZheGU5w1npu9dZHnPgTXB9iomeVRoD8O/jhRpnKsGrDschyNdkeh81BJJMH4Ctc6lnCCquoP/GzCzz33MMsNdid7vL/NIWaCsekQpW26FpWPi/tfj8nLA==",
"webhook_id": "1JE4291016473214C",
"webhook_event": {
"id": "8PT597110X687430LKGECATA",
"create_time": "2013-06-25T21:41:28Z",
"resource_type": "authorization",
"event_type": "PAYMENT.AUTHORIZATION.CREATED",
"summary": "A payment authorization was created",
"resource": {
"id": "2DC87612EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-36246664YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z", "links": [
{
"href": "https://api-m.paypal.com/v1/payments/authorization/2DC87612EK520411B",
"rel": "self",
"method": "GET"
},
{
"href": "https://api-m.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
"rel": "capture",
"method": "POST"
},
{
"href": "https://api-m.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
"rel": "void",
"method": "POST"
},
{
"href": "https://api-m.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
"rel": "parent_payment",
"method": "GET"
}
]
}
}
})// end body
});// end fetch
if (response.status === 200 || response.status === 201) {
return response.json();
}
const errorMessage = await response.text();
throw new Error(errorMessage);
}
export async function payout(base,PaypalClientId,PaypalAppSecret,data){
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v1/payments/payouts`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: data
});
return handleResponse(response);
}
// capture payment for an order
export async function refundPayment(base,PaypalClientId,PaypalAppSecret,orderId) {
const accessToken = await generateAccessToken(base, PaypalClientId,PaypalAppSecret);
const url = `${base}/v2/payments/captures/${capture_id}/refund`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${accessToken}`,
'PayPal-Request-Id': '123e4567-e89b-12d3-a456-426655440020',
'Prefer': 'return=representation'
},
body: JSON.stringify(
{
"amount": { "value": "10.00", "currency_code": "USD" },
"invoice_id": "INVOICE-123",
"note_to_payer": "DefectiveProduct",
"payment_instruction": {
"platform_fees": [
{
"amount": {
"currency_code": "USD",
"value": "1.00"
}
}
]
}
})
});
return handleResponse(response);
}
export async function create_subscription_product(base,PaypalClientId,PaypalAppSecret,data){
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v1/catalogs/products`;
// let data = {
// "consumer": {
// "accountNumber":1181198218909172527,
// "merchantId":"5KW8F2FXKX5HA"
// },
// "merchant":{
// "accountNumber":1659371090107732880,
// "merchantId":"2J6QB8YJQSJRJ"
// },
// "apiCaller":{
// "clientId":"AdtlNBDhgmQWi2xk6edqJVKklPFyDWxtyKuXuyVT-OgdnnKpAVsbKHgvqHHP",
// "appId":"APP-6DV794347V142302B",
// "payerId":"2J6QB8YJQSJRJ",
// "accountNumber":"1659371090107732880"
// },
// "scopes":["https://api-m.paypal.com/v1/subscription/.*","https://uri.paypal.com/services/subscription","openid"]
// }
const response = await fetch(url, {
//fetch('https://api-m.sandbox.paypal.com/v1/catalogs/products', {
method: 'POST',
headers: {
// 'X-PAYPAL-SECURITY-CONTEXT': '{"consumer":{"accountNumber":1181198218909172527,"merchantId":"5KW8F2FXKX5HA"},"merchant":{"accountNumber":1659371090107732880,"merchantId":"2J6QB8YJQSJRJ"},"apiCaller":{"clientId":"AdtlNBDhgmQWi2xk6edqJVKklPFyDWxtyKuXuyVT-OgdnnKpAVsbKHgvqHHP","appId":"APP-6DV794347V142302B","payerId":"2J6QB8YJQSJRJ","accountNumber":"1659371090107732880"},"scopes":["https://api-m.paypal.com/v1/subscription/.*","https://uri.paypal.com/services/subscription","openid"]}',
'X-PAYPAL-SECURITY-CONTEXT': JSON.stringify(data),
'Content-Type': 'application/json',
'Accept': 'application/json',
'PayPal-Request-Id': 'PRODUCT-18062019-001',
'Prefer': 'return=representation'
},
body: JSON.stringify({
"name": "Video Streaming Service",
"description": "Video streaming service",
"type": "SERVICE",
"category": "SOFTWARE",
"image_url": "https://example.com/streaming.jpg",
"home_url": "https://example.com/home"
})
});
return handleResponse(response);
}
export async function create_subscription_plan(base,PaypalClientId,PaypalAppSecret,data){
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v1/billing/plans`;
// let data = {
// "consumer":{
// "accountNumber":1181198218909172527,
// "merchantId":"5KW8F2FXKX5HA"
// },
// "merchant":{
// "accountNumber":1659371090107732880,
// "merchantId":"2J6QB8YJQSJRJ"
// },
// "apiCaller":{
// "clientId":"AdtlNBDhgmQWi2xk6edqJVKklPFyDWxtyKuXuyVT-OgdnnKpAVsbKHgvqHHP",
// "appId":"APP-6DV794347V142302B",
// "payerId":"2J6QB8YJQSJRJ",
// "accountNumber":"1659371090107732880"
// },
// "scopes":["https://api-m.paypal.com/v1/subscription/.*","https://uri.paypal.com/services/subscription","openid"]
// };
const response = await fetch(url, {
// fetch('https://api-m.sandbox.paypal.com/v1/billing/plans', {
method: 'POST',
headers: {
'X-PAYPAL-SECURITY-CONTEXT': JSON.stringify(data),
'Content-Type': 'application/json',
'Accept': 'application/json',
'PayPal-Request-Id': 'PLAN-18062019-001',
'Prefer': 'return=representation'
},
body: JSON.stringify({
"product_id": "PROD-XXCD1234QWER65782",
"name": "Video Streaming Service Plan",
"description": "Video Streaming Service basic plan",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 2,
"pricing_scheme": {
"fixed_price": {
"value": "3",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 2,
"total_cycles": 3,
"pricing_scheme": {
"fixed_price": {
"value": "6",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 3,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "10",
"currency_code":
"USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
}, "setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
})
});
return handleResponse(response);
}
export async function get_product_plan(base,PaypalClientId,PaypalAppSecret,data){
const accessToken = await generateAccessToken(base,PaypalClientId,PaypalAppSecret);
const url = `${base}/v1/catalogs/products?page_size=2&page=1&total_required=true`;
const response = await fetch(url, {
// fetch('https://api-m.sandbox.paypal.com/v1/catalogs/products?page_size=2&page=1&total_required=true', {
headers: {
'X-PAYPAL-SECURITY-CONTEXT': JSON.stringify(data),
'Content-Type': 'application/json',
'Accept': 'application/json',
"Authorization": `Bearer ${accessToken}`,
}
});
return handleResponse(response);
}

View File

@@ -0,0 +1,160 @@
paypal
.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function () {
return fetch("/api/orders", {
method: "post",
// use the "body" param to optionally pass additional order information
// like product skus and quantities
body: JSON.stringify({
cart: [
{
sku: "<YOUR_PRODUCT_STOCK_KEEPING_UNIT>",
quantity: "<YOUR_PRODUCT_QUANTITY>",
},
],
}),
})
.then((response) => response.json())
.then((order) => order.id);
},
// Finalize the transaction after payer approval
onApprove: function (data) {
return fetch(`/api/orders/${data.orderID}/capture`, {
method: "post",
})
.then((response) => response.json())
.then((orderData) => {
// Successful capture! For dev/demo purposes:
console.log(
"Capture result",
orderData,
JSON.stringify(orderData, null, 2)
);
const transaction = orderData.purchase_units[0].payments.captures[0];
alert(`Transaction ${transaction.status}: ${transaction.id}
See console for all available details
`);
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
})
.render("#paypal-button-container");
// If this returns false or the card fields aren't visible, see Step #1.
if (paypal.HostedFields.isEligible()) {
let orderId;
// Renders card fields
paypal.HostedFields.render({
// Call your server to set up the transaction
createOrder: () => {
return fetch("/api/orders", {
method: "post",
// use the "body" param to optionally pass additional order information
// like product skus and quantities
body: JSON.stringify({
cart: [
{
sku: "<YOUR_PRODUCT_STOCK_KEEPING_UNIT>",
quantity: "<YOUR_PRODUCT_QUANTITY>",
},
],
}),
})
.then((res) => res.json())
.then((orderData) => {
orderId = orderData.id; // needed later to complete capture
return orderData.id;
});
},
styles: {
".valid": {
color: "green",
},
".invalid": {
color: "red",
},
},
fields: {
number: {
selector: "#card-number",
placeholder: "4111 1111 1111 1111",
},
cvv: {
selector: "#cvv",
placeholder: "123",
},
expirationDate: {
selector: "#expiration-date",
placeholder: "MM/YY",
},
},
}).then((cardFields) => {
document.querySelector("#card-form").addEventListener("submit", (event) => {
event.preventDefault();
cardFields
.submit({
// Cardholder's first and last name
cardholderName: document.getElementById("card-holder-name").value,
// Billing Address
billingAddress: {
// Street address, line 1
streetAddress: document.getElementById(
"card-billing-address-street"
).value,
// Street address, line 2 (Ex: Unit, Apartment, etc.)
extendedAddress: document.getElementById(
"card-billing-address-unit"
).value,
// State
region: document.getElementById("card-billing-address-state").value,
// City
locality: document.getElementById("card-billing-address-city")
.value,
// Postal Code
postalCode: document.getElementById("card-billing-address-zip")
.value,
// Country Code
countryCodeAlpha2: document.getElementById(
"card-billing-address-country"
).value,
},
})
.then(() => {
fetch(`/api/orders/${orderId}/capture`, {
method: "post",
})
.then((res) => res.json())
.then((orderData) => {
// Two cases to handle:
// (1) Other non-recoverable errors -> Show a failure message
// (2) Successful transaction -> Show confirmation or thank you
// This example reads a v2/checkout/orders capture response, propagated from the server
// You could use a different API or structure for your 'orderData'
const errorDetail =
Array.isArray(orderData.details) && orderData.details[0];
if (errorDetail) {
var msg = "Sorry, your transaction could not be processed.";
if (errorDetail.description)
msg += "\n\n" + errorDetail.description;
if (orderData.debug_id) msg += " (" + orderData.debug_id + ")";
return alert(msg); // Show a failure message
}
// Show a success message or redirect
alert("Transaction completed!");
});
})
.catch((err) => {
alert("Payment could not be captured! " + JSON.stringify(err));
});
});
});
} else {
// Hides card fields if the merchant isn't eligible
document.querySelector("#card-form").style = "display: none";
}

View File

@@ -0,0 +1,257 @@
import { createRequire } from 'module';
import path from 'path';
import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const fs = require('fs');
import {decode} from 'html-entities';
//import "dotenv/config";
import express from "express";
import http from "http";
import https from "https";
import * as paypal from "./paypal-api.js";
var mysql = require('mysql2');
// pm2 start server.js --name "www5" -- www5
// pm2 start server.js --name "www10" -- www10
// pm2 delete www15;pm2 start server.js --name www15 -- www15;pm2 logs www --lines 1000
// pm2 logs --lines 1000
// /home/cradle2careertxxyz/websites/www10/portal/dashboard/system/scripts
// /home/cradle2careertxxyz/websites/www10/portal/dashboard/services/paypal/node/advanced-integration
//process.argv.forEach(function (val, index, array) {console.log(index + ': ' + val);});
const subdomain = process.argv[2];
const mypath = path.join(__dirname, '../../../../../system/db/.env');
require('dotenv').config({ path: mypath })
console.log(process.env.MY_DATABASE);
console.log(mypath);
console.log(subdomain);
function createMySQLConnection(){
return mysql.createConnection({
host: process.env.MY_HOSTNAME,
user: process.env.MY_USER,
password: process.env.MY_PASSWORD,
database: process.env.MY_DATABASE,
insecureAuth : true
});
}
let con = createMySQLConnection();
con.connect(function(err) {
if (err) throw err;
con.query(`SELECT * FROM subdomain_properties WHERE SubDomain = '${subdomain}'`, function (err, results) {
if (err) throw err;
// con.end();
if(results.length > 0){
let managed_domain = {};
for(let i=0; i < results.length; i++){
//console.log(results[i].SubDomain + " : " + results[i].PropertyName + " : " + results[i].PropertyValue);
managed_domain[results[i].PropertyName] = results[i].PropertyValue;
}
con.query(`SELECT * FROM configurations WHERE category="processors"`, function (err1, results1) {
if (err1) throw err1;
con.end();
if(results1.length > 0){
let processors = [];
for(let n=0; n < results1.length; n++){
let processor = results1[n];
processor.json = JSON.parse(decode(processor.json));
if(processor.json.processor=="paypal"){
processors.push(processor);
}
}
run(managed_domain, processors);
}else{
console.log(`No active server for subdomain ${subdomain}`);
}
});
}else{
console.log(`Error starting server! No port number found for subdomain ${subdomain}`);
}
});
});
function run(managed_domain, processors){
// function run(opts,opts1){
// console.log(typeof opts1[0].json);
// console.log(opts1[0].json.port);
let active_paypal = null;
for(let n=0; n < processors.length; n++){
if(processors[n].json.active==true){
active_paypal = processors[n];
break;
}
}
console.log(active_paypal);
if(active_paypal==null){
console.log("No active paypal service");
return;
}
console.log("Starting Paypal Server on port: " + active_paypal.json.service_port);
var privateKey = fs.readFileSync(managed_domain.CertPrivateKeyLocation, 'utf8');
var certificate = fs.readFileSync(managed_domain.CertPublicKeyLocation, 'utf8');
var credentials = {key: privateKey, cert: certificate};
var app = express();
// var clientId = process.env.CLIENT_ID;
let clientId = active_paypal.json.client_id;
let clientSecret = active_paypal.json.client_secret;
let base = "";
let mode = active_paypal.json.mode;
if(mode=="sandbox"){
base = "https://api-m.sandbox.paypal.com";
}else{
base = "https://api-m.paypal.com";
}
// purchase service
app.get("/"+active_paypal.json.service_end_point, async (req, res) => {
console.log(base);
try {
//console.log("starting...");
if(req.query.type=="check"){
const clientToken = await paypal.generateClientToken(base, clientId, clientSecret);
res.jsonp({action:true, token:clientToken, base:base});
}else if(req.query.type=="generate_token"){
console.log("Generating token...");
const clientToken = await paypal.generateClientToken(base, clientId, clientSecret);
res.jsonp(JSON.stringify({clientToken:clientToken,clientId:clientId}));
}else if(req.query.type=="create_order"){
console.log(req.query.data)
var data = JSON.parse( req.query.data );
const order = await paypal.createOrder(base, data, clientId, clientSecret);
res.jsonp(order);
}else if(req.query.type=="capture_order"){
const orderID = req.query.orderID;
const captureData = await paypal.capturePayment(base, orderID, clientId, clientSecret);
res.jsonp(captureData);
}else if(req.query.type=="refund"){
const orderID = req.query.orderID;
const captureData = await paypal.refundPayment(base, clientId, clientSecret, orderID);
res.jsonp(captureData);
}else if(req.query.type=="payout"){
// var data = JSON.parse( req.query.data );
const captureData = await paypal.payout(base, clientId, clientSecret, data);
res.jsonp(captureData);
}else if(req.query.type=="get_product_plan"){
var data = JSON.parse( req.query.data );
const captureData = await get_product_plan(base,clientId,clientSecret,data);
res.jsonp(captureData);
}
} catch (err) {
console.log(err.message)
res.jsonp(JSON.stringify({
err: err.message,
clientId: clientId,
clientSecret: clientSecret,
active_paypal: active_paypal
}));
}
});
app.get("/check", async (req, res) => {
try {
if(req.query.type=="generate_token"){
console.log("Generating token...");
const clientToken = await paypal.generateClientToken(base, clientId, clientSecret);
res.jsonp(JSON.stringify({clientToken:clientToken,clientId:clientId}));
}
} catch (err) {
console.log(err.message)
res.jsonp(err.message);
}
});
// webhooks
app.get("/webhook_events_listener", async (req, res) => {
const accessToken = await paypal.generateAccessToken(base, clientId,clientSecret);
/*
"transmission_id": "69cd13f0-d67a-11e5-baa3-778b53f4ae55",
"transmission_time": "2016-02-18T20:01:35Z",
"cert_url": "cert_url", // PAYPAL-CERT-URL
"auth_algo": "SHA256withRSA", // PAYPAL-AUTH-ALGO
*/
console.log("=========================")
let data = {
webhook_id: "",// The ID of the webhook as configured in your Developer Portal account.
transmission_id: req.get('PAYPAL-TRANSMISSION-ID'),
transmission_time: req.get('PAYPAL-TRANSMISSION-TIME'),
transmission_sig: req.get('PAYPAL-TRANSMISSION-SIG'),
cert_url: req.get('PAYPAL-CERT-URL'),
auth_algo: req.get('PAYPAL-AUTH-ALGO'),
}
// let fileloc = "/home/cradle2careertxorg/websites/www15/portal/admin/services/paypal/node/advanced-integration";
// fs.writeFile(fileloc + "/test", JSON.stringify(data, null, 4), function(err) {
// if(err) {
// return JSON.stringify(err, null, 4);
// }
// });
// Aa-hUI-QfmPnt7vNwhqkoSdjE0UuK0wFe-neDJiuIfnOEXhGl-Fx8Qf1hxaDqxsw_JS5ta6ew2boAoTR
// EBaL2WenKH5x028AK_WukCFOzvwRaOtIgTgVSlN44xBRwKcvCYYr0cT4JOTDQK1CVlaJ-QM_b-d_bMYu
// console.log(accessToken);
res.send(accessToken);
// let response = await paypal.verifyWebHook(base);
});
// var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
//httpServer.listen(9888);
httpsServer.listen(active_paypal.json.service_port);
}
// pm2 delete www15;pm2 start server.js --name "www15" -- www15;pm2 log --lines 200 www15
/*
curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN:EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-" \
-d "grant_type=client_credentials"
*/

View File

@@ -0,0 +1,27 @@
import { createRequire } from 'module';
import path from 'path';
import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const fs = require('fs');
const mypath = path.join(__dirname, '../../../../../../../../system/db/.env');
require('dotenv').config({ path: mypath })
console.log(process.env.MY_USER);

View File

@@ -0,0 +1,101 @@
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
type="text/css"
href="https://www.paypalobjects.com/webstatic/en_US/developer/docs/css/cardfields.css"
/>
<script
src="https://www.paypal.com/sdk/js?components=buttons,hosted-fields&client-id=<%= clientId %>"
data-client-token="<%= clientToken %>"
></script>
</head>
<body>
<div id="paypal-button-container" class="paypal-button-container"></div>
<div class="card_container">
<form id="card-form">
<label for="card-number">Card Number</label>
<div id="card-number" class="card_field"></div>
<div style="display: flex; flex-direction: row;">
<div>
<label for="expiration-date">Expiration Date</label>
<div id="expiration-date" class="card_field"></div>
</div>
<div style="margin-left: 10px;">
<label for="cvv">CVV</label>
<div id="cvv" class="card_field"></div>
</div>
</div>
<label for="card-holder-name">Name on Card</label>
<input
type="text"
id="card-holder-name"
name="card-holder-name"
autocomplete="off"
placeholder="card holder name"
/>
<div>
<label for="card-billing-address-street">Billing Address</label>
<input
type="text"
id="card-billing-address-street"
name="card-billing-address-street"
autocomplete="off"
placeholder="street address"
/>
</div>
<div>
<label for="card-billing-address-unit">&nbsp;</label>
<input
type="text"
id="card-billing-address-unit"
name="card-billing-address-unit"
autocomplete="off"
placeholder="unit"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-city"
name="card-billing-address-city"
autocomplete="off"
placeholder="city"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-state"
name="card-billing-address-state"
autocomplete="off"
placeholder="state"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-zip"
name="card-billing-address-zip"
autocomplete="off"
placeholder="zip / postal code"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-country"
name="card-billing-address-country"
autocomplete="off"
placeholder="country code"
/>
</div>
<br /><br />
<button value="submit" id="submit" class="btn">Pay</button>
</form>
</div>
<script src="app.js"></script>
</body>
</html>

View File

@@ -0,0 +1,2 @@
CLIENT_ID=<FILL_THIS_IN>
APP_SECRET=<FILL_THIS_IN>

View File

@@ -0,0 +1,13 @@
# Standard Integration Example
This folder contains example code for a standard PayPal integration using both the JS SDK and node.js to complete transactions with the PayPal REST API.
## Instructions
1. [Create an application](https://developer.paypal.com/dashboard/applications/sandbox/create)
3. Add your app's `CLIENT_ID` and `APP_SECRET` to the `.env` file
2. Replace `test` in `public/index.html` with your app's client-id
4. Run `npm install`
5. Run `npm start`
6. Open http://localhost:8888
7. Click "PayPal" and log in with one of your [Sandbox test accounts](https://developer.paypal.com/dashboard/accounts).

View File

@@ -0,0 +1,18 @@
{
"name": "@paypalcorp/standard-integration",
"version": "1.0.0",
"main": "paypal-api.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "Apache-2.0",
"description": "",
"dependencies": {
"dotenv": "^16.0.0",
"express": "^4.17.3",
"node-fetch": "^3.2.1"
}
}

View File

@@ -0,0 +1,66 @@
import fetch from "node-fetch";
const { CLIENT_ID, APP_SECRET } = process.env;
const base = "https://api-m.sandbox.paypal.com";
export async function createOrder() {
const accessToken = await generateAccessToken();
const url = `${base}/v2/checkout/orders`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "USD",
value: "100.00",
},
},
],
}),
});
return handleResponse(response);
}
export async function capturePayment(orderId) {
const accessToken = await generateAccessToken();
const url = `${base}/v2/checkout/orders/${orderId}/capture`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
return handleResponse(response);
}
export async function generateAccessToken() {
const auth = Buffer.from(CLIENT_ID + ":" + APP_SECRET).toString("base64");
const response = await fetch(`${base}/v1/oauth2/token`, {
method: "post",
body: "grant_type=client_credentials",
headers: {
Authorization: `Basic ${auth}`,
},
});
const jsonData = await handleResponse(response);
return jsonData.access_token;
}
async function handleResponse(response) {
if (response.status === 200 || response.status === 201) {
return response.json();
}
const errorMessage = await response.text();
throw new Error(errorMessage);
}

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<!-- Replace "test" with your own sandbox Business account app client ID -->
<script src="https://www.paypal.com/sdk/js?client-id=test&currency=USD"></script>
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>
<script>
paypal
.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function () {
return fetch("/api/orders", {
method: "post",
// use the "body" param to optionally pass additional order information
// like product skus and quantities
body: JSON.stringify({
cart: [
{
sku: "<YOUR_PRODUCT_STOCK_KEEPING_UNIT>",
quantity: "<YOUR_PRODUCT_QUANTITY>",
},
],
}),
})
.then((response) => response.json())
.then((order) => order.id);
},
// Finalize the transaction after payer approval
onApprove: function (data) {
return fetch(`/api/orders/${data.orderID}/capture`, {
method: "post",
})
.then((response) => response.json())
.then((orderData) => {
// Successful capture! For dev/demo purposes:
console.log(
"Capture result",
orderData,
JSON.stringify(orderData, null, 2)
);
var transaction =
orderData.purchase_units[0].payments.captures[0];
alert(
"Transaction " +
transaction.status +
": " +
transaction.id +
"\n\nSee console for all available details"
);
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
})
.render("#paypal-button-container");
</script>
</body>
</html>

View File

@@ -0,0 +1,28 @@
import "dotenv/config"; // loads variables from .env file
import express from "express";
import * as paypal from "./paypal-api.js";
const app = express();
app.use(express.static("public"));
app.post("/api/orders", async (req, res) => {
try {
const order = await paypal.createOrder();
res.json(order);
} catch (err) {
res.status(500).send(err.message);
}
});
app.post("/api/orders/:orderID/capture", async (req, res) => {
const { orderID } = req.params;
try {
const captureData = await paypal.capturePayment(orderID);
res.json(captureData);
} catch (err) {
res.status(500).send(err.message);
}
});
app.listen(8888);

View File

@@ -0,0 +1,23 @@
{
"name": "@paypalcorp/advanced-integration",
"version": "1.0.0",
"description": "",
"main": "server.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"start2": "node server2.js"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"dotenv": "^16.0.0",
"ejs": "^3.1.6",
"express": "^4.17.3",
"html-entities": "^2.4.0",
"mysql": "^2.18.1",
"mysql2": "^3.6.3",
"node-fetch": "^3.2.1"
}
}

View File

@@ -0,0 +1,123 @@
import fetch from "node-fetch";
// set some important variables
const { CLIENT_ID, APP_SECRET } = process.env;
const base = "https://api-m.sandbox.paypal.com";
// call the create order method
export async function createOrder(data,PaypalClientId,PaypalAppSecret) {
const purchaseAmount = data.price;//"100.00"; // TODO: pull prices from a database
const accessToken = await generateAccessToken(PaypalClientId,PaypalAppSecret);
const url = `${base}/v2/checkout/orders`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "USD",
value: purchaseAmount,
},
},
],
}),
});
return handleResponse(response);
}
// capture payment for an order
export async function capturePayment(orderId,PaypalClientId,PaypalAppSecret) {
const accessToken = await generateAccessToken(PaypalClientId,PaypalAppSecret);
const url = `${base}/v2/checkout/orders/${orderId}/capture`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
return handleResponse(response);
}
// generate access token
export async function generateAccessToken(PaypalClientId,PaypalAppSecret) {
console.log(PaypalClientId + ":" + PaypalAppSecret);
const auth = Buffer.from(PaypalClientId + ":" + PaypalAppSecret).toString("base64");
console.log(auth);
const response = await fetch(`${base}/v1/oauth2/token`, {
method: "post",
body: "grant_type=client_credentials",
headers: {
Authorization: `Basic ${auth}`,
},
});
const jsonData = await handleResponse(response);
return jsonData.access_token;
}
// generate client token
export async function generateClientToken(PaypalClientId,PaypalAppSecret) {
const accessToken = await generateAccessToken(PaypalClientId,PaypalAppSecret);
const response = await fetch(`${base}/v1/identity/generate-token`, {
method: "post",
headers: {
Authorization: `Bearer ${accessToken}`,
"Accept-Language": "en_US",
"Content-Type": "application/json",
},
});
console.log('response', response.status)
const jsonData = await handleResponse(response);
return jsonData.client_token;
}
async function handleResponse(response) {
if (response.status === 200 || response.status === 201) {
return response.json();
}
const errorMessage = await response.text();
throw new Error(errorMessage);
}
// capture payment for an order
export async function refundPayment(orderId) {
const accessToken = await generateAccessToken();
const url = `${base}/v2/payments/captures/${capture_id}/refund`;
const response = await fetch(url, {
method: "post",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${accessToken}`,
'PayPal-Request-Id': '123e4567-e89b-12d3-a456-426655440020',
'Prefer': 'return=representation'
},
body: JSON.stringify(
{
"amount": { "value": "10.00", "currency_code": "USD" },
"invoice_id": "INVOICE-123",
"note_to_payer": "DefectiveProduct",
"payment_instruction": {
"platform_fees": [
{
"amount": {
"currency_code": "USD",
"value": "1.00"
}
}
]
}
})
});
return handleResponse(response);
}

View File

@@ -0,0 +1,160 @@
paypal
.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function () {
return fetch("/api/orders", {
method: "post",
// use the "body" param to optionally pass additional order information
// like product skus and quantities
body: JSON.stringify({
cart: [
{
sku: "<YOUR_PRODUCT_STOCK_KEEPING_UNIT>",
quantity: "<YOUR_PRODUCT_QUANTITY>",
},
],
}),
})
.then((response) => response.json())
.then((order) => order.id);
},
// Finalize the transaction after payer approval
onApprove: function (data) {
return fetch(`/api/orders/${data.orderID}/capture`, {
method: "post",
})
.then((response) => response.json())
.then((orderData) => {
// Successful capture! For dev/demo purposes:
console.log(
"Capture result",
orderData,
JSON.stringify(orderData, null, 2)
);
const transaction = orderData.purchase_units[0].payments.captures[0];
alert(`Transaction ${transaction.status}: ${transaction.id}
See console for all available details
`);
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
})
.render("#paypal-button-container");
// If this returns false or the card fields aren't visible, see Step #1.
if (paypal.HostedFields.isEligible()) {
let orderId;
// Renders card fields
paypal.HostedFields.render({
// Call your server to set up the transaction
createOrder: () => {
return fetch("/api/orders", {
method: "post",
// use the "body" param to optionally pass additional order information
// like product skus and quantities
body: JSON.stringify({
cart: [
{
sku: "<YOUR_PRODUCT_STOCK_KEEPING_UNIT>",
quantity: "<YOUR_PRODUCT_QUANTITY>",
},
],
}),
})
.then((res) => res.json())
.then((orderData) => {
orderId = orderData.id; // needed later to complete capture
return orderData.id;
});
},
styles: {
".valid": {
color: "green",
},
".invalid": {
color: "red",
},
},
fields: {
number: {
selector: "#card-number",
placeholder: "4111 1111 1111 1111",
},
cvv: {
selector: "#cvv",
placeholder: "123",
},
expirationDate: {
selector: "#expiration-date",
placeholder: "MM/YY",
},
},
}).then((cardFields) => {
document.querySelector("#card-form").addEventListener("submit", (event) => {
event.preventDefault();
cardFields
.submit({
// Cardholder's first and last name
cardholderName: document.getElementById("card-holder-name").value,
// Billing Address
billingAddress: {
// Street address, line 1
streetAddress: document.getElementById(
"card-billing-address-street"
).value,
// Street address, line 2 (Ex: Unit, Apartment, etc.)
extendedAddress: document.getElementById(
"card-billing-address-unit"
).value,
// State
region: document.getElementById("card-billing-address-state").value,
// City
locality: document.getElementById("card-billing-address-city")
.value,
// Postal Code
postalCode: document.getElementById("card-billing-address-zip")
.value,
// Country Code
countryCodeAlpha2: document.getElementById(
"card-billing-address-country"
).value,
},
})
.then(() => {
fetch(`/api/orders/${orderId}/capture`, {
method: "post",
})
.then((res) => res.json())
.then((orderData) => {
// Two cases to handle:
// (1) Other non-recoverable errors -> Show a failure message
// (2) Successful transaction -> Show confirmation or thank you
// This example reads a v2/checkout/orders capture response, propagated from the server
// You could use a different API or structure for your 'orderData'
const errorDetail =
Array.isArray(orderData.details) && orderData.details[0];
if (errorDetail) {
var msg = "Sorry, your transaction could not be processed.";
if (errorDetail.description)
msg += "\n\n" + errorDetail.description;
if (orderData.debug_id) msg += " (" + orderData.debug_id + ")";
return alert(msg); // Show a failure message
}
// Show a success message or redirect
alert("Transaction completed!");
});
})
.catch((err) => {
alert("Payment could not be captured! " + JSON.stringify(err));
});
});
});
} else {
// Hides card fields if the merchant isn't eligible
document.querySelector("#card-form").style = "display: none";
}

View File

@@ -0,0 +1,184 @@
import { createRequire } from 'module';
import path from 'path';
import { fileURLToPath } from 'url';
import {encode} from 'html-entities';
import {decode} from 'html-entities';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const fs = require('fs');
const mypath = path.join(__dirname, '../../system/db/.env');
require('dotenv').config({ path: mypath })
console.log(mypath);
//import "dotenv/config";
import express from "express";
// import fs from "fs";
import http from "http";
import https from "https";
import * as paypal from "./paypal-api.js";
var mysql = require('mysql2');
//
// /home/cradle2careertxxyz/websites/www15/portal/dashboard/services/paypal/node/advanced-integration/
// cd /home/cradle2careertxxyz/websites/www15/portal/dashboard/services/node/paypal/server.js
// pm2 start
// pm2 start server.js --name "www15" -- www15
// pm2 start server.js --name "www10" -- www10
// pm2 delete www15;pm2 start server.js --name "www15" -- www15;pm2 logs www15 --lines 1000
// pm2 delete www10;pm2 start server.js --name "www10" -- www10;pm2 logs www10 --lines 1000
//process.argv.forEach(function (val, index, array) {console.log(index + ': ' + val);});
const subdomain = process.argv[2];
// var con = mysql.createConnection({
// host: "localhost",
// user: "cradle2careertxxyz",
// password: "MYblessings1984!",
// database: "cradle2careertxxyzdb",
// insecureAuth : true
// });
var con = mysql.createConnection({
host: process.env.MY_HOSTNAME,
user: process.env.MY_USER,
password: process.env.MY_PASSWORD,
database: process.env.MY_DATABASE,
insecureAuth : true
});
// console.log(process.env.MY_HOSTNAME);
// console.log(process.env.MY_USER);
// console.log(process.env.MY_PASSWORD);
// console.log(process.env.MY_DATABASE);
function decodeHTMLEntities(text) {
var textArea = document.createElement('textarea');
textArea.innerHTML = text;
return textArea.value;
}
con.connect(function(err) {
if (err) throw err;
con.query(`SELECT * FROM subdomain_properties WHERE SubDomain = '${subdomain}'`, function (err, results) {
if (err) throw err;
if(results.length > 0){
var obj = {};
for(var i=0; i < results.length; i++){
console.log(results[i].SubDomain + " : " + results[i].PropertyName + " : " + results[i].PropertyValue);
obj[results[i].PropertyName] = results[i].PropertyValue;
}
con.query(`SELECT * FROM configurations WHERE category = 'paypal'`, function (err, results2) {
console.log("")
console.log(results2[0]);
// console.log(decode(results2[0].json));
let paypal_config = null;
for(let v=0; v < results2.length; v++){
let me = JSON.parse(decode(results2[v].json));
if(me.active==true){
paypal_config = me;
break;
}
}
con.end();
run({
...obj,
...paypal_config
});
});
}else{
console.log(`Error starting server! No port number found for subdomain ${subdomain}`);
}
});
});
// con.connect(function(err) {
// if (err) throw err;
// con.query(`SELECT * FROM managed_domain WHERE SubDomain = '${subdomain}'`, function (err, result) {
// if (err) throw err;
// con.end();
// if(result.length > 0){
// console.log(result[0])
// run(result[0]);
// }else{
// console.log(`Error starting server! No port number found for subdomain ${subdomain}`);
// }
// });
// });
function run(opts){
console.log("Starting Paypal Server on port: " + opts.service_port);
console.log(opts);
var privateKey = fs.readFileSync(opts.CertPrivateKeyLocation, 'utf8');
var certificate = fs.readFileSync(opts.CertPublicKeyLocation, 'utf8');
var credentials = {key: privateKey, cert: certificate};
var app = express();
// render checkout page with client id & unique client token
app.get("/"+opts.service_end_point, async (req, res) => {
var clientId = process.env.CLIENT_ID;
if(opts.client_id!=undefined){
clientId = opts.client_id;
}
try {
//console.log("starting...");
if(req.query.type=="generate_token"){
console.log("Generating token...");
const clientToken = await paypal.generateClientToken(opts.client_id, opts.client_secret);
res.jsonp(JSON.stringify({clientToken:clientToken,clientId:clientId}));
}else if(req.query.type=="create_order"){
console.log(req.query.data)
var data = JSON.parse( req.query.data );
const order = await paypal.createOrder(data,opts.client_id, opts.client_secret);
res.jsonp(order);
}else if(req.query.type=="capture_order"){
const orderID = req.query.orderID;
const captureData = await paypal.capturePayment(orderID,opts.client_id, opts.client_secret);
res.jsonp(captureData);
}else if(req.query.type=="refund"){
const orderID = req.query.orderID;
const captureData = await paypal.refundPayment(orderID);
res.jsonp(captureData);
}
} catch (err) {
console.log(err.message)
res.jsonp(err.message);
}
});
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
//httpServer.listen(9888);
httpsServer.listen(opts.service_port);
}
// pm2 delete www15;pm2 start server.js --name "www15" -- www15;pm2 log --lines 200 www15
/*
curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN:EIMOBpKnMGNlgaofARDgpuigkvpoSilNUJQSXSmXhNRwxrVosOVp1DCpb7Ky2OfjX7rR0SqszgRMyg1-" \
-d "grant_type=client_credentials"
*/

View File

@@ -0,0 +1,27 @@
import { createRequire } from 'module';
import path from 'path';
import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const fs = require('fs');
const mypath = path.join(__dirname, '../../../../../../../../system/db/.env');
require('dotenv').config({ path: mypath })
console.log(process.env.MY_USER);

View File

@@ -0,0 +1,33 @@
auth-algo: SHA256withRSA
User-Agent: PayPal/AUHD-214.0-58228326
cert-url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
auth-version: v2
transmission-sig: eSf8SgTvCEuA3nHvF1HzdZnhrziTn7VDPD81GcelQiz5jsgmFc+g6iWe7tfr7kuiTkGEw9XT0URy6CFautYRd9Biim3kI6Na/7N11jF5LzTCW3GeRrCpXCXZwXbpSe9PTfCfeXdcroCe/ZQolBx+LSdZCp5Fh5YdzyrwMAj6GqxOE74dt0TdYqjwuCxhzoLOB5rfNMmww4+bynEtKeq9RGqwptROm9ihXqrwDWmup81VGAjLSR6ClveyZM04+y46rQaaYlKxAJ921YMbQ7ObglrsRQqTfnSWzfdpNDfbagFPcrRgDI7CUbNIa7QYdD7Hxwtic+OKp809XC1xKiK8wg==
transmission-time: 2023-12-07T22:26:32Z
transmission-id: ac6eed90-954f-11ee-8fb1-61968daa6bf5
{
"id": "WH-6W4482673W002281V-61985753LP2332451",
"create_time": "2018-19-12T22:20:32.000Z",
"event_type": "CHECKOUT.CHECKOUT.BUYER-APPROVED",
"event_version": "1.0",
"resource_type": "payment",
"summary": "Checkout Payment is created and approved by buyer.",
"resource": {
"id": "EC-7JW39463WG7174715",
"payload": "payment_type=instant&payment_date=10%3A46%3A54%20Apr%2028%2C%202019%20PDT&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller@paypalsandbox.com&receiver_email=seller@paypalsandbox.com&receiver_id=seller@paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=274113719&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AmoLQMSQnFNTX4UH11dp7XvPK.4bAfd10dnRIZeo9cONJNn0b9NquIGb"
},
"links": [
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.paypal.com\/v1\/notifications\/webhooks-events\/WH-6W4482673W002281V-61985753LP2332451\/resend",
"rel": "resend",
"method": "POST"
}
]
}

View File

@@ -0,0 +1,101 @@
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
type="text/css"
href="https://www.paypalobjects.com/webstatic/en_US/developer/docs/css/cardfields.css"
/>
<script
src="https://www.paypal.com/sdk/js?components=buttons,hosted-fields&client-id=<%= clientId %>"
data-client-token="<%= clientToken %>"
></script>
</head>
<body>
<div id="paypal-button-container" class="paypal-button-container"></div>
<div class="card_container">
<form id="card-form">
<label for="card-number">Card Number</label>
<div id="card-number" class="card_field"></div>
<div style="display: flex; flex-direction: row;">
<div>
<label for="expiration-date">Expiration Date</label>
<div id="expiration-date" class="card_field"></div>
</div>
<div style="margin-left: 10px;">
<label for="cvv">CVV</label>
<div id="cvv" class="card_field"></div>
</div>
</div>
<label for="card-holder-name">Name on Card</label>
<input
type="text"
id="card-holder-name"
name="card-holder-name"
autocomplete="off"
placeholder="card holder name"
/>
<div>
<label for="card-billing-address-street">Billing Address</label>
<input
type="text"
id="card-billing-address-street"
name="card-billing-address-street"
autocomplete="off"
placeholder="street address"
/>
</div>
<div>
<label for="card-billing-address-unit">&nbsp;</label>
<input
type="text"
id="card-billing-address-unit"
name="card-billing-address-unit"
autocomplete="off"
placeholder="unit"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-city"
name="card-billing-address-city"
autocomplete="off"
placeholder="city"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-state"
name="card-billing-address-state"
autocomplete="off"
placeholder="state"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-zip"
name="card-billing-address-zip"
autocomplete="off"
placeholder="zip / postal code"
/>
</div>
<div>
<input
type="text"
id="card-billing-address-country"
name="card-billing-address-country"
autocomplete="off"
placeholder="country code"
/>
</div>
<br /><br />
<button value="submit" id="submit" class="btn">Pay</button>
</form>
</div>
<script src="app.js"></script>
</body>
</html>

View File

@@ -0,0 +1,230 @@
<?php
require dirname( __DIR__, 2 ) . "/core/api/php/includes/include.php";
// https://www15.cradle2careertx.org/portal/admin/services/paypal/webhooks.php?webhook=true
function __paypal_service_request($requestUrl){
$body = array("access" => true);
// $requestUrl = "https://www15.cradle2careertx.org:9302/webhook_events_listener";
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'GET',
'content' => http_build_query($body)
),
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$context = stream_context_create($options);
$result = file_get_contents($requestUrl, false, $context);
if ($result === FALSE) {
$result = array("status" => "failure");
}else{
}
return $result;
}
// https://www15.cradle2careertx.org/core/php/request.php?webhook_request=true
// https://www15.cradle2careertx.org/portal/admin/services/paypal/webhooks.php?webhook=true
// https://www15.cradle2careertx.org/portal/admin/core/api/php/request.php?webhook_request=true
function webhook_request2(){
// $obj = array(
// // The ID of the webhook as configured in your Developer Portal account.
// webhook_id: "",
// "transmission_id": req.get('PAYPAL-TRANSMISSION-ID'),
// "transmission_time": req.get('PAYPAL-TRANSMISSION-TIME'),
// "transmission_sig": req.get('PAYPAL-TRANSMISSION-SIG'),
// cert_url: req.get('PAYPAL-CERT-URL'),
// auth_algo: req.get('PAYPAL-AUTH-ALGO'),
// );
// appID: AppfactoryStudio
// james_api1.appfactory.studio
// TVFHPK2R9225PCKT
// AwMds0NH2m8vEgPRSgphoR2TvaTYA.BubSLgZ.Td5GLrpFKL5P52AKlh
// webhooks details
// app_name: mywebhooks
// ClientId
// Aa-hUI-QfmPnt7vNwhqkoSdjE0UuK0wFe-neDJiuIfnOEXhGl-Fx8Qf1hxaDqxsw_JS5ta6ew2boAoTR
// Secret key 1:
// EBaL2WenKH5x028AK_WukCFOzvwRaOtIgTgVSlN44xBRwKcvCYYr0cT4JOTDQK1CVlaJ-QM_b-d_bMYu
// personal sandbox account
// https://sandbox.paypal.com
// sb-yevcv28400344@personal.example.com
// iTAp#!7n
// NVP/SOAP Sandbox API credentials
// business sandbox account
// sb-f4g6728386181@business.example.com
// |Fq@)H8o
// sb-f4g6728386181_api1.business.example.com
// NV9LPHSYD6HBDLE2
// Signature:
// AmOqcCijq4H.wz5KnnQf9r6HqN6SAK-9G5nx1QsCR835E-mx5Tx0khAc
// IPN
// API Username: esb-f4g6728386181_api1.business.example.com
// API Password: NV9LPHSYD6HBDLE2
// Signature: AmOqcCijq4H.wz5KnnQf9r6HqN6SAK-9G5nx1QsCR835E-mx5Tx0khAc
// headers
/*
Content-Length: 1473
X-B3-Spanid: 85daf04c3165688
Correlation-Id: 06e9f90c0a87b
User-Agent: PayPal/AUHD-214.0-58228326
Content-Type: application/json
Paypal-Auth-Algo: SHA256withRSA
Paypal-Cert-Url: https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-ad47cb8d
Paypal-Auth-Version: v2
Paypal-Transmission-Sig: hCZ2QkwDIwsX80KYD+jE4IrvZ8UFQixhj0ZQ0Hku1VQZ/U9Sm/Mz1eqIScKXtr9dHC6TrbpGyRIFAWKzrMKscoZp/u8DLgsQ9k1IJ/KzxXlqW4WJFG8AV8FietHUAgS6WezOoWuL8H3Zpe9MTGjrzKYQDQBV/swKITXBIwQ4ngCv0T9LTuxfn46iJtdh7XIsswyTsZVoqrwU6ebJn6hl7N9JgOuw3Prhf8DrJMR4UhxRG05fFVydGOoYA7UjXtkUv9+cg5SXwRmtN6sEUJVzF8PVBtsUZ4/LmlKBbFmBDpVlXI+H0P+p0whnkEpjbUi6Zd1GyNbARUb3TrzFiY6U2Q==
Paypal-Transmission-Time: 2023-12-07T15:53:48Z
Paypal-Transmission-Id: cf0e7910-9518-11ee-8c10-01aae997541f
Accept:
Host: www15.cradle2careertx.org
*/
// body
/*
{
"id": "WH-6W4482673W002281V-61985753LP2332451",
"create_time": "2018-19-12T22:20:32.000Z",
"resource_type": "payment",
"event_type": "CHECKOUT.CHECKOUT.BUYER-APPROVED",
"summary": "Checkout Payment is created and approved by buyer.",
"resource": {
"payload": "payment_type=instant&payment_date=10%3A46%3A54%20Apr%2028%2C%202019%20PDT&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller@paypalsandbox.com&receiver_email=seller@paypalsandbox.com&receiver_id=seller@paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=274113719&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AmoLQMSQnFNTX4UH11dp7XvPK.4bAfd10dnRIZeo9cONJNn0b9NquIGb",
"id": "EC-7JW39463WG7174715"
},
"links": [
{
"href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-6W4482673W002281V-61985753LP2332451",
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-6W4482673W002281V-61985753LP2332451/resend",
"rel": "resend",
"method": "POST",
"encType": "application/json"
}
],
"event_version": "1.0"
}
*/
// $result = __paypal_service_request("https://www15.cradle2careertx.org:9302/webhook_events_listener");
// nnnnn
$str = "";
foreach (getallheaders() as $name => $value) {
$str .= "$name: $value\n";
}
file_put_contents(__DIR__ . "/testing123.tx", $str);
}
// https://www15.cradle2careertx.org/portal/admin/services/paypal/webhooks.php?webhook=true
if(Input::get("webhook")){
// webhooks details
// app_name: mywebhooks
// webhook_id: 2XA78019KT678284E
// ClientId
// Aa-hUI-QfmPnt7vNwhqkoSdjE0UuK0wFe-neDJiuIfnOEXhGl-Fx8Qf1hxaDqxsw_JS5ta6ew2boAoTR
// Secret key 1:
// EBaL2WenKH5x028AK_WukCFOzvwRaOtIgTgVSlN44xBRwKcvCYYr0cT4JOTDQK1CVlaJ-QM_b-d_bMYu
$X_B3_SPANID = $_SERVER['HTTP_X_B3_SPANID'];
$CORRELATIONS_Id = $_SERVER['HTTP_CORRELATIONS_Id'];
$CONTENT_TYPE = $_SERVER['HTTP_CONTENT_TYPE'];
$USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$PAYPAL_AUTH_ALGO = $_SERVER['HTTP_PAYPAL_AUTH_ALGO'];
$PAYPAL_Cert_Url = $_SERVER['HTTP_PAYPAL_CERT_URL'];
$PAYPAL_Auth_Version = $_SERVER['HTTP_PAYPAL_AUTH_VERSION'];
$PAYPAL_TRANSMISSION_SIG = $_SERVER['HTTP_PAYPAL_TRANSMISSION_SIG'];
$PAYPAL_TRANSMISSION_TIME = $_SERVER['HTTP_PAYPAL_TRANSMISSION_TIME'];
$PAYPAL_TRANSMISSION_ID = $_SERVER['HTTP_PAYPAL_TRANSMISSION_ID'];
$str = "";
foreach (getallheaders() as $name => $value) {
$str .= "$name: $value\n";
}
$body = "\n\n\n";
$body .= "" . $str . "\n\n\n";
$body .= "auth-algo: " . $PAYPAL_AUTH_ALGO . "\n";
$body .= "User-Agent: " . $USER_AGENT . "\n";
$body .= "cert-url: " . $PAYPAL_Cert_Url . "\n";
$body .= "auth-version: " . $PAYPAL_Auth_Version . "\n";
$body .= "transmission-sig: " . $PAYPAL_TRANSMISSION_SIG . "\n";
$body .= "transmission-time: " . $PAYPAL_TRANSMISSION_TIME . "\n";
$body .= "transmission-id: " . $PAYPAL_TRANSMISSION_ID . "\n\n\n";
$body .= json_encode(json_decode(file_get_contents('php://input')), JSON_PRETTY_PRINT);
file_put_contents(__DIR__ . "/mytesting59.txt", $body);
}
if(Input::get("webhook2")){
$payment = __get_main_configurations();
$obj = null;
for($i=0; $i < count($payment["configurations"]["payments"]); $i++){
//echo '</pre>';var_dump($payment["configurations"]["payments"][$i]);echo '</pre>';
if($payment["configurations"]["payments"][$i]["json"]["active"]){
$obj = $payment["configurations"]["payments"][$i];
break;
}
}
echo $obj["json"]["client_id"];// json_encode($payment["configurations"]);
echo "<br>";
echo $payment["managed_domain"]["Address"];
// echo gettype($payment["configurations"][0]);
// echo "<br><br><br><br><br>";
// echo '</pre>';
// var_dump($payment["configurations"][0]);
// echo '</pre>';
}
?>