Integrate Stripe 3D secure payments with Ionic4 - ionic-framework

I'm trying to make 3D secure stripe payments on my Ionic APP, It's easier to do it on web with iframe but the native stripe plugin on Ionic platform doesn't let us to create a source that is required for 3D card payment.
I can make payment without 3D secure but with 3D secure I have to figure out the best way to open 3D secure authentication page. That launches on popup/iframe on web.
import { Stripe } from '#ionic-native/stripe/ngx';
constructor(private stripe: Stripe) { }
...
this.stripe.setPublishableKey('my_publishable_key');
let card = {
number: '4242424242424242',
expMonth: 12,
expYear: 2020,
cvc: '220'
}
this.stripe.createCardToken(card)
.then(token => console.log(token.id))
.catch(error => console.error(error));
But can't use 3D secure with ionic-native/stripe/ is there is a way out?

Related

Swift Stripe Connect how to implement account creation

I'm seriously struggling to create a Stripe Connect account from my IOS Application using swift and firebase. I can't seem to find any documentation on how this would be possible. I creating an app which allows users to do jobs for each other which of course means pay each other. How can I implement this in my app?
I think onboarding users is the biggest difficulty in iOS because(as far as I know) their are only two ways to do this. One, is to use Stripe Onboarding which requires you to take your user to a link where stripe onboards for you. The other, option is building out your own UI flow to manually collect all the information yourself and update their account through the Stripe API.
However, creating an account is simple. Here is an example of it implemented in Node.js!
stripe.accounts.create(
{
type: 'standard',
country: 'US',
email: email,
requested_capabilities: [
'card_payments',
'transfers',
],
},
function(err, account) {
if (err) {
console.log("Couldn't create stripe account: " + err)
reject(err)
}
console.log("ACCOUNT: " + account.id)
response.body = {success: account.id}
return res.send(response)
}
);
stripe.dev/stripe-ios/docs

Braintree integration for PayPal payments in Flutter

