[apple pay][sandbox] GENERIC apple pay authorization
@macurielsipay
code:
data:privatelast updated:2 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
backend
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
}
43
const axios = require('axios');
const crypto = require("crypto");

// IMPORTANTE: Personalizar por el comercio
const key = 'key';
const resource = 'resource';
const secret = 'secret';
// Fin de personalización del comercio

const endpoint = 'https://sandbox.sipay.es/mdwr/v1/authorization';
const { token, request_id } = event.body;


const body = {
  key: key,
  resource: resource,
  nonce: process.hrtime().toString().replace(",", ""),
  mode: "sha256",
  payload: {
    amount: 10,
    currency: 'EUR',
    catcher: {
      type: 'apay',
      token_apay: token,
      request_id: request_id
    }
  }
}

const response = await axios({
  method: 'POST',
  url: endpoint,
  headers: {
    'Content-Signature': crypto.createHmac('sha256', secret).update(JSON.stringify(body)).digest("hex"),
    'Content-Type': 'application/json'
  },
  data: body,
});
const { data } = response;
console.log(body);
$checkpoint = data;
steps.
respond
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
}
7
await $respond({
  status: 200,
  immediate: true,
  body: $checkpoint
})
steps.
end
End execution at this step. Later steps in the workflow will not run.
params
Optional
code
async params => {
1
2
}
3
$end(params.reason)