go get -u github.com/vannleonheart/ayoconnect-api-go
ayoConfig := ayoconnect.Config{
BaseUrl: "{api_base_url}",
ClientId: "{your_client_id}",
ClientSecret: "{your_client_secret}",
MerchantCode: "{your_merchant_code}",
Latitude: "{default_latitude}",
Longitude: "{default_longitude}",
PhoneNumber: "{default_phone_number}",
IpAddress: "{default_ip_address}",
}
Base URL for Sandbox
https://sandbox.api.of.ayoconnect.id
ayoClient := ayoconnect.New(&ayoConfig)
with existing access token
existingAccessToken := "{existing_access_token}"
ayoClient = ayoClient.WithAccessToken(existingAccessToken)
set correlation id manually
correlationId := "{your_correlation_id}"
ayoClient = ayoClient.WithRequestId(correlationId)
set correlation id automatically
ayoClient = ayoClient.WithAutoGeneratedRequestId()
set phone number
phoneNumber := "628xxx"
ayoClient = ayoClient.WithPhoneNumber(phoneNumber)
set ip address
ipAddress := "127.0.0.1"
ayoClient = ayoClient.WithIpAddress(ipAddress)
authenticationResult, err = ayoClient.Authenticate()
if err != nil {
// handle error
}
fmt.Println(authenticationResult.AccessToken)
Reference https://developer.ayoconnect.id/docs/bank-account-disbursement-stage/1/overview
- Get Balance
result, err := ayoClient.WithAutoGeneratedRequestId().GetBalance()
if err != nil {
// handle error
}
fmt.Println(result.AccountInfo[0].AvailableBalance.Value)
- Add Beneficiary
transactionId := ayoClient.RandomString(32)
result, err := ayoClient.WithAutoGeneratedRequestId().AddBeneficiary(
transactionId,
"{bank_account_number}",
"{bank_swift_code}",
)
if err != nil {
// handle error
}
fmt.Println(result.BeneficiaryDetails.BeneficiaryId)
- Disburse
transactionId := ayoClient.RandomString(32)
result, err := ayoClient.WithAutoGeneratedRequestId().Disburse(
transactionId,
"{customer_id}",
"{beneficiary_id}",
"{amount_in_string}",
"IDR",
"{remark}",
)
if err != nil {
// handle error
}
fmt.Println(result.ReferenceNumber)
- Get Disbursement Status using Correlation Id
result, err := ayoClient.WithAutoGeneratedRequestId().GetDisbursementStatusByCorrelationId(
"{correlation_id}",
"{transaction_id}",
"{reference_number}",
"{beneficicary_id}",
"{customer_id}",
)
if err != nil {
// handle error
}
fmt.Println(result.ReferenceNumber)