Skip to content

Instantly share code, notes, and snippets.

View danielneu's full-sized avatar

Daniel Neu danielneu

  • Alexa Commerce
  • Luxembourg
View GitHub Profile
@danielneu
danielneu / gist:fd526c4f546b26399d7c7d2e18c46020
Created October 4, 2019 14:56
Order Independent callback logic
// add Login and Pay callbacks
window.onAmazonPaymentsReady = () => {
this.createButton(sellerId, scope, type, color, size, mountLocation);
}
// if the OffAmazonPayments namespace is already available, call the callback manually - otherwise wait for Amazon to call it
if (typeof window.OffAmazonPayments !== 'undefined') {
window.onAmazonPaymentsReady();
"request": {
"type": "Connections.Response",
"requestId": "amzn1.echo-api.request.d82eb2de-f527-4a07-8367-136789101112",
"timestamp": "2018-10-09T14:36:16Z",
"locale": "de-DE",
"status": {
"code": "400",
"message": "InvalidPaymentMethod"
},
"name": "Charge",
{
"type": "Connections.SendRequest",
"name": "Charge",
"payload": {
"@type": "ChargeAmazonPayRequest",
"@version": "2",
"sellerId": "A1RN901234567",
"billingAgreementId": "B02-9069520-1234567",
"paymentAction": "Authorize",
"authorizeAttributes": {
@danielneu
danielneu / ChargeResponse.json
Created September 20, 2018 09:13
Amazon Pay for Alexa Skills Charge Response
{
"requestEnvelope": {
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.bcde",
"application": {
"applicationId": "amzn1.ask.skill.d2345"
},
"user": {
@danielneu
danielneu / ChargeRequest.json
Created September 20, 2018 09:10
Amazon Pay for Alexa Skills Process Request
{
"type": "Connections.SendRequest",
"name": "Charge",
"payload": {
"@type": "ChargeAmazonPayRequest",
"@version": "2",
"sellerId": "AABBCCDDEE",
"billingAgreementId": "C02-5320354-ABCDEFG",
"paymentAction": "AuthorizeAndCapture",
"authorizeAttributes": {
@danielneu
danielneu / SetupResponse.json
Created September 20, 2018 09:07
Amazon Pay for Alexa Skills Setup Response
{
"requestEnvelope": {
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.012345",
"application": {
"applicationId": "amzn1.ask.skill.d23456"
},
"user": {
@danielneu
danielneu / SetupRequest.json
Last active March 7, 2019 07:57
Amazon Pay for Alexa Skills Setup Request
{
"type": "Connections.SendRequest",
"name": "Setup",
"payload": {
"@type": "SetupAmazonPayRequest",
"@version": "2",
"sellerId": "AABBCCDDEE",
"countryOfEstablishment": "DE",
"ledgerCurrency": "EUR",
"checkoutLanguage": "de-DE",
@danielneu
danielneu / gist:0953e2506fee71a082d6
Created March 15, 2016 12:06
Order of asynchronous Widgetss.js loading
<style type="text/css">
#addressBookWidgetDiv{
width: 400px;
height: 228px;
}
</style>
<!-- first place the diff wherever the widget should appear -->
How to parse address line
For DE and AT customers, usually the street is in the last address line (the last used one). If the customer is from DE or AT, the address line can be parsed using the following pseudo code algorithm:
if (country in ("AT","DE")) {
if (AddressLine3 != "") {
Street = AddressLine3
if (AddressLine1 isNumber or AddressLine1 + AddressLine2 contains “Packstation”) {
PO box = AddressLine1 + AddressLine2
} else {