2021-01-13 02:41:43 +00:00
|
|
|
package rules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/ops/ops_client/payment_method"
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/ops/ops_models"
|
|
|
|
"code.tnxs.net/taxnexus/lib/app"
|
2021-01-19 01:50:45 +00:00
|
|
|
httptransport "github.com/go-openapi/runtime/client"
|
2021-01-13 02:41:43 +00:00
|
|
|
"go.temporal.io/sdk/workflow"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StorePaymentMethodActivity posts a new paymentmethod object to datastore
|
2021-01-19 21:20:11 +00:00
|
|
|
func StorePaymentMethodActivity(ctx workflow.Context, w app.PaymentMethodActivityWrapper) error { //nolint:gocritic,lll // don't care
|
2021-01-13 02:41:43 +00:00
|
|
|
postPaymentMethodParams := payment_method.NewPostPaymentMethodsParamsWithTimeout(postTimeout)
|
2021-01-19 21:18:59 +00:00
|
|
|
obj := &ops_models.PaymentMethod{
|
|
|
|
AccountID: w.AccountID,
|
|
|
|
AchAccountType: w.AchAccountType,
|
|
|
|
AchBankAccount: w.AchBankAccount,
|
|
|
|
AchRouting: w.AchRouting,
|
|
|
|
Active: w.Active,
|
|
|
|
Autopay: w.Autopay,
|
|
|
|
BankName: w.BankName,
|
|
|
|
BillingContactID: w.BillingContactID,
|
|
|
|
CCnumber: w.CCnumber,
|
|
|
|
CCtype: w.CCtype,
|
|
|
|
ContractID: w.ContractID,
|
|
|
|
Default: w.Default,
|
|
|
|
ExpirationMonth: w.ExpirationMonth,
|
|
|
|
ExpirationYear: w.ExpirationYear,
|
|
|
|
Gateway: w.Gateway,
|
|
|
|
GatewayKey: w.GatewayKey,
|
|
|
|
Nickname: w.Nickname,
|
|
|
|
RecordType: w.RecordType,
|
|
|
|
Ref: w.Ref,
|
|
|
|
TenantID: w.TenantID,
|
|
|
|
}
|
2021-01-13 02:41:43 +00:00
|
|
|
postPaymentMethodParams.PaymentMethodRequest = &ops_models.PaymentMethodRequest{
|
2021-01-19 21:18:59 +00:00
|
|
|
Data: []*ops_models.PaymentMethod{obj},
|
2021-01-13 02:41:43 +00:00
|
|
|
}
|
2021-01-19 01:50:45 +00:00
|
|
|
_, err := opsClient.PaymentMethod.PostPaymentMethods(postPaymentMethodParams,
|
|
|
|
httptransport.APIKeyAuth(
|
|
|
|
"X-API-Key",
|
|
|
|
"header",
|
|
|
|
w.APIKey,
|
|
|
|
))
|
2021-01-13 02:41:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
sugar.Info("rules.storePaymentMethod: 👍 📤")
|
|
|
|
return nil
|
|
|
|
}
|