Repository navigation
Do encrypted authentication transaction
Igor Zhutaiev edited this page Apr 28, 2018
·
1 revision
import "github.com/zhutik/adyen-api-go"
// Configure Adyen API
instance := adyen.New(
adyen.Testing,
os.Getenv("ADYEN_USERNAME"),
os.Getenv("ADYEN_PASSWORD"),
)
...
// Pass object with those properties to your form template (shown below)
{
EncURL: instance.ClientURL(os.Getenv("ADYEN_CLIENT_TOKEN")),
Time: now.Format(time.RFC3339),
}<script type="text/javascript" src="**{{ .EncURL }}**"></script>
...
<form action="YOUR_ACTION_URL" method="POST">
<input type="text" id="number" autocomplete="off" data-encrypted-name="number" size="20">
<input type="text" id="holderName" autocomplete="off" data-encrypted-name="holderName">
<input type="text" id="expiryMonth" autocomplete="off" data-encrypted-name="expiryMonth" size="2" maxlength="2">
<input type="text" id="expiryYear" autocomplete="off" data-encrypted-name="expiryYear" size="4" maxlength="4">
<input type="text" id="cvc" autocomplete="off" data-encrypted-name="cvc" size="4" maxlength="4">
<input type="hidden" value="" name="adyen-encrypted-data" id="adyen-encrypted-data" />
<input type="hidden" value="{{ .Time }}" data-encrypted-name="generationtime" />
<button type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
Perform payment
</button>
</form>import "github.com/zhutik/adyen-api-go"
// Configure Adyen API
instance := adyen.New(
adyen.Testing,
os.Getenv("ADYEN_USERNAME"),
os.Getenv("ADYEN_PASSWORD"),
)
req := &adyen.AuthoriseEncrypted{
Amount: &adyen.Amount{
Value: 1000, // amount * 100, f.e. 10,30 EUR = 1030
Currency: "EUR" // or use instance.Currency
},
MerchantAccount: os.Getenv("ADYEN_ACCOUNT"), // your merchant account in Adyen
AdditionalData: &adyen.AdditionalData{Content: "encryptedData"}, // encrypted data from a form
Reference: "your-order-number",
}
// Perform authorise transaction
g, err := instance.Payment().AuthoriseEncrypted(req)