Exemple #1
0
func main() {

	header := new(payeezy.Header)
	header.Url = "https://api-cert.payeezy.com/v1/transactions"
	header.APIKey = "y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a"
	header.Token = "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6"
	header.Authorization = "NDBkODhkMGQwZTEzYzkxNjc4OTc2MmM3ODFlZTA4M2MxNjcxZDY0ZDk5ZDFiOTdjZjkwNTFkNmY4NTUxNWRlYQ=="
	header.Nonce = "6770831660134717000"
	header.Timestamp = "1423683480051"

	authorize := new(payeezy.Authorize)
	authorize.MerchantRef = "Astonishing-Sale"
	authorize.TransactionType = "authorize"
	authorize.Method = "credit_card"
	authorize.Amount = "1299"
	authorize.CurrencyCode = "USD"
	authorize.CreditCard.Type = "visa"
	authorize.CreditCard.CardholderName = "John Smith"
	authorize.CreditCard.CardNumber = "4788250000028291"
	authorize.CreditCard.ExpDate = "1030"
	authorize.CreditCard.Cvv = "123"

	payload := payeezy.AuthorizePayload(authorize)

	response, err := header.PostTransaction(payload)
	if err != nil {
		log.Println(err)
	}

	log.Println(response)

	log.Println("TransactionStatus:", response.TransactionStatus)
	log.Println("ValidationStatus:", response.ValidationStatus)

	errs := len(response.Error.Messages)

	for i := 0; i < errs; i++ {
		log.Println("Code:", response.Error.Messages[i].Code)
		log.Println("Description:", response.Error.Messages[i].Description)
	}

}
Exemple #2
0
func main() {

	var err error

	// HEADER
	header := new(payeezy.Header)
	headJson := `
	{
		"url": "https://api-cert.payeezy.com/v1/transactions",
		"apikey": "y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a",
		"token": "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6",
		"authorization": "NDBkODhkMGQwZTEzYzkxNjc4OTc2MmM3ODFlZTA4M2MxNjcxZDY0ZDk5ZDFiOTdjZjkwNTFkNmY4NTUxNWRlYQ==",
		"nonce": "6770831660134717000",
		"timestamp": "1423683480051"
	}
	`
	json.Unmarshal([]byte(headJson), header)
	if err != nil {
		log.Println(err)
	}

	//AUTHORIZE Data
	authorize := new(payeezy.Authorize)
	authJson := `
	{
		"merchant_ref": "Astonishing-Sale",
		"transaction_type": "authorize",
		"method": "credit_card",
		"amount": "1299",
		"currency_code": "USD",
		"credit_card": {
			"type": "visa",
			"cardholder_name": "John Smith",
			"card_number": "4005519200000004",
			"exp_date": "1020",
			"cvv": "123"
		}
	}`
	err = json.Unmarshal([]byte(authJson), authorize)
	if err != nil {
		log.Println(err)
	}

	// Construct payload
	payload := payeezy.AuthorizePayload(authorize)

	//Post Transaction
	response, err := header.PostTransaction(payload)
	if err != nil {
		log.Println(err)
	}

	errs := len(response.Error.Messages)
	for i := 0; i < errs; i++ {
		log.Println("Code:", response.Error.Messages[i].Code)
		log.Println("Description:", response.Error.Messages[i].Description)
	}

	log.Println(response)
	log.Println("TransactionStatus:", response.TransactionStatus)
	log.Println("ValidationStatus:", response.ValidationStatus)

}