Chọn mô hình tích hợp ZaloPay phù hợp
translation missing: vi.docs.apptoapp.api.context.detail
t
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>zp-redirect-3</string>
<key>CFBundleURLSchemes</key>
<array>
<string>zp-redirect-3</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>zalopay</string>
<string>zalopay.api.v2</string>
</array>
translation missing: vi.docs.apptoapp.api.ios.init_zpdk.desc
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[ZaloPaySDK sharedInstance] initWithAppId:<appid>]; // translation missing: vi.docs.apptoapp.api.ios.init_zpdk.title
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// t
return [[ZaloPaySDK sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
translation missing: vi.docs.apptoapp.api.ios.init_zpdk.note
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
t
[ZaloPaySDK sharedInstance].delegate = self;
[[ZaloPaySDK sharedInstance] payOrder:zptranstoken];
r
- (void)zalopayCompleteWithErrorCode:(ZPErrorCode)errorCode
transactionId:(NSString *)transactionId zpTranstoken:(NSString*)zptranstoken {
NSLog(@"pay bill complete code = %ld transid = %@ zpTranstoken =%@",
(long)errorCode, transactionId, zptranstoken);
}
t
configurations.maybeCreate("default")
artifacts.add("default", file('zpdk-v1.0.114.aar'))
translation missing: vi.docs.apptoapp.api.android.init_zpdk.desc
@Override
public void onCreate() {
super.onCreate();
// translation missing: vi.docs.apptoapp.api.android.init_zpdk.title
ZaloPaySDK.getInstance().initWithAppId(3);
}
// t
@Override
public void onActivityResult(Activity activity, int requestCode,
int resultCode, Intent data) {
ZaloPaySDK.getInstance().onActivityResult(requestCode, resultCode, data);
}
// r
ZaloPaySDK.getInstance().payOrder(
getActivity(), zpTranstoken, new MyZaloPayListener()
);
// a
private static class MyZaloPayListener implements ZaloPayListener {
@Override
public void onPaymentSucceeded(String transactionId, String zpTranstoken) {
Log.d(TAG, "onSuccess: On successful with transactionId: " + transactionId + "- zpTransToken: " + zpTranstoken);
}
@Override
public void onPaymentError(ZaloPayErrorCode errorCode, int paymentErrorCode, String zpTranstoken) {
Log.d(TAG, String.format("onPaymentError: payment error with [error: %s,
paymentError: %d], zptranstoken: %s", errorCode, paymentErrorCode, zpTranstoken));
}
}
t
r
<receiver
android:name="vn.zalopay.sdk.MerchantReceiver"
android:exported="true">
<intent-filter>
<action android:name="vn.zalopay.sdk.ZP_ACTION" />
<category android:name="zlp" />
</intent-filter>
</receiver>
a
MerchantReceiver reciver;
ItentFilter intentFilter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
receiver = new MerchantReceiver();
intentFilter = new IntentFilter("vn.zalopay.sdk.ZP_ACTION");
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(receiver, intentFilter);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(receiver);
}
@Override
protected List<ReactPackage> getPackages() {
return Array.asList(
...,
new PayZaloBridge()
);
}
import {NativeModules, NativeEventEmitter} from 'react-native';
const { PayZaloBridge } = NativeModules;
const payZaloBridgeEmitter = new NativeEventEmitter(PayZaloBridge);
componentDidMount() {
this.subscription = payZaloBridgeEmitter.addListener(
'EventPayZalo',
(data) => {
if(data.returnCode == 1){
alert('translation missing: vi.docs.apptoapp.api.react_native.call_pay.sample_code.trans_success');
} else{
alert('translation missing: vi.docs.apptoapp.api.react_native.call_pay.sample_code.trans_fail');
}
}
);
}
componentWillUnmount() {
this.subscription.remove();
}
let payZP = NativeModules.PayZaloBridge;
payZP.payOrder(zptranstoken);
application/json
Tham số | Kiểu dữ liệu | Ý nghĩa |
---|---|---|
errorCode |
int | t 1: r #1: a |
transactionId |
String | n |
zpTranstoken |
String | s |