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

fix(payment-service): fix issues in payment service #2139

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1,569 changes: 973 additions & 596 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions services/payment-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ any client application.
- Users can seamlessly integrate PayPal for payment transactions.
- The microservice supports Stripe as a preferred payment gateway option.
- Razorpay integration is also available for users seeking diverse payment methods.

## Installation

```bash
Expand All @@ -41,12 +42,10 @@ npm i @sourceloop/payment-service
- Bind any of the custom [providers](#providers) you need.
- **Using Paypal payment Gateway**
Bind the PayPalHelper and PayPalConfig as shown below

```typescript
//import Providers
import {
PayPalBindings,
PaypalProvider
} from 'payment-service/dist/providers';
import {PayPalBindings, PaypalProvider} from 'payment-service/dist/providers';
//Bind the providers
this.bind(PayPalBindings.PayPalHelper.key).toProvider(PaypalProvider);
this.bind(PayPalBindings.PayPalConfig).to({
Expand All @@ -56,23 +55,19 @@ npm i @sourceloop/payment-service
```

- **Using Stripe payment Gateway**
Bind the StripeHelper and Config as shown below

Bind the StripeHelper and Config as shown below

```typescript
//import Providers
import {
StripeBindings,
StripeProvider,
} from 'payment-service/dist/providers';
import {StripeBindings, StripeProvider} from 'payment-service/dist/providers';
//Bind the providers
this.bind(StripeBindings.Config).to({dataKey: '', publishKey: ''});
this.bind(StripeBindings.StripeHelper).toProvider(StripeProvider);
```

- **Using RazorPay payment Gateway**
Bind the RazorPayHelper and RazorPayConfig as shown below

```typescript
//import Providers
import {
Expand Down Expand Up @@ -183,6 +178,7 @@ JWT_ISSUER=https://authentication.service
| `DB_SCHEMA` | Y | `public` | Database schema used for the data source. In PostgreSQL, this will be `public` unless a schema is made explicitly for the service. |
| `JWT_SECRET` | Y | | Symmetric signing key of the JWT token. |
| `JWT_ISSUER` | Y | | Issuer of the JWT token. |

### Providers

You can find documentation for some of the providers available in this service [here](./src/providers/README.md)
Expand Down Expand Up @@ -217,6 +213,14 @@ copy the credentials to the sandbox account and use them to develop payment-serv

Order creation , capture and refund is supported right now.

The **`place-order-and-pay`** API endpoint allows creating a new order and initiate payment through PayPal. When a request is made, it first creates an order with the given details and saves it to the database.

The create method in it handles the payment process by checking if a payment transaction already exists for the order. If not, it creates a new PayPal order and retrieves a payment link, which is then returned along with the order ID.

The redirect url redirect users to the PayPal checkout page where they can review and complete their payment for a transaction associated with the provided orderId and receive a token or approval link in the response redirecting users to either the `SUCCESS_CALLBACK_URL` for successful payments with token and payerID or the `FAILURE_CALLBACK_URL` for canceled or failed transactions provided in env file.

The **`transactionscharge`** API endpoint processes a payment charge and redirects the user based on the result.Upon receiving a successful response, it updates the order and transaction records to reflect the payment status.

#### API Details

##### POST /payment-gateways
Expand All @@ -227,6 +231,10 @@ Create a payment gateway.

Create an order and initiate transaction for the selected payment gateway, this will create order and initiate payment process.

##### POST /transactions/charge

The transactionscharge endpoint handles incoming charge requests. It extracts the order ID from the request, calls the charge helper method of selected payment gateway,and redirects the user to a success or failure URL based on the charge outcome.

##### POST /orders

Creating orders manually.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
CREATE SCHEMA IF NOT EXISTS main;

CREATE TABLE main.paymentgateways (
id uuid NOT NULL ,
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL,
name varchar NOT NULL ,
gateway_type varchar NOT NULL ,
enabled boolean NOT NULL ,
CONSTRAINT paymentgateways_pkey PRIMARY KEY ( id )
);

CREATE TABLE main.templates (
id uuid NOT NULL ,
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL,
payment_gateway_id uuid NOT NULL ,
name varchar NOT NULL ,
"template" text NOT NULL ,
Expand All @@ -18,7 +18,7 @@ CREATE TABLE main.templates (
);

CREATE TABLE main.orders (
id uuid NOT NULL ,
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL,
totalamount numeric NOT NULL ,
status varchar(100) NOT NULL ,
paymentmethod varchar(100) ,
Expand All @@ -29,7 +29,7 @@ CREATE TABLE main.orders (
);

CREATE TABLE main.transactions (
id uuid NOT NULL ,
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL,
amount_paid numeric NOT NULL ,
status varchar(100) ,
order_id uuid NOT NULL ,
Expand All @@ -41,7 +41,7 @@ CREATE TABLE main.transactions (
);

CREATE TABLE main.subscriptions (
id uuid NOT NULL ,
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL,
currency varchar ,
status varchar ,
payment_gateway_id uuid ,
Expand Down
Loading
Loading