(Go: >> BACK << -|- >> HOME <<)

Page MenuHomePhabricator

Implement backend for DLocal recurring UPI payments in SmashPig
Closed, ResolvedPublic8 Estimated Story Points

Description

https://docs.dlocal.com/docs/india-recurring-payments

  • Payment_method_id for this will be 'IR' (India recurring)
  • initial recurring setup will be a new API call to 'create a subscription', where we specify the schedule
{
   "amount": 0,
   "currency": "INR",
   "country": "IN",
   "payment_method_id": "IR",
   "payment_method_flow": "REDIRECT",
   "payer": {
       "name": "Ram Devi",
       "email": "ramdevi@example.com",
       "phone": "+919000123456",
       "document": "HSECT4378A"
   },
   "wallet": {
       "save": true,
       "verify": true,
       "recurring_info": {
           "subscription_frequency_unit": "ONDEMAND",
           "subscription_frequency": 1,
           "subscription_start_at": "20210101", # note: needs to be current day in India Standard Time (GMT+5:30)
           "subscription_end_at": "20220101" # mandatory field, but you can set it to very far in the future. It will be shown to the donor.
       },
       "capture": false
   },
   "order_id": "5346523564",
   "notification_url": "http://merchant.com/notifications",
   "callback_url": "http://merchant.com/callback"
}
  • recurring installments will look like the createPayment call, but with a prenotify flag set to true. Indian recurring payment regulations require us to send a charge pre-notification one day ahead of time. We then wait one day for the notification from DLocal telling us the payment came through to record the payment.
  {
   "amount": 750,
   "currency": "INR",
   "country": "IN",
   "payment_method_id": "IR",
   "payment_method_flow": "DIRECT",
   "payer": {
       "name": "Ram Devi",
       "email": "ramdevi@example.com",
       "phone": "+919000123456",
       "document": "HSECT4378A"
   },
   "wallet": {
       "token": "W-yu23y4ibnyiu23y4",
       "recurring_info": {
           "prenotify": TRUE
       }
   },
   "order_id": "5346523565",
   "notification_url": "http://merchant.com/notifications"
}

General notes on UPI recurring (move these to another place?)

  • limit of 5000 rupees
  • Dlocal will send donors to PayTM (Indian payment processor) to make these charges
  • Donor can choose in the PayTM site whether to pay with their PayTM wallet (like paying with PayPal balance) or UPI, but both of those will appear the same to us. Note that we can decide whether to offer that choice to donors or to only offer one (UPI is preferred) to streamline the process. Setting up this option has to be coodinated with DLocal and PayTM, so it's not a really quick switch.

Event Timeline

Ejegg updated the task description. (Show Details)
Ejegg updated the task description. (Show Details)
Dwisehaupt set the point value for this task to 8.Jan 12 2023, 6:07 PM

dlocal mentioned that the recurring start date needs to be an Indian date set to India's time zone.

India Standard Time (GMT + 5:30)

Ejegg updated the task description. (Show Details)

Change 891327 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/dev@master] Add dlocal india bank transfer recurring payment link

https://gerrit.wikimedia.org/r/891327

Change 891328 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/SmashPig@master] WIP: Add bank transfer for india recurring subscription request

https://gerrit.wikimedia.org/r/891328

Change 890364 had a related patch set uploaded (by Wfan; author: Wfan):

[mediawiki/extensions/DonationInterface@master] India recurring di configs

https://gerrit.wikimedia.org/r/890364

Change 891327 merged by Wfan:

[wikimedia/fundraising/dev@master] Add dlocal india bank transfer recurring payment link

https://gerrit.wikimedia.org/r/891327

Change 894131 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/SmashPig@master] Add unit test for upi recurring

https://gerrit.wikimedia.org/r/894131

Add bank transfer for india recurring subscription request

Test:

first subscription and init payment:
if from web:
go to https://localhost:9001/index.php?title=Special:DlocalGateway&appeal=JimmyQuote&payment_method=bt&payment_submethod=upi&recurring=1&uselang=en&language=en&currency=INR&amount=505&country=IN&first_name=Jimmy&last_name=Wales&fiscal_number=AAAAA9999C&submethod=upi&email=jwales%40example.com&debug=true to make first init recurring payment, then from the redirect link, use Paytm and phone 7777777777 with OTP 489871 to complete the first init payment.
if from script:
go to smashpig box, run php PaymentProviders/dlocal/Maintenance/CreateIRRecurringSubscription.php <orderid> <Amount>, hint: if put amount more than 5000, will get a validation error as "Should under 5k INR", otherwise will get the redirect url, then go to get redirect link, then use Paytm and phone 7777777777 with OTP 489871 to complete the payment.

for recurring charge:
if get the token from ipn:
go to smashpig_syslog, check get the token from there, and then based on the token, run php PaymentProviders/dlocal/Maintenance/ChargeRecurringIR.php testid <amount opitonal, any less than 5k otherwise use the orignal amount> <token from ipn listner>

if check the payment detail for token:
run php PaymentProviders/dlocal/Maintenance/ChargeRecurringIR.php <gatewa_txn_id starts from F from dlocal (if from webpage, find the gateway_txn_id from log/payments-syslog, if script, from printed result)> <amount opitonal, any less than 5k otherwise use the orignal amount>

Finally, check the status with pending for recurring, and paid for init from dlocal dashboard

Change 895895 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/dev@master] Add amount limitation for dlocal

https://gerrit.wikimedia.org/r/895895

Change 890364 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] India recurring di configs

https://gerrit.wikimedia.org/r/890364

Change 891328 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Add bank transfer for india recurring subscription request

https://gerrit.wikimedia.org/r/891328

Change 895895 merged by Cstone:

[wikimedia/fundraising/dev@master] Add amount limitation for dlocal

https://gerrit.wikimedia.org/r/895895

Change 894131 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Add unit test for upi recurring

https://gerrit.wikimedia.org/r/894131

Change 898041 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/dev@master] Add amount limitation for dlocal certain payment method

https://gerrit.wikimedia.org/r/898041

Change 898234 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/SmashPig@master] Only convert to subscription if upi also set a default phone for india in cc

https://gerrit.wikimedia.org/r/898234

Change 898234 abandoned by Wfan:

[wikimedia/fundraising/SmashPig@master] Only convert to subscription if upi, only set wiki phone as default for india cc

Reason:

No need to worry the manually manipulated URL

https://gerrit.wikimedia.org/r/898234

Dwisehaupt set Final Story Points to 8.