diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e20366a..74589f1 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -103,3 +103,17 @@ jobs: run: docker run --rm -d --name giving-example-image -p 8080:80 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_MERCHANT_ACCOUNT=${{ secrets.ADYEN_MERCHANT_ACCOUNT }} -e ADYEN_CLIENT_KEY=${{ secrets.ADYEN_CLIENT_KEY }} -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} giving-example-image:latest - name: Run testing suite against giving-example-image run: docker run --rm --name adyen-testing-suite -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e PLAYWRIGHT_FOLDERNAME=giving --network host ghcr.io/adyen-examples/adyen-testing-suite:main + + in-person-payments: + runs-on: ubuntu-latest + steps: + - name: In-person Payments project + uses: actions/checkout@v4 + - name: Build in-person-payments-example image + run: docker build -t in-person-payments-example-image:latest in-person-payments-example + - name: Start in-person-payments-example container, set ADYEN_TERMINAL_API_CLOUD_ENDPOINT to default docker bridge and port 3000 + run: docker run --rm -d --name in-person-payments-example-image -p 8080:80 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e ADYEN_TERMINAL_API_CLOUD_ENDPOINT=http://172.17.0.1:3000 -e ADYEN_POS_POI_ID=V400m-123456789 in-person-payments-example-image:latest + - name: Start the Adyen Mock Terminal API Application on port 3000 + run: docker run --rm -d --name adyen-mock-terminal-api -p 3000:3000 -e PORT=3000 ghcr.io/adyen-examples/adyen-mock-terminal-api:main + - name: Run testing suite against in-person-payments-example-image + run: docker run --rm --name adyen-testing-suite -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e PLAYWRIGHT_FOLDERNAME=in-person-payments --network host ghcr.io/adyen-examples/adyen-testing-suite:main diff --git a/in-person-payments-example/Controllers/ApiController.cs b/in-person-payments-example/Controllers/ApiController.cs index b780cd6..f24b535 100644 --- a/in-person-payments-example/Controllers/ApiController.cs +++ b/in-person-payments-example/Controllers/ApiController.cs @@ -85,10 +85,10 @@ public async Task> CreatePayment([FromBody] { case ResultType.Success: table.PaymentStatus = PaymentStatus.Paid; - table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData.POITransactionID.TransactionID; - table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData.POITransactionID.TimeStamp; - table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData.SaleTransactionID.TransactionID; - table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData.SaleTransactionID.TimeStamp; + table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData?.POITransactionID?.TransactionID; + table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData?.POITransactionID?.TimeStamp; + table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData?.SaleTransactionID?.TransactionID; + table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData?.SaleTransactionID?.TimeStamp; return Ok(new CreatePaymentResponse() { @@ -97,10 +97,10 @@ public async Task> CreatePayment([FromBody] case ResultType.Failure: table.PaymentStatus = PaymentStatus.NotPaid; table.PaymentStatusDetails.RefusalReason = "Payment terminal responded with: " + paymentResponse.Response.ErrorCondition; - table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData.POITransactionID.TransactionID; - table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData.POITransactionID.TimeStamp; - table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData.SaleTransactionID.TransactionID; - table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData.SaleTransactionID.TimeStamp; + table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData?.POITransactionID?.TransactionID; + table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData?.POITransactionID?.TimeStamp; + table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData?.SaleTransactionID?.TransactionID; + table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData?.SaleTransactionID?.TimeStamp; return Ok(new CreatePaymentResponse() { diff --git a/in-person-payments-example/Options/AdyenOptions.cs b/in-person-payments-example/Options/AdyenOptions.cs index faa790d..f884f00 100644 --- a/in-person-payments-example/Options/AdyenOptions.cs +++ b/in-person-payments-example/Options/AdyenOptions.cs @@ -24,7 +24,13 @@ public class AdyenOptions /// /// Your unique ID for the POS system (cash register) to send this request from. /// - public string ADYEN_POS_SALE_ID { get; set; } + public string ADYEN_POS_SALE_ID { get; set; } + /// + /// Default: null, unless you want to override this to point to a different endpoint based on your region. + /// See https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/#cloud. + /// Optionally, if you do not own an Adyen Terminal/POS (yet), you can test this application using Adyen's Mock Terminal-API Application on GitHub: https://github.com/adyen-examples/adyen-mock-terminal-api (see README). + /// + public string ADYEN_TERMINAL_API_CLOUD_ENDPOINT { get; set; } } } \ No newline at end of file diff --git a/in-person-payments-example/Startup.cs b/in-person-payments-example/Startup.cs index c31f11d..7b8b43a 100644 --- a/in-person-payments-example/Startup.cs +++ b/in-person-payments-example/Startup.cs @@ -35,7 +35,8 @@ public void ConfigureServices(IServiceCollection services) options.ADYEN_API_KEY = Configuration[nameof(AdyenOptions.ADYEN_API_KEY)]; options.ADYEN_HMAC_KEY = Configuration[nameof(AdyenOptions.ADYEN_HMAC_KEY)]; options.ADYEN_POS_POI_ID = Configuration[nameof(AdyenOptions.ADYEN_POS_POI_ID)]; - options.ADYEN_POS_SALE_ID = "SALE_ID_POS_42"; + options.ADYEN_TERMINAL_API_CLOUD_ENDPOINT = Configuration[nameof(AdyenOptions.ADYEN_TERMINAL_API_CLOUD_ENDPOINT)]; + options.ADYEN_POS_SALE_ID = "SALE_ID_POS"; } ); @@ -57,7 +58,8 @@ public void ConfigureServices(IServiceCollection services) XApiKey = options.Value.ADYEN_API_KEY, // Test environment. Environment = Adyen.Model.Environment.Test, - Timeout = 180 + Timeout = 180, + CloudApiEndPoint = options.Value.ADYEN_TERMINAL_API_CLOUD_ENDPOINT }, provider.GetRequiredService(), httpClientName diff --git a/in-person-payments-loyalty-example/Startup.cs b/in-person-payments-loyalty-example/Startup.cs index 3766342..4c7033e 100644 --- a/in-person-payments-loyalty-example/Startup.cs +++ b/in-person-payments-loyalty-example/Startup.cs @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services) XApiKey = options.Value.ADYEN_API_KEY, // Test environment. Environment = Adyen.Model.Environment.Test, - Timeout = 180, + Timeout = 180 }, provider.GetRequiredService(), httpClientName