Add Chapa checkout, verify, webhook, and callback flows so subscriptions activate only after confirmed payment. Route subscription checkout through Chapa while keeping ArifPay for direct payments. Include integration docs and a Postman collection. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.0 KiB
Go
68 lines
2.0 KiB
Go
package domain
|
|
|
|
// ChapaInitializeRequest is sent to POST /transaction/initialize.
|
|
type ChapaInitializeRequest struct {
|
|
Amount string `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Email string `json:"email"`
|
|
FirstName string `json:"first_name"`
|
|
LastName string `json:"last_name"`
|
|
PhoneNumber string `json:"phone_number,omitempty"`
|
|
TxRef string `json:"tx_ref"`
|
|
CallbackURL string `json:"callback_url,omitempty"`
|
|
ReturnURL string `json:"return_url,omitempty"`
|
|
Customization struct {
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
} `json:"customization,omitempty"`
|
|
}
|
|
|
|
type ChapaInitializeResponse struct {
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
Data struct {
|
|
CheckoutURL string `json:"checkout_url"`
|
|
} `json:"data"`
|
|
}
|
|
|
|
type ChapaVerifyResponse struct {
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
Data ChapaTransactionData `json:"data"`
|
|
}
|
|
|
|
type ChapaTransactionData struct {
|
|
TxRef string `json:"tx_ref"`
|
|
Reference string `json:"reference"`
|
|
Amount string `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Status string `json:"status"`
|
|
PaymentMethod string `json:"payment_method"`
|
|
Mode string `json:"mode"`
|
|
}
|
|
|
|
// ChapaWebhookPayload is the body POSTed to the webhook URL.
|
|
type ChapaWebhookPayload struct {
|
|
Event string `json:"event"`
|
|
Type string `json:"type"`
|
|
TxRef string `json:"tx_ref"`
|
|
Reference string `json:"reference"`
|
|
Status string `json:"status"`
|
|
Amount string `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
PaymentMethod string `json:"payment_method"`
|
|
Mode string `json:"mode"`
|
|
}
|
|
|
|
// ChapaCallbackQuery is sent to callback_url after payment (GET).
|
|
type ChapaCallbackQuery struct {
|
|
TrxRef string `json:"trx_ref"`
|
|
RefID string `json:"ref_id"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type ChapaPaymentMethod struct {
|
|
Name string `json:"name"`
|
|
DisplayName string `json:"display_name"`
|
|
}
|