When a customer wants to choose his payment method while creating a sale order I see it changed in the DropInUI(small tick mark) and I assume that should become the default payment method but that is not what happens at my server, I still get the payment token for the first one.
Here's what I'm doing:
String token = btGateway.customer().find(customerId).getDefaultPaymentMethod().getToken().toString();
Case:
Customer A places an order with his credit card - All Good
Customer A places another order, this time adding a paypal account and the drop in ui shows two options, customer selects his preferred payment method - All good
At my server I don't get a different payment token for credit card and paypal.
UPDATE:
Based on the Ryan's answer, I have a new query: How do you get the token for the payment method selected from the dropin(is there a delegate method that returns the payment method in iOS). Is there a way to identify the payment method selected by user so I fetch the token for it?
When you select a payment method from the DropIn, that payment method does not automatically get set at the customer's default. If you want to set a default payment method, you can do that via the SDK.
The card that gets displayed in the DropIn is most recently used card.
If you have any other questions, please feel free to email us at support#braintreepayments.com.
All right, after nice inputs from Ryan and here. I figured out a way to make my payment method as default and fetch its token to make a sale with that later on. Later on since I am using marketplace I can't create a sale with service fee so I fetched the payment method from the token and went on to make a sale. Not sure if what I did is the best way but it serves the purpose.
Here's what I did:
Make the user selected payment method as default and save its token:
if(customerId!=null){
PaymentMethodRequest request = new PaymentMethodRequest()
.customerId(customerId)
.paymentMethodNonce("paymentMethodNonceFromClient")
.options()
.makeDefault(true)
.done();
Result<PaymentMethod> result = (Result<PaymentMethod>) btGateway.paymentMethod().create(request);
if(result.isSuccess())
token = btGateway.customer().find(customerId).getDefaultPaymentMethod().getToken().toString();
Later on when making a transaction find the payment method and apply fee if it is a CreditCard:
PaymentMethod payMethod = btGateway.paymentMethod().find(token);
if(payMethod instanceof CreditCard){
request = new TransactionRequest()
.amount(new BigDecimal(txnAmount))
.paymentMethodToken(token)
.merchantAccountId("merchantAccountId")
.serviceFeeAmount(new BigDecimal(serviceFee));
}else{
request = new TransactionRequest()
.amount(new BigDecimal(txnAmount))
.paymentMethodToken(token);
}
Related
I am using checkout-one-time-payments for stripe for subscription and one time payments.This is the demo link from stripe https://70p1h.sse.codesandbox.io/.
I am able to successfully collect payments for one time and subscription products . What I want to do now is to show a page that shows all the saved cards for the particular user if user has already made payment from stripe and then if user selects the pre saved card ,I want to move the customer direct to payment confirmation or failure. Dont want the user to re enter the card details and other info
I am using following code in backend for java
SessionCreateParams.Builder builder = new SessionCreateParams.Builder()
.setSuccessUrl(createcheckoutSessionRequest.getSuccessUrl() + "?session_id={CHECKOUT_SESSION_ID}").setCancelUrl(createcheckoutSessionRequest.getFailureUrl())
.addPaymentMethodType(PaymentMethodType.CARD)
.setMode(product.getIsSubscriptionProduct() ? SessionCreateParams.Mode.SUBSCRIPTION
: SessionCreateParams.Mode.PAYMENT)
I am quite confused with all these docs ,I am not able to find the actual scenario in docs ,any help will be really appreciated. Thanks
Using a customer's saved cards is not something that is currently supported by Checkout.
If you want to build this functionality yourself you'd have to do the following:
Retrieve all of a Customer's Payment Methods using the Stripe API (https://stripe.com/docs/api/payment_methods/list).
Once a Payment Method has been selected, use it along with the Customer ID to create a Payment Intent (https://stripe.com/docs/payments/save-during-payment#web-create-payment-intent-off-session) or a Subscription (https://stripe.com/docs/api/subscriptions/create).
Depending on the status of payment, redirect to your own success or failure page.
Stripe now supports using a customer's saved cards in Checkout.
This feature is automatically enabled in Checkout unless the 'Link with Stripe' feature is disabled in Stripe Settings. You may find more information about this in the docs.
Is there any way to pass the saved payment method directly to session object?
Yes. Pass a Customer object with an attached card payment method to a Checkout Session, and Checkout will prefill that customer’s previously saved card details so they can complete the payment with a 1-click checkout experience. You can read more about this in the docs.
Source: Stripe support
to integrate PayPal payment into Java web application ,i use this link Text,
but when i verify the paypal sandbox account for both buyer and seller i found the transaction will be added but it has a "pending" status and the money is not changing,so i want to complete the transaction to transfer money from buyer to seller and paypal inform me whether the transaction is successful or not.
I found the transaction will be added but it has a "pending" status
There are a few possible reasons for this, one is simply the expected behavior of requestPayment.setIntent("authorize");. You may simply want to change that to "sale" if it's not being captured automatically by the guide you were following.
Another possible reason is the currency if it is new to that sandbox receiver account. Log into the receiver account via https://www.sandbox.paypal.com , and see if you can accept one of the payments in the new currency, which will open a currency balance. Future payments won't be pending.
Also ensure the sandbox Business account receiving the payment has a confirmed email in the sandbox environment...
Log into it at https://www.sandbox.paypal.com/businessprofile/settings/email
Send the confirmation from there, if necessary
Read and proceed with the confirmation, via https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fnotifications%2F
Hi I am writing a REST web application and confused on how to handle the payment via Stripe.
I am unclear on when to create order, below is 2 approaches I have thought:
First approach
User enters order details and clicks place order.
Order gets created in database with a boolean flag is_active and orderId is sent to UI.
user gets redirected to stripe payment page.
user enters card details and we get stripe token for charging card
token with orderId sent to backend.
token is used in backend to send request to Stripe to charge user, if charge success then mark order as active otherwise report failure to user.
Second approach
User enters details and clicks place order.
user gets redirected to stripe payment page.
user enters card details and we get stripe token for charging card
token with orderdetails sent to backend.
token is used in backend to send request to Stripe to charge user, if charge success then create order otherwise report failure to user.
which of the above two approach should I use or is there any other way through which I should be handling the payments?
I would only use the first option if building an order was such a lengthy or high-stakes process that you would want to persist a dead candidate order.
The second approach is fine. I would suggest splitting the process of saving a card off from the process of submitting an order; so you have two API calls that can do their error handing separately.
User enters order details and clicks "Next".
User is sent through the Stripe payment page (or your own on-site stripe integration).
The Stripe token is sent to the backend and saved as a/the payment method for the user.
The user clicks "Submit".
Order details are sent to the backend.
Token is used to request the charge, etc...
I am using the Paypal Java Rest API.
I build a payment object.
I run the payment.create(accessToken).
Then send the user off to paypal.
The user returns from paypal after entering shipping and payment information.
The user comes back to my site.
I then execute Payment p = Payment.get(accessToken, paymentId);
I get the payment but it does not have the shipping information.
I can get the shipping information if I:
PaymentExecution paymentExecution = new PaymentExecution(payerID);
Payment executedPayment = createdPayment.execute(accessToken, paymentExecution);
Then the payment object will have all information about the transaction.
I don't want to execute the payment yet. I just want the shipping information so I can show shipping options. Then after the user accepts the order I can execute the payment (either sale or auth).
I just want the shipping information when the customer returns to my site before taking or authorizing the payment.
Thanks
Mark
Unfortunately, at this time, the shipping information is only returned in the Execution response. There are discussions to modify this for future releases.
I made a DoExpressCheckoutPayment call with following detail and success.[Of course the call is made after the successful SetExpressCheckout call]
METHOD=DoExpressCheckoutPayment&
VERSION=93&
PWD=MyPassword&
USER=User&
SIGNATURE=Signature&
PAYMENTREQUEST_0_PAYMENTACTION=Order&
PAYMENTREQUEST_0_AMT=85.0&
PAYMENTREQUEST_0_CURRENCYCODE=USD&
IPADDRESS=localhost&
BUTTONSOURCE=PP-ECWizard
The Response details from above call
PAYMENTINFO_0_REASONCODE=None, PAYMENTINFO_0_TAXAMT=0.00, PAYMENTINFO_0_ERRORCODE=0, PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=AHYPGLSVNYNYC, BUILD=6118442, PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout, PAYMENTINFO_0_ORDERTIME=2013-05-30T11:26:49Z, PAYMENTINFO_0_PROTECTIONELIGIBILITY=None, CORRELATIONID=c7061e7e201b4, SUCCESSPAGEREDIRECTREQUESTED=false, INSURANCEOPTIONSELECTED=false, PAYMENTINFO_0_CURRENCYCODE=USD, PAYMENTINFO_0_PAYMENTSTATUS=Pending, PAYMENTINFO_0_AMT=85.00, PAYMENTINFO_0_TRANSACTIONID=O-3M746191252284215, PAYMENTINFO_0_ACK=Success, VERSION=93, PAYMENTINFO_0_PAYMENTTYPE=None, PAYMENTINFO_0_PENDINGREASON=order, ACK=Success, SHIPPINGOPTIONISDEFAULT=false, TIMESTAMP=2013-05-30T11:26:49Z, TOKEN=EC-9J328055AB342102B
(I have modified response and convert response into HashMap)
I have created two test accounts in Paypal Sandbox
One is Business Account and one is Personal Account.All has opening Balance of 5000 USD.
Everything works fine except one thing.
The buyer account shows the Order Detail as shown in following figure as Pending only and does not debit itself. the balance as same as it was the last.
The Merchant's account shows the order detail but same as the account is not credited and balance is not updated as shown in following figure.
Now if i look at the Sandbox notifications i can see some text for Buyer account only and not for Merchant's account as shown in following figure.
What i am missing here ?
Why the amount is not debited from buyer and credited to Merchant's ?
why the transaction status is Pending ?
I found 3 similar questions on SO match my problem and some of the questions on the internet , i tried all the solutions but could not success .
Payment Review is tuned off in My Sandbox Business Account.
If you need me any more detail from me please ask feel free to ask me.
Thanks
The reason that your transaction is showing pending is because you processed this as an order. You can also see the pending reason in the response that you provided.
PAYMENTINFO_0_PENDINGREASON=order
You need to go back now and perform a transaction against the order to actually charge the buyer and this will move the funds from the buyer account to the seller account. For example you can go back and perform an Authorization against the order using the DoAuthorization API and then once that is completed you can run the DoCapture API to complete the purchase.
If you are not wanting to process the transaction as an order initially, you can process it as a "Sale" rather than an "Order", and this will take the money up front when you complete the DoExpressCheckoutPayment API call.