Split/Deferred payments through apple pay - ios

On the getting started page for Apple Pay, it says that Apple Pay supports "partial shipments." How is this implemented in practice? I know how to get a token from a successful PKPayment. Once I get that token, how do I use it to implement multiple sub-order payments through my payment gateway?
For example, say the user validates a total $100 purchase through Apple Pay of two separate suborder shipments ($40 and $60 each) and I now have an associated token for the $100 order. Because of restrictions on some networks, we can't capture each payment until the associated item has been shipped, and they ship at different times.
Do I have the ability to authorize and capture payments of any amounts using that token?
What is the best approach to authorizing and capturing those sub orders?
Do I auth for the total ($100) and then auth for each sub total ($40, $60) at shipment and then capture for each sub total? If so, then I will be potentially authorizing more than the necessary total ($200), and that doesn't seem right. Is it valid to just skip auth for the total, auth for each sub total, and then capture the sub totals as they ship?

You can't capture an authorization more than once. For stripe you would need to save the token to a customer, and charge the customer for each shipment separately. This isn't only the best way it is the only way to do it.
Once you have a token and attach it to the customer object in stripe, you have the ability to charge it at any time & any amount up until the expiration date or if they remove the card from their apple pay account, like you would any other card regardless of the initial authorization.
The rest of your questions will vary by opinion as there are different ways of doing it, but here is how I would charge this type of order. I think this method benefits both the business and the customer, in addition to keeping stripe/apple happy. This isn't apple pay specific, I would treat most orders with these requirements the same. Also keep in mind apple pay supports it, but it is not required. You can collect all up front regardless of shipment dates.
Generate token from PKPayment for $100
Create customer(if needed) & add token to customer
Create charge against customer using that card for $100 without
capture
Within 7 days assess expected shipping dates.
Once assessment is complete immediately capture only the amount
expected to ship within a week on the initial charge. In your
example this is where I would capture $40 for the first charge. If
nothing is expected to be captured issue a complete refund.
Any shipments beyond the 7 days, create individual charges for the
shipments using the customer object, not the token. Again in your example this is when the $60 shipment goes
out charge that here.
As long as the second shipment charge doesn't happen to go out earlier than the 7 days this would prevent any authorizations overlapping resulting in holds of more than the initial amount at any given moment. I would treat almost any transaction like this apple pay or not.

Related

Authorize a transaction with unknown amount, and charge the amount for the service later

I'm developing a kind of Car Booking iOS Application; and I want to develop following kind of process for payment :
Want to implement Consumption based payment for my App Users. Rather than pre-payment; User will do Post Payment based on his Usage.
In my Application, User will book a Car ---> He can use it for as many Hours as he wants to use. E.g. he used it for 10 Hours ---> And at the time of submitting car back ---> System automatically deducts the money from his credit card for his usage.
So, e.g. Hourly Rate is 2$/Hour and User used it for 20 hours; than system will deduct 40 $(2*20) From his credit card.
My Plan is to Use Apple Pay,I got below information : https://developer.apple.com/apple-pay/get-started/
Transaction type : Authorization unknown amount & capture
Description : Authorize a transaction with unknown amount, and charge
the amount for the service later
Example : Taxi ride
I have read apple pay document and see apple pay video from here :
https://developer.apple.com/videos/play/wwdc2015/702/
https://developer.apple.com/apple-pay/get-started/
https://dzone.com/articles/integrating-your-ios-app-apple
https://developer.apple.com/apple-pay/Getting-Started-with-Apple-Pay.pdf
I have also refer following demo:
I'm buildingn my iOS Application in Objective C.
https://developer.apple.com/library/content/samplecode/Emporium/Introduction/Intro.html
https://github.com/prolificinteractive/applepay-demo
https://www.raywenderlich.com/87300/apple-pay-tutorial
also refer :
Paypal - charge customer an unknown amount at a later date
Now I want to know is there any best option than apple pay? Or how can I achieve above requirement using Apple Pay.
My main goal is to take automatic payment from user after he/she used my services.
Please give me your opinion for the same and How can I use Transaction type?
Thanks in Advance.
Here is an explanation from apple developer pages:
If you do not know the actual cost when the payment is authorized (for example, a taxi fare), make a subtotal summary item using the PKPaymentSummaryItemTypePending type and a 0.0 amount. For the grand total, use a positive non-zero amount and the PKPaymentSummaryItemTypePending type. The system then shows the cost as pending without a numeric amount.
https://developer.apple.com/library/archive/ApplePay_Guide/CreateRequest.html#//apple_ref/doc/uid/TP40014764-CH3-SW2

Auto deduct money from the paypal transaction to send it to app owner

