Skip to content

Instantly share code, notes, and snippets.

@wehub
Last active February 21, 2017 18:23
Show Gist options
  • Select an option

  • Save wehub/daf6063c8f498a792282355848c74218 to your computer and use it in GitHub Desktop.

Select an option

Save wehub/daf6063c8f498a792282355848c74218 to your computer and use it in GitHub Desktop.
//LineItem:
var lineItem = {
type: "final",
label: "Subtotal",
amount: "1234.56"
};
//PaymentContact:
var contact = {
emailAddress: "test@email.com",
phoneNumber: "1234567890",
familyName: "Lastname",
givenName: "Firstname",
addressLines: ["123 California Street", "#100"],
locality: "Redwood City",
postalCode: "94061",
administrativeArea: "CA",
country: "United States",
countryCode: "us"
};
//ShippingItem:
var shippingItem = {
label: "Next Day Air",
detail: "Arrives in 1-2 business days.",
amount: "25.00",
identifier: "next_day_air"
};
//PaymentMethod
var paymentMethod = {
displayName: "MasterCard 1471",
paymentNetwork: "MasterCard",
type: "credit"
};
//PaymentRequest
var paymentRequest = {
billingContact: contact,
countryCode: "us",
currencyCode: "USD",
lineItems: [lineItem, {label: "shipping", amount: "25.00", type: "final"}],
requiredBillingContactFields: ["phone", "name"],
requiredShippingContactFields: ["postalAddress", "name"],
shippingContact: contact,
shippingMethods: [shippingItem],
shippingType: ["shipping"],
total: {label: "Total", amount: "1259.56"}
};
//AvailabilityResponse
var response = {
canMakePayments: false,
error: "InvalidAccessError", // This error occurs when using Apple Pay over http (instead of https)
error_description: "The object does not support the operation or argument."
};
//PaymentResponse
var response = {
creditCardId: 1234567,
transactionIdentifier: "a83abeCu134dai125ab",
paymentMethod: paymentMethod,
billingContact: billingContact,
shippingContact: shippingContact,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment