-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from flickmatch/phonepe-integration
Complete logic to initiate payment
- Loading branch information
Showing
17 changed files
with
309 additions
and
80 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
platform/src/main/java/com/flickmatch/platform/bean/confugration/ProxyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.flickmatch.platform.bean.confugration; | ||
|
||
import com.phonepe.sdk.pg.Env; | ||
import com.phonepe.sdk.pg.payments.v1.PhonePePaymentClient; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class ProxyConfiguration { | ||
|
||
@Value("${phonepe.merchant.id}") | ||
private String merchantId; | ||
@Value("${phonepe.saltkey}") | ||
private String saltKey; | ||
@Value("${phonepe.saltkey.index}") | ||
private Integer saltIndex; | ||
|
||
@Bean | ||
PhonePePaymentClient phonePePaymentClient() { | ||
return new PhonePePaymentClient(merchantId, saltKey, saltIndex, Env.PROD, true); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
platform/src/main/java/com/flickmatch/platform/dynamodb/model/PaymentRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.flickmatch.platform.dynamodb.model; | ||
|
||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@DynamoDBTable(tableName="PaymentRequest") | ||
@Builder | ||
@AllArgsConstructor | ||
public class PaymentRequest { | ||
|
||
private String merchantTransactionId; | ||
private String uniqueEventId; | ||
private List<Event.PlayerDetails> playerDetailsList; | ||
/* | ||
status values can be INITIATED, PAID, FAILED | ||
*/ | ||
private String status; | ||
|
||
@DynamoDBHashKey(attributeName="merchantTransactionId") | ||
public String getMerchantTransactionId() { | ||
return merchantTransactionId; | ||
} | ||
|
||
public void setMerchantTransactionId(String merchantTransactionId) { | ||
this.merchantTransactionId = merchantTransactionId; | ||
} | ||
|
||
@DynamoDBAttribute(attributeName="uniqueEventId") | ||
public String getUniqueEventId() { | ||
return uniqueEventId; | ||
} | ||
|
||
public void setUniqueEventId(String uniqueEventId) { | ||
this.uniqueEventId = uniqueEventId; | ||
} | ||
|
||
@DynamoDBAttribute(attributeName="playerDetailsList") | ||
public List<Event.PlayerDetails> getPlayerDetailsList() { | ||
return playerDetailsList; | ||
} | ||
|
||
public void setPlayerDetailsList(List<Event.PlayerDetails> playerDetailsList) { | ||
this.playerDetailsList = playerDetailsList; | ||
} | ||
|
||
@DynamoDBAttribute(attributeName="status") | ||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...m/src/main/java/com/flickmatch/platform/dynamodb/repository/PaymentRequestRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.flickmatch.platform.dynamodb.repository; | ||
|
||
import com.flickmatch.platform.dynamodb.model.PaymentRequest; | ||
import org.socialsignin.spring.data.dynamodb.repository.EnableScan; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
@EnableScan | ||
public interface PaymentRequestRepository extends CrudRepository<PaymentRequest, String> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
platform/src/main/java/com/flickmatch/platform/graphql/builder/PaymentRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.flickmatch.platform.graphql.builder; | ||
|
||
import com.flickmatch.platform.dynamodb.model.Event; | ||
import com.flickmatch.platform.dynamodb.model.PaymentRequest; | ||
import com.flickmatch.platform.dynamodb.repository.PaymentRequestRepository; | ||
import com.flickmatch.platform.graphql.input.PlayerInput; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class PaymentRequestBuilder { | ||
|
||
@Autowired | ||
private PaymentRequestRepository paymentRequestRepository; | ||
|
||
public PaymentRequest createPaymentRequest(final String merchantTransactionId, | ||
final String uniqueEventId, | ||
final List<PlayerInput> playerInputList) { | ||
List<Event.PlayerDetails> playerDetailsList = playerInputList.stream() | ||
.map(playerInput -> Event.PlayerDetails.builder() | ||
.name(playerInput.getName()) | ||
.waNumber(playerInput.getWaNumber()) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
PaymentRequest paymentRequest = PaymentRequest.builder() | ||
.merchantTransactionId(merchantTransactionId) | ||
.uniqueEventId(uniqueEventId) | ||
.playerDetailsList(playerDetailsList) | ||
.status("INITIATED") | ||
.build(); | ||
return paymentRequestRepository.save(paymentRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.