I have a scenario, I am working in the phone gap iOS application which able a user to buy and sell a commodity. Take three persons A(Owner of the app),B(Seller),C(Buyer).
B wants to sale a commodity and C want to buys it. C agreed upon a common point and proceed with the payment. Now when the C pays for the commodity i want to shift 2% of the amount to the A account and rest of the payment to the B.
I am aware this is done over the websites and there are plenty of examples. I want to know few things:
Is it possible in phone gap application, does paypal sdk allow to do so.
how could i do the two transaction in one single go, in case i need to do both the things manually.
Is this thing can be automated or this will be handled manually at the back end.
Here is the link for the phone gap plugin that i am using for app.
If anyone could guide me to any doc which explains this or any helping material that will be a great help. I have been reading and searching over net but could not get any help.
Thanks in advance
1) It's definitely possible as it's just a matter of making API calls. The SDK should handle it for you, but if not you could always build the requests yourself.
2) You could do either a parallel payment (where the payer would see both receivers during checkout) or a chained payment (where the payer would only see the primary receiver during checkout.)
Most people doing this sort of thing like to hide the split, so I'll assume you want to do a chained payment. You'll make a request to the Pay API with a primary receiver set to the seller and the secondary receiver set to you.
You'll set the primary receiver amount the full amount and the secondary receiver to their amount accordingly. For example, if $100 is paid the primary receiver amount would be $100 (not $98) and the secondary receiver would be $2.
I would definitely recommend reviewing the Adaptive Payments documentation which has a lot of detail about chained payments and how it all works.
3). Both transactions will automatically happen when the payer completes the checkout.

Rails: model setup for school charges

I know this is supposed to be simple but I'm having trouble coming up with a good, simple setup.
I'm building an app for a school. The school charges for things like pre-registration fee, supply fees, monthly enrollment, etc.
The most important aspect of billing is the monthly enrollment. Let's say it's $50 per month. I want to setup recurring billing (maybe with Stripe), but some people might choose to pay cash, or check or one-time credit card charge, instead of an automatic monthly withdrawal from their account.
Also, fees other than monthly enrollment, such as supply fees, books and such.
I was thinking about creating an Invoice setup, which I already have from another app (kinda like Freshbooks or Blinksale, [Item, LineItem, Tax, Invoice, Payment, etc]) but I thought that might be overkill.
So how would you set this up? Important points...
Ability to charge a monthly recurring fee and other one time charges
Able to track if item is due or if it has been paid
Track if monthly enrollment has been paid, MAKING A RELATIONSHIP between the payment and the monthly enrollment
I would just have a payments model. It would have a frequency (monthly, quarterly, half-yearly, yearly), payment status(paid or pending) and due date and type of fee(pre-registration, supply, etc)
If a guy opts one time payment in beginning, he would have all payments inserted and due date would be the current date and all the statuses would be paid.
If he opts for some fees to be paid monthly, he will have 12 records in payment table with frequency 'monthly'. The due date would be spaced one month apart each. The status of the last 11 records would be pending.
You can now track the list of payments whose due date is within next one month and take appropriate action.

Reserve amount that will fall back at a specific time if not used

I'm developing an app in Ruby on Rails where companies buy advertising campaigns. First they buy credits to their account on my site, then they buy the campaigns with the credits. The thing is the campaign is payed per view/click. A company reserves a budget of credits for each campaign and these reserved credits can't be used to buy other campaigns with. When a campaign ends and not all credits are used they will be un-reserved and available to buy more campaigns for.
How do I structure the models in the database and how to move/reserve/un-reserve the credits in order to periodically check for any credits that should be un-reserved in a background process?
Have a client/campaigns relationship. Each client has a number of credits. Each client campaign can withdraw credits from the client. As a campaign is viewed/clicked it withdraws credit from the client campaign.
A process periodically checks for lapsed campaigns. When it finds one, any remaining credits are deposited back to the client's main account.
All the money is kept in the company's account all the time. The goal is then to dynamically calculate how much of the funds that are reserved and how much that are not. This can be done if every campaign have a reserved amount attribute and a used amount attribute. When a user clicks on the campaign I withdraw money from the companies account and add them to the campaigns used account.

Recurring billing with Rails and ActiveMerchant: Best practices, pitfalls, gotchas?

