Beispiel #1
0
// Do account/pm, auth, capture NOT using combo
func doAuthCapture(s *kbcli.Session, apiKey string) {

	// Query params reused across the test
	var params kbcli.QueryParams

	accountData := gen.AccountAttributes{Name: apiKey, ExternalKey: apiKey, Email: apiKey, Currency: "USD"}
	createdAccount, err := kbcli.CreateAccount(s, &accountData, nil)

	displaySuccessMsgOrAbort("Created account id = ", "Failed to create account", err, createdAccount.AccountId)

	params = make(kbcli.QueryParams)
	params[kbcli.QUERY_EXTERNAL_KEY] = createdAccount.ExternalKey
	params[kbcli.QUERY_AUDIT] = "FULL"

	accountByKey, err := kbcli.GetAccount(s, "", &params)
	displaySuccessMsgOrAbort("Retrieved account by external key", "Failed to retrieve account by external key", err, accountByKey.ExternalKey)

	paymentMethodData := gen.PaymentMethodAttributes{AccountId: createdAccount.AccountId, PluginName: "__EXTERNAL_PAYMENT__", PluginInfo: gen.PaymentMethodPluginDetailAttributes{}}
	params = make(kbcli.QueryParams)
	params[kbcli.QUERY_PAYMENT_METHOD_IS_DEFAULT] = "true"
	createdPaymentMethod, err := kbcli.CreatePaymentMethod(s, &paymentMethodData, &params)
	displaySuccessMsgOrAbort("Created payment method id = ", "Failed to create payment method", err, createdPaymentMethod.PaymentMethodId)

	authorizationData := gen.PaymentTransactionAttributes{TransactionType: "AUTHORIZE", Amount: 12.5, Currency: createdAccount.Currency}
	createdPyament, err := kbcli.CreatePaymentAuthorization(s, createdAccount.AccountId, &authorizationData, nil)
	displaySuccessMsgOrAbort("Created payment transaction (AUTH)", "Failed to create payment transaction (AUTH)", err, createdPyament.PaymentId)

	captureData := gen.PaymentTransactionAttributes{PaymentId: createdPyament.PaymentId, TransactionType: "CAPTURE", Amount: 12.5, Currency: createdAccount.Currency}
	createdPyament, err = kbcli.CreatePaymentCapture(s, createdAccount.AccountId, &captureData, nil)
	displaySuccessMsgOrAbort("Created payment transaction (CAPTURE)", "Failed to create payment transaction (AUTH)", err, createdPyament.PaymentId)
}
Beispiel #2
0
func doComboAuthCapture(s *kbcli.Session, key string, isCapture bool) {

	accountData := gen.AccountAttributes{Name: key, Email: key, Currency: "USD"}
	paymentMethodData := gen.PaymentMethodAttributes{PluginName: "__EXTERNAL_PAYMENT__", PluginInfo: gen.PaymentMethodPluginDetailAttributes{}}
	authorizationData := gen.PaymentTransactionAttributes{TransactionType: "AUTHORIZE", Amount: 12.5, Currency: accountData.Currency}

	var pluginProperties []gen.PluginPropertyAttributes
	comboPaymentData := gen.ComboPaymentTransactionAttributes{Account: accountData, PaymentMethod: paymentMethodData, Transaction: authorizationData, PaymentMethodPluginProperties: pluginProperties, TransactionPluginProperties: pluginProperties}
	createdPayment, _ := kbcli.CreateComboAuthorization(s, &comboPaymentData, nil)
	//displaySuccessMsgOrAbort("Created COMBO payment transaction (AUTH)", "Failed to create payment transaction (AUTH)", err, createdPayment.PaymentId)

	if isCapture {
		captureData := gen.PaymentTransactionAttributes{PaymentId: createdPayment.PaymentId, TransactionType: "CAPTURE", Amount: 12.5, Currency: createdPayment.Currency}
		createdPayment, err := kbcli.CreatePaymentCapture(s, createdPayment.AccountId, &captureData, nil)
		displaySuccessMsgOrAbort("Created payment transaction (CAPTURE)", "Failed to create payment transaction (AUTH)", err, createdPayment.PaymentId)
	}
}