Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning committed Jul 19, 2024
0 parents commit a75558c
Show file tree
Hide file tree
Showing 49 changed files with 904 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Update Changelog"

on:
release:
types: [ published, edited, deleted ]

jobs:
generate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.target_commitish }}

- name: Generate changelog
uses: justbetter/generate-changelogs-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: ${{ github.repository }}

- name: Commit CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Rapidez Riverty

## Requirements

You need to have the [Riverty Magento 2 module](https://docs.riverty.com/bnpl/platforms/magento/magento_2#setup) installed and configured within your Magento 2 installation.

## Installation

```bash
composer require rapidez/riverty
```

## Configuration

In order to let guests check out using Riverty they need to know their Date Of Birth and Gender.
For this a template has been added. You must load this in on your payment page.

```blade
@include('riverty::additional-info')
```

## Views

You can publish the views with:
```bash
php artisan vendor:publish --provider="Rapidez\Riverty\RivertyServiceProvider" --tag=views
```

## Icons

You can publish the icons with:
```bash
php artisan vendor:publish --provider="Rapidez\Riverty\RivertyServiceProvider" --tag=payment-icons
```

## License

GNU General Public License v3. Please see [License File](LICENSE) for more information.
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "rapidez/riverty",
"description": "Rapidez Riverty",
"keywords": [
"rapidez",
"riverty",
"afterpay"
],
"homepage": "https://rapidez.io",
"license": "GPL-3.0",
"authors": [
{
"name": "indy koning",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1|^8.2",
"rapidez/core": "^2.0"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"Rapidez\\Riverty\\RivertyServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Rapidez\\Riverty\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
106 changes: 106 additions & 0 deletions resources/js/eventlisteners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { token } from 'Vendor/rapidez/core/resources/js/stores/useUser'
import { mask } from 'Vendor/rapidez/core/resources/js/stores/useMask'

document.addEventListener('turbo:load', () => {
async function placeOrder() {
if (!token.value && window.app.guestEmail) {
await window.magentoGraphQL(
`mutation setGuestEmailOnCart($cart_id: String!, $email: String!) {
setGuestEmailOnCart(input: {
cart_id: $cart_id
email: $email
}) {
cart {
email
}
}
}`,
{
cart_id: mask.value,
email: window.app.guestEmail
}
)
}

await window.magentoGraphQL(
`mutation setRivertyPaymentMethodOnCart(
$cart_id: String!
$code: String!
$terms_and_conditions: Int!
$customer_dob: String
$customer_gender: Int
$customer_telephone: String
) {
setPaymentMethodOnCart(
input: {
cart_id: $cart_id
payment_method: {
code: $code
afterpay: {
customer_dob: $customer_dob
customer_gender: $customer_gender
customer_telephone: $customer_telephone
terms_and_conditions: $terms_and_conditions
}
}
}
) {
cart {
selected_payment_method {
code
}
}
}
}`,
{
cart_id: mask.value,
code: window.app.checkout.payment_method,
terms_and_conditions: 1,
customer_gender: window.app.custom?.gender ?? window.app.checkout.billing_address?.gender ?? window.app.checkout.shipping_address?.gender,
customer_dob: window.app.custom?.dob ?? window.app.checkout.billing_address?.dob ?? window.app.checkout.shipping_address?.dob ?? window.app.checkout.billing_address?.date_of_birth ?? window.app.checkout.shipping_address?.date_of_birth ?? '1999-11-11',
customer_telephone: window.app.checkout.billing_address?.telephone ?? window.app.checkout.shipping_address?.telephone
}
)

return await window.magentoGraphQL(
`mutation rivertyPlaceOrder($cart_id: String!) {
placeOrder(
input: {
cart_id: $cart_id
}
) {
order {
order_number
}
errors {
code
message
}
}
}`,
{
'cart_id': mask.value
}
).then(response => {
if (response?.data?.placeOrder?.order?.order_number) {
return true;
}

if (response?.data?.placeOrder?.errors) {
response?.data?.placeOrder?.errors?.forEach((error) => Notify(error.message));
}

return false;
})
}

window.app.$on('before-checkout-payment-saved', (data) => {
if (!data.order.payment_method_code.includes('riverty_') && !data.order.payment_method_code.includes('afterpay_')) {
return;
}
window.app.checkout.preventOrder = true
window.app.checkout.doNotGoToTheNextStep = true

placeOrder(data).then(success => success ? window.app.checkout.step = window.app.getCheckoutStep('success') : '');
});
})
6 changes: 6 additions & 0 deletions resources/js/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './eventlisteners'

document.addEventListener('turbo:load', (event) => {
Vue.set(window.app.custom, 'dob', window.app.custom?.dob)
Vue.set(window.app.custom, 'gender', window.app.custom?.gender)
});
15 changes: 15 additions & 0 deletions resources/payment-icons/afterpay_at_direct_debit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a75558c

Please sign in to comment.