cordova plugin add cordova-plugin-stripe-alipay
Add code on AppDelegate.m
/**
This method is implemented to route returnURLs back to the Stripe SDK.
@see https://stripe.com/docs/mobile/ios/authentication#return-url
*/
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL stripeHandled = [Stripe handleStripeURLCallbackWithURL:url];
if (stripeHandled) {
return YES;
} else {
// This was not a stripe url – do whatever url handling your app
// normally does, if any.
}
return NO;
}
On CDVStripeAlipay.m
,add your own key!
[Stripe setDefaultPublishableKey:@"pk_live_YOUR_OWN_KEY_XXXXXXX"];
Modify scheme
#define DEFAULT_SCHEME @"cuteapp://safepay/"
Project => Target => Info => URL Types => Click + => URL Schemes: cuteapp
URLSchemes should the same as 【DEFAULT_SCHEME】 prefix
https://github.com/stripe/stripe-ios/blob/771f778fcbad58f771583ebe6fe499a2a4bc6ae8/Example/Non-Card%20Payment%20Examples/AlipayExampleViewController.swift
https://stripe.com/docs/sources/alipay/ios
Called in javascript, spend least money.
window.StripeAlipay.alipayTest(
result => {
alert("succeed:" + JSON.stringify(result));
},
err => {
alert("err:" + JSON.stringify(err));
}
);
Called in javascript
let source = `{"amount":50, "currency":"jpy","extraParams":{},"owner":{"email":"sample@sample.smp","name":"Mr. Sample"},"returnUrl":"mycompany://alipay","type":"alipay","typeRaw":"alipay"}`;
window.StripeAlipay.alipayBySourceJson(
source,
result => {
alert("succeed:" + JSON.stringify(result));
},
err => {
alert("err:" + JSON.stringify(err));
}
);
test key like pk_test_ABACDF2hitYZV1hsqU00jfHaLuse
maybe get some unknown error!
Suggest sue pk_live_XXX key.
pk_test_ABACDF2hitYZV1hsqU00jfHaLuse
Map<String, Object> alipayParams = source.getSourceTypeData();
final String dataString = (String) alipayParams.get("data_string");
get data_string all return "null",
com.stripe.android.exception.InvalidRequestException: Invalid currency: cny. The payment method `alipay` only supports the following currencies: aud, cad, eur, gbp, hkd, jpy, nzd, sgd, usd.
The currency you use should the same as your company region. not the customer's region.
your company region: 'japan', maybe you should use 'jpy'
your company region: 'America', maybe you should use 'usd'
your company region: 'china', maybe you should use 'cny' or 'hkd'(i don't know,because my company is not in china's mainland, somebody who use it may tell me the result)
com.stripe.android.exception.InvalidRequestException: Amount must convert to at least 400 cents. ¥50 converts to approximately \$3.58.
Too little money to test, add it.
Add set default key api