Angular SDK

The Angular SDK is written and intended to be used with Angular 17

To seamlessly integrate Appcharge’s Checkout Angular SDK into your application, follow these steps:

  1. Install the SDK:
    In your app, execute npm i appcharge-checkout-angular-sdk to install the Appcharge Checkout Angular SDK.
npm i appcharge-checkout-angular-sdk
  1. Integrate the Library:
    Add AppchargeCheckoutModule your module.ts file of the component
@NgModule({
  declarations: [
		...
  ],
  imports: [
		...,
    AppchargeCheckoutModule,
  ],
  providers: [],
  bootstrap: [...]
})

In the HTML of your component, add the appcharge-checkout component, make sure the appcharge-checkout component is shown only once you have the checkoutUrl and sessionToken you fetched via a backend to backend API call.

<appcharge-checkout
	[checkoutUrl]="checkoutUrl"
	[sessionToken]="sessionToken"
	[onClose]="closeCheckout">
</appcharge-checkout>
  1. Appcharge's checkout component allowed properties:
PropTypeMandatoryParams availableDescription
checkoutUrlstringYesNoThe checkoutUrl as provided by the "backend-to-backend" request
sessionTokenstringYesNoThe session token as provided by the "backend-to-backend" request
onCloseFunctionNoYesThe checkout popup has closed
onOrderCreatedFunctionNoYesOrder has been created
onOrderCompletedFailedFunctionNoYesThe order has failed due to an internal error/publisher reward error
onOrderCompletedSuccessfullyFunctionNoYesAn order has updated with the publisher and confirmation was received
onPaymentIntentFailedFunctionNoYesThe player has clicked on ‘Pay’ and the payment failed
onPaymentIntentSuccessFunctionNoYesThe player has clicked on ‘Pay’ and the payment has been charged successfully
publisherTokenstringNoNoUnique public token for each game. Used to distinguish multiple game stores under the same domain

All frontend events are received with a set of parameters, please notice that not all parameters are available for every event, parameters that are not available will be undefined.

NameTypeDescription
orderIdstringUnique identifier for the order.
orderExternalIdstringExternal identifier for the order.
datestringDate of the order.
sessionIdstringIdentifier for the session associated with the order.
purchaseInvoiceIdstringIdentifier for the associated purchase invoice.
appChargePaymentIdstringIdentifier for the payment associated with the order.
bundleNamestringName of the bundle associated with the order.
bundleIdstringIdentifier for the bundle.
bundleSKUstringStock Keeping Unit (SKU) for the bundle.
productsProduct[]Array of products included in the order.
totalSumnumberTotal sum of the order.
totalSumCurrencystringCurrency of the total sum.
paymentMethodNamestringName of the payment method used for the order.
userIdstring(Optional) Identifier for the user placing the order.
userCountrystring(Optional) Country associated with the user.
reasonstring(Optional) Reason for the order or additional notes.
  1. Price points:

In your Angular component, import the getPricePoints function:

import {
  AppchargeCheckoutService,
  Environment
} from 'appcharge-checkout-angular-sdk';

The getPricePoints function allows you to retrieve price points for your store. It takes two parameters:

  1. environment (string, mandatory): This parameter specifies the environment and can be either sandbox or prod.
  2. domain (string, optional): This parameter is the domain of your store. If not provided, the function will use the current domain as the default.
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  providers:  [ AppchargeCheckoutService ]
})
export class AppComponent {
  constructor(
    private appchargeSdkLib: AppchargeCheckoutService,
  ) {
  }
  getPricePointHandler() {
    this.appchargeSdkLib.getPricePoints("sandbox");
  }
}