Skip to content

Commit

Permalink
feat: add API to request list of payments (#17)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: kody-joao <[email protected]>
  • Loading branch information
afabris-kodypay and kody-joao authored Jul 4, 2024
1 parent da22939 commit a79ca18
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release
on:
push:
tags:
- 'v*'
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
dispatch:
Expand Down
58 changes: 55 additions & 3 deletions src/main/proto/com/kodypay/grpc/ecom/v1/ecom.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ option java_multiple_files = true;
option java_outer_classname = "KodyEcomPaymentsProto";
option java_package = "com.kodypay.grpc.ecom.v1";
import "google/protobuf/timestamp.proto";
import "com/kodypay/grpc/sdk/common/pagination.proto";

// All service requests require X-API-Key header with 'API Key' value
service KodyEcomPaymentsService {
// Initiates a payment and returns a URL for the user to complete payment
rpc InitiatePayment(PaymentInitiationRequest) returns (PaymentInitiationResponse);

rpc PaymentDetails(PaymentDetailsRequest) returns (PaymentDetailsResponse);
rpc GetPayments(GetPaymentsRequest) returns (GetPaymentsResponse);
}

// Payment Initiation Request
Expand Down Expand Up @@ -66,6 +67,17 @@ message PaymentDetailsResponse {
Error error = 2;
}

message Error {
Type type = 1;
string message = 2;

enum Type {
UNKNOWN = 0;
NOT_FOUND = 1;
INVALID_REQUEST = 2;
}
}

message Response {
string payment_id = 1; // The unique identifier created by Kody
string payment_reference = 2; // Your unique payment reference that was set during the initiation
Expand All @@ -84,6 +96,47 @@ message PaymentDetailsResponse {
CANCELLED = 3;
}
}
}

message GetPaymentsRequest {
string store_id = 1;
com.kodypay.grpc.sdk.common.PageCursor pageCursor = 2;
Filter filter = 3;

message Filter {
optional string order_id = 1;
optional google.protobuf.Timestamp created_after = 2;
}
}
message GetPaymentsResponse {
oneof result {
Response response = 1;
Error error = 2;
}

message Response {
repeated PaymentDetails payments = 1;
int64 total = 2;

message PaymentDetails {
string payment_id = 1; // The unique identifier created by Kody
string payment_reference = 2; // Your unique payment reference that was set during the initiation
string order_id = 3; // Your identifier of the order. It doesn't have to be unique, for example when the same order has multiple payments.
optional string order_metadata = 4; // A data set that can be used to store information about the order and used in the payment details. For example a JSON with checkout items. It will be useful as evidence to challenge chargebacks or any risk data.
PaymentStatus status = 5;
optional string payment_data_json = 6; // json blob containing payment data

google.protobuf.Timestamp date_created = 7;
optional google.protobuf.Timestamp date_paid = 8;

enum PaymentStatus {
PENDING = 0;
SUCCESS = 1;
FAILED = 2;
CANCELLED = 3;
}
}
}

message Error {
Type type = 1;
Expand All @@ -92,8 +145,7 @@ message PaymentDetailsResponse {
enum Type {
UNKNOWN = 0;
NOT_FOUND = 1;
INVALID_REQUEST = 2;
INVALID_ARGUMENT = 2;
}
}

}
11 changes: 11 additions & 0 deletions src/main/proto/com/kodypay/grpc/sdk/common/pagination.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package com.kodypay.grpc.sdk.common;
option java_multiple_files = true;
option java_outer_classname = "KodySdkCommonProto";
option java_package = "com.kodypay.grpc.sdk.common";
import "google/protobuf/timestamp.proto";

message PageCursor {
int64 page = 1;
int64 page_size = 2;
}

0 comments on commit a79ca18

Please sign in to comment.