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
Attribute | Type | Description | Required/Optional |
---|---|---|---|
paymentIntent | PaymentIntent | required | |
paymentMethod | OrderPaymentMethod | required |
OrderPaymentMethod
Attribute | Type | Description | Required/Optional |
---|---|---|---|
type | String | value: paypal_order | required |
data.intent | String | Possible values: capture, authorize | required |
data.options | OrderOptions | Merchant specific options | |
data.purchases | Array[OrderPurchase] | Purchase items & amounts Note: Currently, only 1 purchase is acceptable | required |
OrderOptions
Attribute | Type | Description | Required/Optional |
---|---|---|---|
brandName | String | The name of the brand | |
payeePreferredPayment | String | Possible values: UNRESTRICTED, IMMEDIATE_PAYMENT_REQUIRED | |
locale | String | en_US, ko_KR | |
landingPage | String | Possible values: LOGIN, BILLING, NO_PREFERENCE | |
shippingPreference | String | Possible values: NO_SHIPPING, SET_PROVIDED_ADDRESS GET_FROM_FILE |
OrderPurchase
Attribute | Type | Description | Required/Optional |
---|---|---|---|
description | String | The purchase description | |
softDescriptor | String | The soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer's card statement | |
amount | PurchaseAmount | required | |
items | Array[PurchaseItem] | ||
shippingAddress | required if shippingPreference != SET_PROVIDED_ADDRES | ||
shippingAddress.method | String | A name for the shipping method | |
shippingAddress.address | ShippingAddress | Shipping address provide by the merchant | required |
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).
Attribute | Type | Description | Required/Optional |
---|---|---|---|
itemTotal | Integer | The total purchase amount | required if request includes items[].unitAmount |
taxTotal | Integer | The total tax for all items | required if request includes items[].tax |
shipping | Integer | The shipping fee for all items | |
handling | Integer | The handling fee for all items | |
insurance | Integer | The insurance fee for all item | |
discount | Integer | The discount for all item | |
shippingDiscount | Integer | The shipping discount for all items |
PurchaseItem
Attribute | Type | Description | Required/Optional |
---|---|---|---|
name | String | The item name | required |
qty | Integer | The item quantity | required |
unitAmount | Integer | The item price, in the smallest currency unit (eg., 100 to charge $1.00, or 100 to Charge ¥100, a zero decimal currency) | required |
tax | Integer | The item tax | |
category | String | The item category type Possible values: DIGITAL_GOODS, PHYSICAL_GOODS | |
sku | String | The stock keeping unit (SKU) for the item | |
description | String | The item description |
ShippingAddress
Attribute | Type | Description | Required/Optional |
---|---|---|---|
firstName | String | User's first name | |
lastName | String | User's last name | |
address_1 | String | User's address line 1 | |
address_2 | String | User's address line 2 | |
city | String | User's city | required |
state | String | User's state | |
country | String | User's country | required |
postcode | String | User's postcode | required |
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
Attribute | Type | Description | Required/Optional |
---|---|---|---|
paymentMethod | BillingAgreementPaymentMethod | Includes required data for a fulfilling PayPal flow | required |
BillingAgreementPaymentMethod
Attribute | Type | Description | Required/Optional |
---|---|---|---|
type | String | value: paypal_billing | required |
data.name | String | A name for the Billing Agreement | |
data.description | String | A description for the Billing Agreement | |
data.shippingAddress | ShippingAddress | Shipping address provided by the merchant | required |
data.merchantCustomData | String | Merchant specific data, e.g. a UUID |
ShippingAdress
Attribute | Type | Description | Required/Optional |
---|---|---|---|
firstName | String | User's first name | |
lastName | String | User's last name | |
address_1 | String | User's address line 1 | required |
address_2 | String | User's address line 2 | |
city | String | User's city | required |
state | String | User's state | required |
country | String | User's country | required |
postcode | String | User's postcode | required |
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"
})
Updated 10 months ago