I have to integrate PayPal payments in Flutter and the only plugin that seems to have this kind of functionality is flutter_braintree. But the documentation there is not so detailed, so I am kind of confused how to use this plugin to have real payments. My mission is to have this kind of flow: click on a PayPal button in the app and then proceed with PayPal paying to a predefined IBAN. I tried to examine the PayPal and Braintree documentations, but since there is nothing mentioned for Flutter, I am a little bit confused.
Please help me what's the right direction to go in order to fulfil my requirements. I have the following questions:
How to use this plugin and make real payments? What do I need - a client token as far as I see, but I am going to generate this in Flutter?
Where should I put the IBAN that I want the money to be transferred to?
Am I supposed to use some kind of webviews for the PayPal, or this plugin is enough?
Thank you in advance, I am really stuck on this topic and can't find a solution.
Generate clientToken in php | nodejs see: https://developers.braintreepayments.com/reference/request/client-token/generate/php
$clientToken = $gateway->clientToken()->generate([
"customerId" => '21534539348326'//create customer in panel
]);`
Generate paymentNonce in app flutter:
BraintreePayment braintreePayment = new BraintreePayment();
var data = await braintreePayment.showDropIn(
nonce: clientNonce,
amount: "2.0",
inSandbox: true,
);
print("Response of the payment $data");
// exe: Generate transaction in php | nodejs see: https://github.com/braintree/braintree_php
$result = $gateway->transaction()->sale([
'amount' => '1000.00',
'paymentMethodNonce' => 'nonceFromTheClient',
'options' => [ 'submitForSettlement' => true ]
]);

Facebook Instant game purchase issue

I am integrating InApp purchases in my game(build using cocos creator). but unable to get payments.purchaseAsync in FBInstant.getSupportedAPIs() on both Android And Facebook.com any Help please below is the my sample code.
let supportedAPIs = FBInstant.getSupportedAPIs();
if(supportedAPIs.includes('payments.purchaseAsync'))
{
console.log('payments supported...');
FBInstant.payments.onReady(() => {
console.log('payments ready...');
FBInstant.payments.purchaseAsync({
productID: 'com.test.testing',
developerPayload: '',
}).then(function (purchase) {
console.log(purchase);
});
});
}
else
{
console.log('payments not supported...');
}
Your game must be onboarded and have a company associated with it in order for payments to be enabled. You can ensure that this is set up by clicking Set Up Payout under the In App Purchase option under the developer console (developers.facebook.com).
In addition, you will need to have passed review for users who are not developers or testers of the app to access payments, and payments are not available on iOS at this time.

Unity Facebook Canvas Inapp Purchase Error

I've been trying to make the facebook canvas inapp api working for my game virtual items for quite some time without any success.
Its unity made game running in facebook canvas iframe with WebGL.
I am using the following code to make the transaction...
FB.Canvas.Pay (product: "productID",
quantity: 1,
callback: delegate(IPayResult response) {
Debug.Log (response.RawResult);
if(onProductPurchasedSucceed != null) {
if( response.ResultDictionary["status"] == "completed"){
onProductPurchasedSucceed("productID");
}
}
}
);
When I invoke this method from canvas page.. This is what I ended up with
Since its a simple game I chose facebook hosted feature to upload my game assets. I have no idea what to fill in App Domains field.
I tried to setup apps.facebook.com, but its not accepting

Paypal Adaptive payment for mobile web

Im integrating Paypal Adaptive Payment API for a mobile website.
But when Im submitting payment to
https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value
( For Sandbox : https://www.sandbox.paypal.com/cgi-bin/webscr )
Its always redirecting to Paypal Main Web. Not to Paypal Mobile website.
How to redirect client to paypal mobile web?
Try redirecting your site to
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-XYZ&expType=mini
Fill your pay key in place of AP-XYZ
Let me know if it works.
The best approach I found was mini browser experience. But I had a variety of different issues on mobile devices implementing it (which is what it was meant for in the first place). You will see many similar questions about adaptive payments and all sorts of issues with using lightbox and mini browser experience.
But FINALLY... I have figured it out after hours upon hours, days upon days! This should solve everyone's problems of all different varieties when it comes to issues with PayPal Adaptive Payments and the issues with:
The default redirected paypal page is NOT mobile responsive and looks horrible on mobile devices.
The lightbox gets "hung up" and does not close on some mobile devices.
The mini browser doesn't close after completing payment or cancelling.
The mini browser doesn't redirect to the callBackFunction from paypal apdg.js script.
Not redirecting to returnUrl and cancelUrl after payment completion (or when cancelling)
Chrome for ios (iphones) doesn't initiate the callbackfunction and therefore after payment completion or cancellation, it just keeps you at the page you launched the paypal payment page from which prevents you from validating success or failure of payment.
Drum roll please.... here it is!! This replaces any need for PayPal javascript files etc. All you need is what is below along with your own method of obtaining the PayKey to add to the redirect url. My live website, with adaptive payments working correctly using below code, is https://www.trackabill.com.
<div>
<?php $payUrl = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=mini&paykey=' . $payKey ?>
<button onclick="loadPayPalPage('<?php echo $payUrl; ?>')" title="Pay online with PayPal">PayPal</button>
</div>
<script>
function loadPayPalPage(paypalURL)
{
var ua = navigator.userAgent;
var pollingInterval = 0;
var win;
// mobile device
if (ua.match(/iPhone|iPod|Android|Blackberry.*WebKit/i)) {
//VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
//See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
win = window.open(paypalURL,'_blank');
pollingInterval = setInterval(function() {
if (win && win.closed) {
clearInterval(pollingInterval);
returnFromPayPal();
}
} , 1000);
}
else
{
//Desktop device
var width = 400,
height = 550,
left,
top;
if (window.outerWidth) {
left = Math.round((window.outerWidth - width) / 2) + window.screenX;
top = Math.round((window.outerHeight - height) / 2) + window.screenY;
} else if (window.screen.width) {
left = Math.round((window.screen.width - width) / 2);
top = Math.round((window.screen.height - height) / 2);
}
//VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
//See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
win = window.open(paypalURL,'_blank','top=' + top + ', left=' + left + ', width=' + width + ', height=' + height + ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1');
pollingInterval = setInterval(function() {
if (win && win.closed) {
clearInterval(pollingInterval);
returnFromPayPal();
}
} , 1000);
}
}
var returnFromPayPal = function()
{
location.replace("www.yourdomain.com/paypalStatusCheck.php");
// Here you would need to pass on the payKey to your server side handle (use session variable) to call the PaymentDetails API to make sure Payment has been successful
// based on the payment status- redirect to your success or cancel/failed page
}
</script>
There is actually a simple solution to this that isn't documented anywhere. We were in discussion with PayPal about adding it a while back so I am wondering if it eventually got implemented.
Anyway, simply just redirect the user to the following URL and they will be redirected back to your site on completion:
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapproval?preapprovalKey=PA-XXXXX&expType=redirect
The difference here is using expType=redirect rather that expType=mini. I'm not sure when this was added but after a bit of reverse engineering and some experimenting we have a surprisingly simple solution.
that's right - the Adaptive Payments UI is not Mobile optimized. But the closest to that it offers is what we call the MiniBrowser experience. You can try and see if that serves your needs. You can find the how-to guide here on X.com: Implementing the Mini-Browser Option