We are prepping for the release of a large web application that has been in development for the past year. We are about to start the process of integrating ActiveMerchant to handle recurring subscription fees for the service.
I am looking for any advice regarding best practices considering our requirements (listed below) and any additional heads-up for common pitfalls or specific issues I should be giving special consideration. The payment gateway we will be using is PaymentExpress as it's one of the few supported gateways that has recurring billing and doesn't have any special conditions for companies operating outside of the USA. The business behind this application is based out of the UK.
Users of the application create an account with a sub-domain where they can access and customise the application and their data. Below are some of the requirements/features that might have an effect on how billing works:
All users get a 30 day trial
There are different plans, including a free one
Higher priced plans have larger limits on the amount of data (e.g. users, projects, etc) they can have in their account
Billing period will be monthly, beginning after trial
There will be discounts/coupon codes to get a percentage off the normal price for a year on plans, etc.
Plan pricing will change as features are added
Specific hurdles I can foresee will be things including the following:
How to handle downgrading when they violate the plan limits for lower level plans.
Behaviour when credit cards expire or payments don't go through (a read-only mode enforced, perhaps)
When plan pricing changes, we want to honour previous prices for existing users for a time period (such as 6 months), then start charging higher rates. If the plan price decreases, it will take effect immediately.
Other advice that would be helpful would be anything regarding flow of the application. How should billing forms be presented to the user? When should credit card information be required? How should invoices be sent, stored, and accessible?
I should disclose that we plan to base a lot of the code base off SaaSy. SaaSy is designed to be used as a separate Rails app that handles all the signup and account management side of things. However, this doesn't work for us since we never planned for this from the beginning and it would be a tedious process to adapt our application to work like that. Consequently, we'll be pulling code and ideas from SaaSy and merging them into our app, a considerably less tedious task.
One thing I wanted to add: keep in mind you don't need to use the recurring billing feature that is built into the gateway. In general these systems are legacy and very difficult to deal with, we get spoiled in the rails world.
You get a lot more flexibility just using them for one purpose (to bill a credit card, and perhaps also store credit cards for PCI compliance). Then roll your own recurring billing in your rails app with a cron job, a date field for when they are paid through, and amount each person is paying (in case they used a coupon) etc.
One small example: sometimes people will cancel a monthly subscription in the middle of the month. They want to make sure they don't forget to cancel before the next payment. Most gateway recurring billing that I've seen will instantly terminate the account (or send you a message indicating this). In reality, the user has paid through the end of the month and should be given 2 more weeks of access. You can do this if you have rolled your own recurring billing in rails, but not if you are using the gateway recurring billing. Just a small example.
RailsKits has a Software as a Service kit that should do what you need. It has built-in support for free trials, upgrading, downgrading, plan limits, etc., and it supports PaymentExpress (and some others).
I've researched it a bit for a project I'm doing, but I haven't purchased it yet so I can't vouch for it. However, I have seen a few blog posts praising this kit.
While the RailsKit is relatively inexpensive when compared what it would cost you to implement all of its features yourself, there are a couple open source versions out there that aim to accomplish the same thing. The one I remember off the top of my head is called Freemium.
EDIT: I forgot to mention that Ryan Bates said in his most recent Railscast that his next episode or two will deal with recurring billing, so keep an eye out for that. He usually does one episode per week, and the five he's done since December 22 all cover handling payments of different types.
Peepcode has a PDF for sale(70 pages) that details various aspects of payment processing and industry practices for this. It may be worth checking out:
http://peepcode.com/products/activemerchant-pdf
I'm also in the middle of setting up a subscription based website and these are our current requirements. They may help you regarding best practice:
Users will be able to choose one of
the subscription plans.
Users will be required to enter their
credit card details to sign up to
their chosen plan.
All major credit and debit cards must
be accepted including Maestro and
American Express.
Each plan will have a 30-day free
trial so users' credit cards should
only be charged after the 30-day
period expires. However, the validity
of credits cards should be checked at
the time of sign up.
Users will be emailed a few days
before their credit card is charged
to notify them that they will be
charged soon unless they cancel their
account. If they cancel their account
within their 30 day free trial, their
credit card should not be charged.
After any free trial period, users
will be charged in advance for their
use of the system - ie they will
pre-pay.
Users will be charged automatically
every month for their chosen plan.
Each month, users will be sent an
email a few days in advance to notify
them that they will be charged. Once
payment has been made, users will be
emailed an invoice showing that their
payment has been received.
Users will be able to upgrade or
downgrade their accounts at any time.
When users upgrade/downgrade, their
next subscription charge will be at
the new rate. Users will only be able
to downgrade their accounts to a plan
that can handle their data. For
example, if they currently have 10
active projects they can't downgrade
to the Basic plan because the Basic
plan only allows 5 projects. They
will have to delete or archive 5
projects before you they can
downgrade to Basic.
Users will be able to log in to their
account and change or update their
credit card details.
Users will be able to cancel their
account at any time. There will be no
further subscription charges after a
user has canceled their account.
However, users will not be refunded
for part of the month they have
already paid for.
All parts of the payment system must
be 100% PCI DSS compliant; including
any 3rd party systems.
The payment system must support
automated notification and retry of
failed subscription renewals.
The payment system must support
discount vouchers with expiry dates.
Credit card details must not be
processed by or stored on our servers
they should always be processed/stored by our 3rd party
payment processing partner. We do not
want responsibility for securing
these details and complying with
legal rules and regulations.
Users will be able to log into their
accounts and see a full billing
history including dates and amounts
paid. We will also need to be
able to log in to a system to see
customer payment plans and payment
history. This will be essential for
customer service.
We've also been looking at http://chargify.com/ which looks like it could save a lot of coding time.

Resources