Giter VIP home page Giter VIP logo

amazon-payments's Introduction

Installation:

npm install @madisonreed/amazon-payments

Usage:

Initialize the amazonPayment object with the environment variable, and all required config parameters.

The amazonPayments.Environment object contains two properties: Production and Sandbox, pass one of these in the configuration object. Use ProductionEU and SandboxEU for European countries.

Example:

var amazonPayments = require('@madison-reed/amazon-payments');
var payment = amazonPayments.connect({
  environment: amazonPayments.Environment.Production,
  sellerId: 'Amazon Seller ID',
  mwsAccessKey: 'MWS Access Key',
  mwsSecretKey: 'MWS Secret Key',
  clientId: 'Client ID'
});

Note about request parameters

This module will automatically sign all requests and convert nested objects to dot notation.

Example:

payment.offAmazonPayments.refund({
  AmazonCaptureId: 'Amazon capture ID',
  RefundReferenceId: 'Refund Reference ID',
  RefundAmount: {
    Amount: 123.45,
    CurrencyCode: 'USD'
  }
}, function(err) {
  console.log(err);
})

Will make a call with the following parameters:

{
  "AmazonCaptureId": "Amazon capture ID",
  "RefundReferenceId": "Refund Reference ID",
  "RefundAmount.Amount": 123.45,
  "RefundAmount.CurrencyCode": "USD"
}

api.getTokenInfo(accessToken, callback)

getTokenInfo takes two parameters: accesToken and callback. More Info

callback: err, tokenInfo

Example:

payment.api.getTokenInfo('access token from button', function(err, tokenInfo) {
  console.log(tokenInfo);
});

api.getProfile(accessToken, callback)

getProfile takes two parameters: accesToken and callback. More Info

callback: err, profile

Example:

payment.api.getProfile('access token from button', function(err, profile) {
  console.log(profile);
});

offAmazonPayments.*

All the methods in the offAmazonPayments object take two parameters: params and callback. The functions are all named the same as their respective API calls, except with a lowercase first letter. More Info

Exmaple:

payment.offAmazonPayments.getAuthorizationDetails({
  AmazonAuthorizationId: 'P01-0000000-0000000-000000'
}, function(err, details) {
  // details will be the authorization details
});

SNS Response handling

Version 0.1.2 added SNS response handling for dealing with SNS messages. This also includes support for IPN endpoints. This will check the signature and attempt to parse any XML within IPN requests, if the message is not JSON it will return the raw message data, otherwise it will be the parsed response.

Example:

payment.parseSNSResponse(responseFromSns, function(err, parsed) {
  // parsed will contain the full response from SNS unless the message is an IPN notification, in which case it will be the JSON-ified XML from the message.
});

amazon-payments's People

Contributors

360disrupt avatar benstepp avatar divesnob avatar isurfbecause avatar scottspork avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ckim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.