https://github.com/shurjopay-plugins/sp-plugin-spring
shurjoPay plugin module for Spring applications
https://github.com/shurjopay-plugins/sp-plugin-spring
java payment-gateway payments shurjomukhi shurjopay spring spring-boot spring-mvc
Last synced: 8 months ago
JSON representation
shurjoPay plugin module for Spring applications
- Host: GitHub
- URL: https://github.com/shurjopay-plugins/sp-plugin-spring
- Owner: shurjopay-plugins
- License: mit
- Created: 2022-10-17T10:25:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-23T12:39:15.000Z (almost 2 years ago)
- Last Synced: 2025-04-01T00:42:42.446Z (9 months ago)
- Topics: java, payment-gateway, payments, shurjomukhi, shurjopay, spring, spring-boot, spring-mvc
- Language: Java
- Homepage:
- Size: 13.1 MB
- Stars: 20
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#  Spring Plugin
Official shurjoPay Spring plugin for merchants or service providers to connect with [**_shurjoPay_**](https://shurjopay.com.bd) Payment Gateway ``` v2.1 ``` developed and maintained by [_**ShurjoMukhi Limited**_](https://shurjomukhi.com.bd).
This plugin can be used with spring application.
Also it makes easy for developers to integrate with shurjoPay ``` v2.1 ``` with calling three methods only:
1. **makePayment**: create and send payment request
1. **verifyPayment**: verify payment status at shurjoPay
1. **paymentStatus**: Check payment details and status
Also reduces many of the things that you had to do manually:
- Handles http request and errors.
- JSON serialization and deserialization.
- Authentication during initiating and verifying of payments.
## Audience
This document is intended for the technical personnel of merchants and service providers who wants to integrate our online payment gateway using spring plugin provided by _**shurjoMukhi Limited**_.
## How to use this shurjoPay plugin
To integrate the shurjoPay Payment Gateway in your spring project do the following tasks sequentially.
#### Step 1: Add dependency into your spring project
**Maven**
```xml
bd.com.shurjomukhi
sp-plugin-spring
0.1.0
```
**Gradle**
```gradle
implementation 'bd.com.shurjomukhi:sp-plugin-spring:0.1.0'
```
> _Attention:_ shurjoMukhi offers [separate plugin](https://github.com/shurjopay-plugins/sp-plugin-java) to integrate with any _Java Application_.
#### Step 2: Add below properties to project yml/properties file (e.g. application.yml, application.properties).
Properties contains four fields ```username, password, shurjopay-api, sp-callback``` to configure shurjoPay. Configure logging using these params ```path``` and ```name.```
```yml
shurjopay:
username:
password:
shurjopay-api: https://sandbox.shurjopayment.com/api
sp-callback: https://sandbox.shurjopayment.com/response
logging:
file:
path: /var/log
name: sp-plugin-spring.log
```
- See and copy this ready [_YML_](https://github.com/shurjopay-plugins/sp-plugin-spring/blob/main/src/test/resources/application-sample.yml) or [_properties_](https://github.com/shurjopay-plugins/sp-plugin-spring/blob/main/src/test/resources/application-sample.properties).
- Add ```logback-classic``` dependency in your application to get log messages generated by this plugin to track shurjoPay errors only (optional).
#### Step 3: After that, you can initiate payment request to shurjoPay using below code example.
```java
// Initialize shurjopay
private @Autowired Shurjopay shurjopay;
// Prepare payment request to initiate payment
PaymentReq request = new PaymentReq();
request.setPrefix("sp");
request.setAmount(10.00);
request.setCustomerOrderId("sp315689");
request.setCurrency("BDT");
request.setCustomerName("Dummy");
request.setCustomerAddress("Dhaka");
request.setCustomerPhone("01766666666");
request.setCustomerCity("Dhaka");
request.setCustomerPostCode("1212");
request.setCustomerEmail("dummy@gmail.com");
// Calls first method to initiate a payment
shurjopay.makePayment(request);
```
- Returns [_POJO_](https://github.com/shurjopay-plugins/sp-plugin-java/blob/main/src/main/java/com/shurjomukhi/model/PaymentRes.java) corresponding this [_JSON_](https://github.com/shurjopay-plugins/sp-plugin-spring/blob/main/src/test/resources/sample-msg/payment-res.json)
#### Step 4: Payment verification can be done after each transaction with shurjopay transaction id.
- Call verify method
```java
shurjopay.verifyPayment(:=spTxnId)
```
- Returns [_POJO_](https://github.com/shurjopay-plugins/sp-plugin-java/blob/develop/src/main/java/com/shurjomukhi/model/VerifiedPayment.java) corresponding this [_JSON_](https://github.com/shurjopay-plugins/sp-plugin-spring/blob/develop/src/test/resources/sample-msg/verification-res.json)
# Want to see shurjoPay in action?
Run the JUnit test to see shurjopay plugin in action. These tests will run on selenium browser and will provide the complete experience. Just download source and run the command ```mvnw.cmd test``` in Windows and ```./mvnw test``` in Linux from plugin root path.
## References
1. [Spring example application](https://github.com/shurjopay-plugins/sp-plugin-usage-examples/tree/main/spring-app-spring-plugin) showing usage of the spring plugin.
2. [Sample applications and projects](https://github.com/shurjopay-plugins/sp-plugin-usage-examples) in many different languages and frameworks showing shurjopay integration.
3. [shurjoPay Postman site](https://documenter.getpostman.com/view/6335853/U16dS8ig) illustrating the request and response flow using the sandbox system.
4. [shurjopay Plugins](https://github.com/shurjopay-plugins) home page on github
## License
This code is under the [MIT open source License](https://github.com/shurjopay-plugins/sp-plugin-spring/blob/develop/LICENSE).
#### Please [contact](https://shurjopay.com.bd/#contacts) with shurjoPay team for more detail!
Copyright ©️2022 Shurjomukhi Limited.