PayPalPaymentObject

The setupPayPal method can be used to either:

  • Create a PayPal Order (capture or authorization)
  • Create a PayPal Billing Agreement (subscription)

Create a PayPal Order

AttributeTypeDescriptionRequired/Optional
paymentIntentPaymentIntentrequired
paymentMethodOrderPaymentMethodrequired

OrderPaymentMethod

AttributeTypeDescriptionRequired/Optional
typeStringvalue: paypal_orderrequired
data.intentStringPossible values: capture, authorizerequired
data.optionsOrderOptionsMerchant specific options
data.purchasesArray[OrderPurchase]Purchase items & amounts

Note: Currently, only 1 purchase is acceptable
required

OrderOptions

AttributeTypeDescriptionRequired/Optional
brandNameStringThe name of the brand
payeePreferredPaymentStringPossible values:
UNRESTRICTED, IMMEDIATE_PAYMENT_REQUIRED
localeStringen_US, ko_KR
landingPageStringPossible values:
LOGIN, BILLING, NO_PREFERENCE
shippingPreferenceStringPossible values:
NO_SHIPPING,
SET_PROVIDED_ADDRESS
GET_FROM_FILE

OrderPurchase

AttributeTypeDescriptionRequired/Optional
descriptionStringThe purchase description
softDescriptorStringThe soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer's card statement
amountPurchaseAmountrequired
itemsArray[PurchaseItem]
shippingAddressrequired if shippingPreference != SET_PROVIDED_ADDRES
shippingAddress.methodStringA name for the shipping method
shippingAddress.addressShippingAddressShipping address provide by the merchantrequired

PurchaseAmount

Note: All amount values should be in the smallest currency unit (eg., 100 to charge $1.00, or 100 to Charge ¥100, a zero decimal currency).

AttributeTypeDescriptionRequired/Optional
itemTotalIntegerThe total purchase amountrequired if request includes items[].unitAmount
taxTotalIntegerThe total tax for all itemsrequired if request includes items[].tax
shippingIntegerThe shipping fee for all items
handlingIntegerThe handling fee for all items
insuranceIntegerThe insurance fee for all item
discountIntegerThe discount for all item
shippingDiscountIntegerThe shipping discount for all items

PurchaseItem

AttributeTypeDescriptionRequired/Optional
nameStringThe item namerequired
qtyIntegerThe item quantityrequired
unitAmountIntegerThe item price, in the smallest currency unit (eg., 100 to charge $1.00, or 100 to Charge ¥100, a zero decimal currency)required
taxIntegerThe item tax
categoryStringThe item category type
Possible values: DIGITAL_GOODS, PHYSICAL_GOODS
skuStringThe stock keeping unit (SKU) for the item
descriptionStringThe item description

ShippingAddress

AttributeTypeDescriptionRequired/Optional
firstNameStringUser's first name
lastNameStringUser's last name
address_1StringUser's address line 1
address_2StringUser's address line 2
cityStringUser's cityrequired
stateStringUser's state
countryStringUser's countryrequired
postcodeStringUser's postcoderequired

Note: Please refer to our documentation for more information on how to calculate the verification HMAC. Alternatively refer to PaymentIntent.

(Pseudo code) verification = hmac_md5(shared_secret, "reference:amount:currency")

var fz = new FatZebra({
  username: MERCHANT_USERNAME,
})

const capturePayment = {
  paymentIntent: {
    payment: {
      reference: reference,  // merchant-generated reference
      amount: 12000,
      currency: "AUD",
    },
    verification: verification
  },
  paymentMethod: {
    type: "paypal_order",
    data: {
      intent: "capture",  // "capture" | "authorize"
      options: {
        brandName: "EXAMPLE INC",
        landingPage: "NO_PREFERENCE", // "BILLING", "LOGIN"
        payeePreferredPayment: "UNRESTRICTED" // "IMMEDIATE_PAYMENT_REQUIRED"
      },
      purchases: [
        {
          description: "Sporting Goods",
          softDescriptor: "HighFashions",
          amount: {
            itemTotal: 9000,
            shipping: 2000,
            taxTotal: 1000
          },
          items: [
            {
              name: "T-Shirt",
              unitAmount: 9000,
              tax: 1000,
              qty: 1,
              sku: "sku01",
              category: "PHYSICAL_GOODS" // "DIGITAL_GOODS"
            }
          ],
          shipping_address: {
            method: "United States Postal Service 1",
            address: {
              firstName: "John",
              lastName: "Doe",
              address_1: "100 Kent Street",
              address_2: "Cafe Lane",
              city: "Sydney",
              state: "NSW",
              postcode: "2000",
              country: "AU"
            }
          }
        }
      ]
    }
  }
}

// This method should be called after setting event listeners!
fz.setupPayPal({
  currency: "AUD",
  payment: capturePayment,
  clientId: MERCHANT_PAYPAL_CLIENT_ID,
  containerId: "paypal-button-container"
})

Create a PayPal Billing Agreement

AttributeTypeDescriptionRequired/Optional
paymentMethodBillingAgreementPaymentMethodIncludes required data for a fulfilling PayPal flowrequired

BillingAgreementPaymentMethod

AttributeTypeDescriptionRequired/Optional
typeStringvalue: paypal_billingrequired
data.nameStringA name for the Billing Agreement
data.descriptionStringA description for the Billing Agreement
data.shippingAddressShippingAddressShipping address provided by the merchantrequired
data.merchantCustomDataStringMerchant specific data, e.g. a UUID

ShippingAdress

AttributeTypeDescriptionRequired/Optional
firstNameStringUser's first name
lastNameStringUser's last name
address_1StringUser's address line 1required
address_2StringUser's address line 2
cityStringUser's cityrequired
stateStringUser's staterequired
countryStringUser's countryrequired
postcodeStringUser's postcoderequired
const billingAgreementPayment = {
  paymentMethod: {
    type: "paypal_billing",
    data: {
      name: "Sample Billing Agreement",
      description: "Stored PayPal account",
      shippingAddress: {
        firstName: "John",
        lastName: "Doe",
        address_1: "100 Kent Street",
        address_2: "Cafe Lane",
        city: "Sydney",
        state: "NSW",
        postcode: "2000",
        country: "AU",
      },
      merchantCustomData: "UUID"
    }
  }
}

// This method should be called after setting event listeners!
fz.setupPayPal({
  currency: "AUD",
  payment: billingAgreementPayment,
  containerId: "paypal-button-container"
})