Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
cordova-sumup-plugin
Advanced tools
This plugin provides the functionality from the SumUp API for the SumUp payment terminals.
If something is wrong with the plugin feel free to open an issue or make a pull request.
Many thanks to Peter Meester for helping maintaining the plugin and adding support for iOS!
Add the plugin with the following command:
cordova plugin add cordova-sumup-plugin --variable SUMUP_API_KEY=INSERT_YOUR_KEY
SUMUP_API_KEY is the Affiliate Key which was created in the SumUp Dashboard.
If you want to change your Affiliate Key on runtime, just install the plugin like this:
cordova plugin add cordova-sumup-plugin --variable SUMUP_API_KEY=""
Make sure, the SUMUP_API_KEY value is an empty string.
If you are in development you can request test credentials. With this credentials your card (Debit- or creditcard) will not be charged. Just write a mail to:
Get global access to the plugin methods with the keyword SumUp.
If you are using Ionic , use the Ionic Native Wrapper. Install it with npm install @ionic-native/sum-up
.
Import the plugin in your app.module:
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
SumUp,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
And import and use it in every of your components:
import { SumUp } from "@ionic-native/sum-up/ngx";
@Component({
selector: "app-home",
templateUrl: "home.page.html",
})
export class HomePage {
private access_token: string = "YOUR_ACCESS_TOKEN";
constructor(private sumUp: SumUp) {}
private async login(): Promise<void> {
try {
await this.sumUp.login(this.access_token);
} catch (e) {
console.log(e);
}
}
}
If you want to try the example first, you can read more here
If you get access to the plugin with plain JavaScript by using SumUp the plugin will return a success and an error callback. Example:
SumUp.methodName(
[parameter],
function (success) {
console.log(success);
},
function (error) {
console.log(error);
}
);
SumUpKeys {
accessToken?: number;
affiliateKey?: string;
}
SumUp.login(sumUpKeys: SumUpKeys)
User will be logged in, in his SumUp account. The parameter for the login method is a SumUpKeys Object. Default, it contains two empty string values. Both values are optional.
Read more how to create and renew an access token: Create an access token
If you want to change your affiliateKey on runtime, make sure you've added the plugin in the correct way. Like described in Installation.
Now you can set your affiliate key value on the object.
SumUp.auth(accessToken: string)
Authenticates the account with the given access token. Parameter accessToken is required.
SumUp.getSettings()
Opens a new window with the all account settings of an logged in user.
SumUp.logout()
Logout a user from the account.
SumUp.isLoggedIn()
Checks whether the user is logged in or not and returns an object with the field isLoggedIn which is a boolean value.
SumUp.prepare()
Prepares the terminal for a payment. Checks whether the CardReader is ready to tramsmit and if an instance of the CardReaderManager is available.
SumUp.setup()
Will setup/initiate the SumUP SDK. Usely after App launch. For iOS, this is required before using other functions.
SumUp.test()
Test the SumUp SDK integration. Currently only for iOS.
SumUp.closeConnection()
Tries to close the connection to the card terminal.
SumUp.pay(amount: number, title?: string, currencyCode?: string)
Opens a native SumUp window to proceed a payment.
Parameter amount is required.
Parameter title and currencyCode are optional.
If no title
is provided, the title is empty.
If no currencyCode
is provided, the default currency from logged in user is chosen.
If the Payment was successful it returns an SumUpPayment object with information about the payment.
NOTE: At the moment just the required parameter amount and currencycode are available in this plugin. SumUp supports some optional parameter like:
additionalInfo can has any amount.
There are 3 types of responses from the plugin:
SumUpResponse: This response is fired from the plugin at every call. You'll get an code and an description message. In case of an exception the exception message is set to SumUpResponse.
SumUpResponse {
code: number;
message: string;
}
SumUpLoginStatus: It contains the code of the Response and an boolean value whether the user is logged in or not.
SumUpLoginStatus {
code: number;
isLoggedIn: boolean;
}
SumUpPayment: You'll get this response after a successful payment
SumUpPayment {
transaction_code: string;
card_type: string;
merchant_code: string;
amount: number;
tip_amount: number;
vat_amount: number;
currency: string;
status: string;
payment_type: string;
entry_mode: string;
installments: number;
last_4_digits: number;
}
In the SumUp Dashboard in the developer section create an app id.
https://api.sumup.com/authorize
?response_type=code
&client_id=YOUR_CLIENT_ID
&redirect_uri=YOUR_CALLBACK_URL
curl -X POST \
https://api.sumup.com/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=authorization_code'\
-d 'client_id=YOUR_CLIENT_ID'\
-d 'client_secret=YOUR_CLIENT_SECRET' \
-d 'code=CODE_FROM_QUERY_STRING'
curl -X POST \
https://api.sumup.com/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=refresh_token'\
-d 'client_id=YOUR_CLIENT_ID'\
-d 'client_secret=YOUR_CLIENT_SECRET' \
-d 'refresh_token=YOUR_REFRESH_TOKEN'
These are all the response codes from the native SumUp SDK. They are also returned to your JavaScript App.
Code | Description |
---|---|
1 | Success |
2 | Transaction failed |
3 | Geolocation required |
4 | Invalid param |
5 | Invalid Token |
6 | No connectivity |
7 | Permission denied |
8 | Not logged in |
9 | Duplicate foreign tx id |
10 | Invalid affiliate key |
11 | User is already logged in |
This plugins always returns an object with a status code to recognize if the operation was successful or not. These codes are starting at 100.
Here are all additional codes:
Code | Description |
---|---|
100 | Login error |
101 | Login canceled |
102 | Check for login status failed |
103 | Logout failed |
104 | Failed to close card reader connection |
105 | CardReader instance is not defined |
106 | Error while stop card reader |
107 | Show settings failed |
108 | Settings done |
109 | Prepare payment error |
110 | Card reader is not ready to transmit |
111 | Error while preparing checkout |
112 | Authenticate error |
113 | No access token |
114 | Authenticate was successful |
115 | Can't parse amount |
116 | Can't parse currency |
117 | Payment error |
118 | No affiliate key available |
If you want to make a payment and get the "Invalid affiliate key" error in this process it could be, you have provided the false app id.
Make sure the app id you created in your SumUp dashboard is equal to the id from your config.xml
In the folder examples/javasript you can find a plain Javascript application to communicate with a SumUp Terminal. Just insert your affiliate key in package.json and install the package with npm install.
If you want to login with an access token, you must generate an access token like described here. After generating a valid access token insert it in index.js.
In examples/ionic is an example app with Ionic.
npm install
.ionic cordova platform add [android, ios]
.ionic cordova build [android, ios]
.adb install
or open the xcworkspace
to run it on an iOS device.ionic cordova run [android, ios]
.FAQs
Cordova plugin for SumUp SDK integration
We found that cordova-sumup-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.