Core Concepts
Payments
A Payment object represents a single attempt to move money. It transitions through a small set of states — from creation through capture, refund, or failure.
Lifecycle
requires_source— created without a payment methodrequires_confirmation— has a source, awaiting confirmationprocessing— submitted to the networksucceeded— funds capturedfailed— terminal failure (see Errors)
Creating a payment
const payment = await ypp.payments.create({
amount: 125000, // ₹1,250.00
currency: "inr",
source: "ypp_src_upi_8h2k",
capture: true, // false = authorize only
metadata: { order_id: "ord_91" },
});Capturing later
Pass capture: false to place a hold on the funds. You then have 7 days to capture, after which the authorization is automatically released.
await ypp.payments.capture(payment.id);Refunds
Refunds can be partial or full. Funds are returned to the original payment method on the same settlement schedule as the original charge.
await ypp.refunds.create({
payment: "pay_8Hk9bLp",
amount: 50000, // optional, defaults to full
});