-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add invoice paid event callback struct #124
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package xendit | ||
|
||
type EventInvoicePaid struct { | ||
ID string `json:"id"` | ||
Fees []InvoiceFee `json:"fees"` | ||
Amount int `json:"amount"` | ||
Status string `json:"status"` | ||
Created string `json:"created"` | ||
IsHigh bool `json:"is_high"` | ||
PaidAt string `json:"paid_at"` | ||
Updated string `json:"updated"` | ||
UserID string `json:"user_id"` | ||
Currency string `json:"currency"` | ||
PaymentID string `json:"payment_id"` | ||
ExternalID string `json:"external_id"` | ||
PaidAmount int `json:"paid_amount"` | ||
MerchantName string `json:"merchant_name"` | ||
PaymentMethod string `json:"payment_method"` | ||
PaymentChannel string `json:"payment_channel"` | ||
PaymentDetails InvoicePaymentDetail `json:"payment_details"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you declare this as a pointer since this field is optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure! |
||
PaymentMethodID string `json:"payment_method_id"` | ||
BankCode string `json:"bank_code,omitempty"` | ||
PayerEmail string `json:"payer_email,omitempty"` | ||
Description string `json:"description,omitempty"` | ||
PaymentDestination string `json:"payment_destination,omitempty"` | ||
SuccessRedirectURL string `json:"success_redirect_url,omitempty"` | ||
FailureRedirectURL string `json:"failure_redirect_url,omitempty"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package xendit_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/xendit/xendit-go" | ||
) | ||
|
||
func TestEventInvoicePaid_EWallet(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please help to rename this test to reflect the new callback struct, thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks ! i renamed it to match the InvoiceCallback |
||
testPayload := `{ | ||
"id": "12345", | ||
"fees": [ | ||
{ | ||
"type": "example fee", | ||
"value": 100 | ||
} | ||
], | ||
"amount": 1000, | ||
"status": "PAID", | ||
"created": "2023-05-14T07:32:42.646Z", | ||
"is_high": false, | ||
"paid_at": "2023-05-14T07:35:14.000Z", | ||
"updated": "2023-05-14T07:35:15.810Z", | ||
"user_id": "example", | ||
"currency": "IDR", | ||
"payment_id": "qrpy_example", | ||
"external_id": "example", | ||
"paid_amount": 1000, | ||
"merchant_name": "Example Merchant", | ||
"payment_method": "QR_CODE", | ||
"payment_channel": "QRIS", | ||
"payment_details": { | ||
"source": "Ovo", | ||
"receipt_id": "example" | ||
}, | ||
"payment_method_id": "pm-example-123" | ||
}` | ||
expectedPayload := xendit.EventInvoicePaid{ | ||
ID: "12345", | ||
Fees: []xendit.InvoiceFee{{Type: "example fee", Value: 100}}, | ||
Amount: 1000, | ||
Status: "PAID", | ||
Created: "2023-05-14T07:32:42.646Z", | ||
IsHigh: false, | ||
PaidAt: "2023-05-14T07:35:14.000Z", | ||
Updated: "2023-05-14T07:35:15.810Z", | ||
UserID: "example", | ||
Currency: "IDR", | ||
PaymentID: "qrpy_example", | ||
ExternalID: "example", | ||
PaidAmount: 1000, | ||
MerchantName: "Example Merchant", | ||
PaymentMethod: "QR_CODE", | ||
PaymentChannel: "QRIS", | ||
PaymentDetails: xendit.InvoicePaymentDetail{ | ||
Source: "Ovo", | ||
ReceiptID: "example", | ||
}, | ||
PaymentMethodID: "pm-example-123", | ||
} | ||
var actualPayload xendit.EventInvoicePaid | ||
err := json.Unmarshal([]byte(testPayload), &actualPayload) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expectedPayload, actualPayload) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be renamed to InvoiceCallback to reflect what we define on the API Reference here? Thanks!
Could we also move this to the
invoice
folder over here since this logic is specific to Invoices?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good !
i renamed it to
InvoiceCallback
and moved it to invoice package.