PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV Mobile 2024
→
Need Help Inserting Java Code
Need Help Inserting Java Code
Started by Kenny, Jan., 05 2018 8:30 AM - No answer
Connect yourself…
Kenny
#1
Posted on January, 05 2018 - 8:30 AM
I am creating a WM22 App with wallet for demo. I signed up as Masterpass developer and the following codes are their sample app.
Do not know JAVA well so seeking help with integrating to WM22. Willing to pay, drop me email.
rongkh (at) hotmail (dot) com
Thanks.
public class MainActivity extends AppCompatActivity implements MasterpassInitCallback, MasterpassCheckoutCallback {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String signature = "LOCAL_TESTING"; // will be provided by Masterpass, use "LOCAL_TESTING" to test integration
MasterpassMerchantConfiguration sampleConfig = new MasterpassMerchantConfiguration.Builder()
.setContext(this.getApplicationContext()) // context
.setEnvironment(MasterpassMerchantConfiguration.SANDBOX) // environment
.setLocale(new Locale("en-US")) // locale
.setAnalyticsEnabled(false) // analytics on / off
.setSignature(signature) // will be provided by Masterpass
.build();
try {
MasterpassMerchant.initialize(sampleConfig, this);
} catch (IllegalStateException e) {
// in case SDK already initialized
this.onInitSuccess();
}
}
@Override public void onInitSuccess() {
MasterpassButton masterpassButton = MasterpassMerchant.getMasterpassButton(MasterpassButton.WEB_FLOW_ENABLED, this);
this.addContentView(masterpassButton, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
}
@Override public MasterpassCheckoutRequest getCheckoutRequest() {
Amount total = new Amount(1000, Currency.getInstance(Locale.US).getCurrencyCode());
ArrayList
allowedNetworkTypes = new ArrayList<>();
allowedNetworkTypes.add(new NetworkType(NetworkType.MASTER));
Tokenization tokenization = getSampleTokenizationObject();
return new MasterpassCheckoutRequest.Builder()
.setCheckoutId("c71d7dddda6a4db3af6121346de08ad9").setCartId("bb9410f9-e5a7-4f14-9c99-ea557d6fe2e8")
.setAmount(total).setAllowedNetworkTypes(allowedNetworkTypes)
.setTokenization(tokenization)
.isShippingRequired(false).build();
}
@Override public void onCheckoutComplete(Bundle bundle) {
String transactionId = bundle.getString(CheckoutResponseConstants.TRANSACTION_ID);
Toast.makeText(this, "Here is the transaction ID:" + transactionId, Toast.LENGTH_SHORT).show();
}
@Override public void onCheckoutError(MasterpassError masterpassError) {
Toast.makeText(this, masterpassError.message(), Toast.LENGTH_SHORT).show();
}
@Override public void onInitError(MasterpassError masterpassError) {
Toast.makeText(this, masterpassError.message(), Toast.LENGTH_SHORT).show();
}
@Override public MasterpassCheckoutRequest getUpdatedCheckoutData(List
list, List
list1, ShippingSummaryItem shippingSummaryItem, Address address, Amount amount) {
// Only required if shipping is required
return null;
}
private Tokenization getSampleTokenizationObject() {
try {
ArrayList
format = new ArrayList<>();
CryptoOptions.Mastercard mastercard = new CryptoOptions.Mastercard();
CryptoOptions cryptoOptions = new CryptoOptions();
format.add("UCAF");
mastercard.setFormat(format);
cryptoOptions.setMastercard(mastercard);
String unpreditableNumber = Base64.encodeToString(Integer.toString(10000).getBytes("UTF-8"), Base64.NO_WRAP);
return new Tokenization(unpreditableNumber, cryptoOptions);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
}
Report
0
0
→ Go back to WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text