Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update xcheckout #6

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "react"],
"rules": {}
}
20 changes: 20 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on:
push:
branches:
- "**"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.x

- run: pnpm install
- run: pnpm run format && pnpm run build
31 changes: 31 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish
on:
workflow_run:
workflows: [CI]
branches: [main]
types: [completed]

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write

jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'

- run: pnpm install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ typings/
.code


bun.lockb
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
deploy:
@npm run build
@npm publish --access public

format:
npm run format

lint:
npm run lint
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,29 @@ yarn add react-korba-payment

```javascript
import React from 'react';
import {useXCheckout} from 'react-korba-payment';
import { useXCheckout } from 'react-korba-payment';

function App() {
const {handleXCheckoutClick} = useXCheckout({
config: {
merchantID: '<your_merchant_id>',
orderID: '<unique_order_id>',
description: 'Ordered goods',
amount: 1.2,
redirectURL: 'http://www.yourawesomeapp.com',
},
scriptSrc: 'https://paywithkorba.s3-eu-west-1.amazonaws.com/test-checkout.js',
const {pay} = useXCheckout({
scriptSrc: 'https://paywithkorba.s3-eu-west-1.amazonaws.com/test-checkout.js', // replace with your XCheckout script URL
});

return (
<div className="flex items-center justify-center h-screen">
<button onClick={handleXCheckoutClick} className="bg-blue-500 text-white px-4 py-2">
<button
onClick={() => {
pay({
merchantID: '<your_merchant_id>',
orderID: '<unique_order_id>',
description: 'Ordered goods',
amount: 1.2, // in GH₵
redirectURL: 'http://www.yourawesomeapp.com',
});
}}
className="button"
>
Pay Now!
</button>
</div>
);
}

export default App;
```
Expand All @@ -62,28 +63,30 @@ Next.js 13 introduces a new app/ directory folder structure. By default it uses
```javascript
'use client';
import React from 'react';
import {useXCheckout} from 'react-korba-payment';

function CheckoutButton() {
const {handleXCheckoutClick} = useXCheckout({
config: {
merchantID: '<your_merchant_id>',
orderID: '<unique_order_id>',
description: 'Ordered goods',
amount: 1.2,
redirectURL: 'http://www.yourawesomeapp.com',
},
scriptSrc: 'https://paywithkorba.s3-eu-west-1.amazonaws.com/test-checkout.js',
import { useXCheckout } from 'react-korba-payment';

export default function CheckoutButton() {
const {pay} = useXCheckout({
scriptSrc: 'https://paywithkorba.s3-eu-west-1.amazonaws.com/test-checkout.js', // replace with your XCheckout script URL
});

return (
<button onClick={handleXCheckoutClick} className="bg-blue-500 text-white px-4 py-2">
<button
onClick={() => {
pay({
merchantID: '<your_merchant_id>',
orderID: '<unique_order_id>',
description: 'Ordered goods',
amount: 1.2, // in GH₵
redirectURL: 'http://www.yourawesomeapp.com',
});
}}
className={styles.button}
>
Pay Now!
</button>
);
}

export default CheckoutButton;
```

Please checkout [Korba Documentation](https://xchange.korba365.com/docs/) for more.
Expand All @@ -103,6 +106,7 @@ If you would like to contribute to React Korba Payment(js),
5. Submit a pull request 😉😉

Don't forget to [follow me on instagram](https://instagram.com/1rutmann)!
Don't forget to [follow me on twitter](https://x.com/tswwws)!

## License

Expand Down
10 changes: 5 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module.exports = {
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
node: 'current',
},
},
],
'@babel/preset-typescript'
]
'@babel/preset-typescript',
],
};
98 changes: 69 additions & 29 deletions dist/index.es.js

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

2 changes: 1 addition & 1 deletion dist/index.es.js.map

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

Loading
Loading