Skip to content

Instantly share code, notes, and snippets.

@mrezentes
Last active July 11, 2016 14:45
Show Gist options
  • Save mrezentes/7602e14d69edfa2ef0a239e1bc11329b to your computer and use it in GitHub Desktop.
Save mrezentes/7602e14d69edfa2ef0a239e1bc11329b to your computer and use it in GitHub Desktop.
SFTP Batch Export

Export multiple payment methods in a single, asynchronous, batch call to an SFTP receiver endpoint.

To use export:

  • create a receiver with an SFTP endpoint. Please refer to our documentation for creating receivers.
  • send a request to the export endpoint. Please refer to our documentation for export

Sample export request

curl https://core.spreedly.com/v1/receivers/QvCtF4nD6tav60DcztgorcPnTLO/export.json \
  -u 'Ll6fAtoVSTyVMlJEmtpoJV8S:RKOCG5D8D3fZxDSg504D0IxU2XD4Io5VXmyzdCtTivHFTTSy' \
  -H 'Content-Type: application/json' \
  -d '{
        "export": {
          "payment_method_tokens": ["FJSPfoAM9aavIkdtTZnGKff52l5", "Yj9FPVz1Nz87mDCspfcofBYu5Fy", "SGLYl7swRHjwA5Z3JD5UuBL4ayF"],
          "payment_method_data": {
            "FJSPfoAM9aavIkdtTZnGKff52l5": {"external_cardholder_id": "1111111111111111111111111", "action_code":"A" }, 
            "Yj9FPVz1Nz87mDCspfcofBYu5Fy": {"external_cardholder_id": "2222222222222222222222222", "action_code":"D"},
            "SGLYl7swRHjwA5Z3JD5UuBL4ayF": {"external_cardholder_id": "3333333333333333333333333", "action_code":"U"}
          },
          "url": "sftp://posttestserver.com/filename.txt",
          "body": "{{#gpg}}-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: IPWorks! OpenPGP v9.0\nxsBNBFdaDS0BCACPTH1Td1PSUSMeaTDAagncwV18KrpuXSPXWjTgPy9SLHeoKQDt\nwxWlIoisyxV1Ex2LQZnidINgNCFzMi26+SqYucm6OFv2bllr91tpk8I0+aeL/XBC\nJ5DUEbG9JAMyegMyzTz9PjRu4peXV/IUf2/uBJifZyv1bBaARCBXBaHvv+qfJbHx\n88QNVo5J7KU8C7MD8hqLxwtqDjHgKtXHGbyscMzJn+ySTueemqhOBI3jst/z9uL2\nOuSXeO0DudcLsmp6bVrh3SqpLKiZMbj2GsNcwVA/ikJiriaXOESv2RI/h1j5MjRs\nsg9tyJYytuDsqz/rEOVDnqfP5/xpiTX223tjABEBAAHNJHNmaWxlMi1sYS10YXFj\nLVBST0QgPG5hd2VzQHZpc2EuY29tPsLAdAQTAQIAHgUCV1oNLwMLAgIEFQoIAgUW\nAQIDAAIeAQIXgAIbDwAKCRBPCXevH0QlBoxhB/4o7sG1TOZlxjv9fuK1/Bx9ZjPJ\n6zCWGEAMV3li/jDmiNfJUaJOL5ZV8ffLRhgvS6bvKlpdMaRY8FXuJQThGe4T/BU4\nHJIP8jPR+x4CHoUHNw1rOVitdkc9y/tWoF7aYAWqcqBBQwqjH9XbSC2XcYbULcl8\nj8rVVTbXvJIdnx7u6v9OOeyc6XO7AupV7zjQHE6bdDPnmhyM9Yf+1OkDxuGNywsv\n0WP8iB847/ZPmaENvOofIsrbncbztgZu1V2fOJM6JRp0EbctSxP44Mk1K8AKcmx2\nMFqkPdKpeZh2bO269TO8fMy82gx6ltzMtms2NrRL3NOWj6suLke7s8K8++JC\n=Zp6G\n-----END PGP PUBLIC KEY BLOCK-----,nawes@visa.com,{{#format_text}}%-1000.1000s,0000VISA  VISA  {{#format_text}}%-255.255s,Card Account List Sample File{{/format_text}}20140101002.0 P2014010120510114VDACCTLISTSAMPLE{{/format_text}}\n{{#payment_methods}}{{#format_text}}%-1000.1000s,1001VDACCTLISTSAMPLE           {{action_code}}VISA  VISA  {{#format_text}}%-19.19s,{{credit_card_number}}{{/format_text}}{{external_cardholder_id}}{{#format_date}}%Y%m%d, {{credit_card_created_at}}{{/format_date}}{{/format_text}}\n{{/payment_methods}}{{#format_text}}%-1000.1000s,99990000000003{{/format_text}}{{/gpg}}""
        }
      }'

Sample receiver creation

curl https://core.spreedly.com/v1/receivers.json \
  -u 'Ll6fAtoVSTyVMlJEmtpoJV8S:RKOCG5D8D3fZxDSg504D0IxU2XD4Io5VXmyzdCtTivHFTTSy' \
  -H 'Content-Type: application/json' \
  -d '{"receiver":
        {
          "receiver_type": "test",
          "hostnames": "sftp://posttestserver.com",
          "protocol": {"user": "test_user", "password": "test_password"}
        }
      }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment