Skip to content

Commit

Permalink
Worked on license and added some basic code to initialize checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
EricMcWinNer committed Apr 20, 2023
1 parent 9edd630 commit 8c534cd
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 103 deletions.
51 changes: 51 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
BUSINESS SOURCE LICENSE 1.0

Purpose of this License

This License governs Your use of the Work. This License is intended to allow You to use the Work commercially as permitted by the Licensor under the terms of this License. This License shall be governed by the laws of the State of California, without giving effect to any conflicts of law principles that would require the application of the laws of a different jurisdiction.

Definitions

"Commercial Use" means use of the Work for direct or indirect commercial (including strategic) gain or advantage, including deploying or distributing software that embeds or links to the Work, or a derivative work of it.

"Licensor" means the individual(s) or entity(ies) granting rights under this License.

"Software" means the code or instructions that implement the Work.

"Work" means the material or software distributed by the Licensor under this License, including, but not limited to, source code, object code, documentation, or other material or software that is distributed by the Licensor under this License.

"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.

Grant of Rights

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, non-exclusive, non-sublicensable, royalty-free license to use, reproduce, distribute, and prepare derivative works of the Work.

Restrictions

This License is granted only for Commercial Use of the Work. You may not use, reproduce, distribute, or prepare derivative works of the Work for any other purpose.

You may not use the Work in a way that violates any applicable laws or regulations.

You may not distribute the Work in source code form.

Termination

This License and the rights granted hereunder will terminate immediately upon any breach by You of the terms of this License.

Licensor may terminate this License and the rights granted hereunder at any time without prior notice.

Upon termination of this License, You shall immediately cease all use of the Work and destroy all copies of the Work in your possession.

Disclaimer of Warranty and Limitation of Liability

The Work is provided "as is" and Licensor makes no warranty whatsoever with respect to the Work, including any warranty of merchantability, noninfringement, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specification, or sample.

In no event shall Licensor be liable to You or any other party for any damages whatsoever (including, without limitation, direct, indirect, incidental, special, consequential, or exemplary damages, lost profits, business interruption, loss of business information or any other pecuniary loss) arising out of or relating to the Work, even if Licensor has been advised of the possibility of such damages.

Miscellaneous

This License constitutes the entire agreement between the parties with respect to the Work licensed hereunder.

This License shall be governed by and construed in accordance with the laws of the State of California, without giving effect to any conflicts of law principles that would require the application of the laws of a different jurisdiction.

If any provision of this License is held to be invalid or unenforceable, the remaining provisions shall continue to be valid and enforceable.
42 changes: 36 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const validateCustomer = (customer) => {
};
};

export const AsyncpayCheckout = ({
export const AsyncpayCheckout = async ({
publicKey,
amount,
description,
Expand Down Expand Up @@ -85,6 +85,39 @@ export const AsyncpayCheckout = ({
// Validate the entire customer object and return an object containing the customer object that we'll later spread and send into the URL
customerOBJ = validateCustomer(customer);
}
if (!publicKey) {
throw Error(
"Please provide a public key `publicKey` to the AsyncpayCheckout function."
);
}
// Validate Amount
// Validate the description
// Validate the other potential parameters
// Figure out if (and how) we should use idempotentency

const response = await fetch(
`http://localhost/v1/sdk/initialize-payment-request`,
{
method: "POST",
body: JSON.stringify({
...customerOBJ,
amount: parseFloat(amount),
description,
choose_payment_channel: false,
}),
headers: {
Authentication: `Bearer ${publicKey}`,
"Content-Type": "application/json",
},
}
);
const body = await response.json();
if (!response.ok) {
throw Error(`Error-Code: ${body.error_code} - ` + body.error_description);
} else {
}
console.log(response);

const checkoutIframeWrapper = document.createElement("div");
checkoutIframeWrapper.id = "asyncpay-checkout-wrapper";
checkoutIframeWrapper.style.position = "fixed";
Expand All @@ -96,14 +129,11 @@ export const AsyncpayCheckout = ({
checkoutIframeWrapper.style.border = "none";
checkoutIframeWrapper.style.background = "transparent";
const iframe = document.createElement("iframe");
iframe.src =
"http://localhost:5173/checkout/6a43116ff59c1065c435c87f10977191298c";
iframe.src = body.data.action;
iframe.width = "100%";
iframe.height = "100%";
iframe.style.border = "none";
iframe.onload = () => {
alert("Dancing in the sunlight");
};
iframe.onload = () => {};
checkoutIframeWrapper.appendChild(iframe);
document.body.appendChild(checkoutIframeWrapper);

Expand Down
93 changes: 0 additions & 93 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "asyncpay-checkout-sdk",
"name": "@asyncpay/checkout",
"version": "0.0.0",
"description": "JavaScript SDK for running the Asyncpay checkout flow",
"main": "index.js",
Expand All @@ -16,8 +16,5 @@
"license": "BSL-1.0",
"devDependencies": {
"prettier": "^2.8.7"
},
"dependencies": {
"axios": "^1.3.5"
}
}

0 comments on commit 8c534cd

Please sign in to comment.