Skip to content

Instantly share code, notes, and snippets.

@yosriady
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save yosriady/0e4048cea9ff0bd7fbd5 to your computer and use it in GitHub Desktop.

Select an option

Save yosriady/0e4048cea9ff0bd7fbd5 to your computer and use it in GitHub Desktop.
def build_adaptive_payment_request(sheet)
trackingId = generate_token
api = PayPal::SDK::AdaptivePayments::API.new
pay_request = api.build_pay()
pay_request.trackingId = trackingId
pay_request.actionType = "PAY"
pay_request.cancelUrl = orders_cancel_url
pay_request.returnUrl = orders_success_url(trackingId)
pay_request.ipnNotificationUrl = orders_ipn_notify_url
pay_request.currencyCode = DEFAULT_CURRENCY
# Primary receiver (Sheet Owner)
pay_request.receiverList.receiver[0].amount = sheet.price #100%
pay_request.receiverList.receiver[0].email = sheet.user.paypal_email
pay_request.receiverList.receiver[0].primary = true
pay_request.receiverList.receiver[0].paymentType = "DIGITALGOODS"
# Secondary Receiver (Marketplace)
pay_request.receiverList.receiver[1].amount = sheet.commission
pay_request.receiverList.receiver[1].email = MARKETPLACE_PAYPAL_EMAIL
pay_request.receiverList.receiver[1].primary = false
pay_request.receiverList.receiver[1].paymentType = "DIGITALGOODS"
return pay_request
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment