Skip to content

Commit

Permalink
fix(payment-service): fix payment service issues
Browse files Browse the repository at this point in the history
fix payment service issues

BREAKING CHANGE:
Added mandatory authentication and authorization checks to API endpoints

GH-2138
  • Loading branch information
Surbhi-sharma1 committed Aug 19, 2024
1 parent adccfa5 commit 7f318ad
Show file tree
Hide file tree
Showing 12 changed files with 1,342 additions and 652 deletions.
1,569 changes: 973 additions & 596 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 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 @@ -227,6 +223,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
75 changes: 74 additions & 1 deletion services/payment-service/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@
"tags": [
"TransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"302": {
"description": "Order model instance",
Expand All @@ -739,11 +744,12 @@
}
}
},
"description": "\n\n| Permissions |\n| ------- |\n| CreateOrder |\n| 6 |\n",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
"$ref": "#/components/schemas/NewMessage"
}
}
}
Expand All @@ -758,6 +764,11 @@
"tags": [
"SubscriptionTransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Subscription model instance",
Expand All @@ -766,6 +777,7 @@
}
}
},
"description": "\n\n| Permissions |\n| ------- |\n| UpdateTransaction |\n| 20 |\n",
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
Expand Down Expand Up @@ -1445,6 +1457,11 @@
"tags": [
"TransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Transacttion Gateway Request",
Expand All @@ -1453,6 +1470,7 @@
}
}
},
"description": "\n\n| Permissions |\n| ------- |\n| CreateTransaction |\n| 18 |\n",
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
Expand Down Expand Up @@ -1516,6 +1534,11 @@
"tags": [
"TransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "HTML response for payment gateway interface.",
Expand All @@ -1528,6 +1551,7 @@
}
}
},
"description": "\n\n| Permissions |\n| ------- |\n| CreateOrder |\n| 6 |\n",
"parameters": [
{
"name": "id",
Expand All @@ -1548,6 +1572,11 @@
"tags": [
"TransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Refund Object from payment gateway",
Expand Down Expand Up @@ -1576,6 +1605,11 @@
"tags": [
"TransactionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Refund Object from payment gateway",
Expand Down Expand Up @@ -1604,6 +1638,11 @@
"tags": [
"TransactionSubscriptionsController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"302": {
"description": "Array of Transactions model instances",
Expand All @@ -1616,6 +1655,7 @@
}
}
},
"description": "\n\n| Permissions |\n| ------- |\n| UpdateSubscriptions |\n| 4 |\n",
"parameters": [
{
"name": "id",
Expand Down Expand Up @@ -2238,6 +2278,39 @@
"additionalProperties": false,
"x-typescript-type": "Partial<Transactions>"
},
"NewMessage": {
"title": "NewMessage",
"type": "object",
"description": "(tsType: Omit<Orders, 'id'>, schemaOptions: { title: 'NewMessage', exclude: [ 'id' ] })",
"properties": {
"totalAmount": {
"type": "number"
},
"currency": {
"type": "string"
},
"status": {
"type": "string"
},
"paymentGatewayId": {
"type": "string"
},
"paymentmethod": {
"type": "string"
},
"metaData": {
"type": "object"
}
},
"required": [
"totalAmount",
"currency",
"status",
"paymentGatewayId"
],
"additionalProperties": false,
"x-typescript-type": "Omit<Orders, 'id'>"
},
"PaymentGateways": {
"title": "PaymentGateways",
"type": "object",
Expand Down
Loading

0 comments on commit 7f318ad

Please sign in to comment.