Apple Pay - Frontend
If you want to know the latest SDK version and the difference between each version, please refer to Github Release Page: TapPay iOS Github Support iOS 10 and later.
Environment
Before you get to coding, make sure you have done the following things: 1. Download and import TPDirect.framework into your project. 2. Import PassKit.framework into your project. 4. Use TPDSetup to set up your environment. 5. Please open Advertising Identifier, to improve the accuracy of fraud detect.

iOS-objC
+ (instancetype _Nonnull)setWithAppld:(int)appld withAppKey:(NSString *_Nonnull)appKey withServerType:(TPDServerType)serverType;
iOS-Swift
class func setWithAppKey(_ appKey: String, withAppId appId: Int32, with serverType: TPDServerType) -> Self
iOS-objC
: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { // Override point for customization after application launch. [TPDSetup setWithAppId:"APP_ID" withAppKey:@"APP_KEY" withServerType:TPDServer_SandBox]; return YES; }
iOS-Swift
: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. TPDSetup.setWithAppId("APP_ID", withAppKey: "APP_KEY", with: TPDServerType.sandBox) return true }

Codes
1. Import PassKit and TPDirect frameworks into your project.
iOS-objC
#import <PassKit/PassKit.h> #import <TPDirect/TPDirect.h>
iOS-Swift
import PassKit import TPDirect 2. Implement the following classes in order: 1. TPDApplyPay TPDApplePayDelegate 2. 3. TPDTransactionResult 4. PKPaymentButton 5. TPDMerchant 6. TPDConsumer 7. TPDCart
TPDApplePay
iOS-objC
@interface ViewController () <TPDApplePayDelegate> @property (nonatomic, strong) TPDApplePay *applePay; @end
iOS-Swift
class ViewController: UlViewController { var applePay : TPDApplePay! }
@protocol TPDApplePayDelegate <NSObject> @required // Send To The Delegate After Receive Prime and prime expiry millis. - (void)tpdApplePay:(TPDApplePay *)applePay didReceivePrime:(NSString *)prime withExpiryMillis:(long)expiryMillis withCardInfo:(TPDCardInfo *)cardInfo withMerchantReferenceInfo:(NSDictionary ")merchantReferenceInfo; // Send To The Delegate After Apple Pay Payment Processing Succeeds. - (void)tpdApplePay:(TPDApplePay *)applePay didSuccessPayment: (TPDTransactionResult *)result; // Send To The Delegate After Apple Pay Payment Processing Fails. - (void)tpdApplePay:(TPDApplePay *)applePay didFailurePayment: (TPDTransactionResult *)result; @optional // Send To The Delegate After Apple Pay Payment's Form Is Shown. - (void)tpdApplePayDidStartPayment:(TPDApplePay *)applePay; // Send To The Delegate After User Selects A Payment Method. // You Can Change The PaymentItem Or Discount Here. - (TPDCart *)tpdApplePay:(TPDApplePay *)applePay didSelectPaymentMethod: (PKPaymentMethod *)paymentMethod cart:(TPDCart *)cart; // Send To The Delegate After User Selects A Shipping Method. // Set shippingMethods ==> TPDMerchant.shippingMethods. - (void)tpdApplePay:(TPDApplePay *)applePay didSelectShippingMethod: (PKShippingMethod *)shippingMethod; // Send To The Delegate After User Authorizes The Payment. // You Can Check Shipping Contact Here, Return YES If Authorized. - (BOOL)tpdApplePay:(TPDApplePay *)applePay canAuthorizePaymentWithShippingContact:(PKContact *)shippingContact; // Send To The Delegate After User Cancels The Payment. - (void)tpdApplePayDidCancelPayment:(TPDApplePay *)applePay; // Send To The Delegate After Apple Pay Payment's Form Disappeared. - (void)tpdApplePayDidFinishPayment:(TPDApplePay *)applePay; @end
iOS-Swift
public protocol TPDApplePayDelegate : NSObjectProtocol { // Send To The Delegate After Receive Prime. public func tpdApplePay(_ applePay: TPDApplePay!, didReceivePrime prime: String!, withExpiryMillis expiryMillis: Int, withCardInfo cardInfo: TPDCardInfo, withMerchantReferenceInfo merchantReferenceInfo: [AnyHashable : Any]!) // Send To The Delegate After Apple Pay Payment Processing Succeeds. public func tpdApplePay(_ applePay: TPDApplePay!, didSuccessPayment result: TPDTransactionResult!) // Send To The Delegate After Apple Pay Payment Processing Fails. public func tpdApplePay(_ applePay: TPDApplePay!, didFailurePayment result: TPDTransactionResult!) // Send To The Delegate After Apple Pay Payment's Form Is Shown. optional public func tpdApplePayDidStartPayment(_ applePay: TPDApplePay!) // Send To The Delegate After User Selects A Payment Method. // You Can Change The PaymentItem Or Discount Here. @available(iOS 9.0, *) optional public func tpdApplePay(_ applePay: TPDApplePay!, didSelect paymentMethod: PKPaymentMethod!, cart: TPDCart!) -> TPDCart! // Send To The Delegate After User Selects A Shipping Method. // Set shippingMethods ==> TPDMerchant.shippingMethods. @available(iOS 8.0, *) optional public func tpdApplePay(_ applePay: TPDApplePay!, didSelect shippingMethod: PKShippingMethod!) // Send To The Delegate After User Authorizes The Payment. // You Can Check Shipping Contact Here, Return YES If Authorized. @available(iOS 9.0, *) optional public func tpdApplePay(_ applePay: TPDApplePay!, canAuthorizePaymentWithShippingContact shippingContact: PKContact!) -> Bool // Send To The Delegate After User Cancels The Payment. optional public func tpdApplePayDidCancelPayment(_ applePay: TPDApplePay!) // Send To The Delegate After Apple Pay Payment's Form Disappeared. optional public func tpdApplePayDidFinishPayment(_ applePay: TPDApplePay!) }

TPDTransactionResult
iOS-objC
@interface TPDTransactionResult : NSObject // message, Report Message. @property (nonatomic, strong) NSString *message; // status, Result Code, '0' Means Success. @property (nonatomic, assign) NSInteger status; // amount @property (nonatomic, strong) NSDecimalNumber *amount; // paymentMehod @property (nonatomic, strong) PKPaymentMethod "paymentMethod; @end
iOS-Swift
class TPDTransactionResult : NSObject { // message, Report Message. var message: String! // status, Result Code, '0' Means Success. var status: Int // amount var amount: NSDecimalNumber! // paymentMehod var paymentMethod: PKPaymentMethod! } The returned object in didSuccessPayment and didFailurePayment, TPDTransactionResult, will contain the following values:

iOS-objC
- (void)tpdApplePayDidStartPayment:(TPDApplePay *)applePay { NSLog(@"= NSLog(@"Apple Pay On Start"); NSLog(@"= } - (void)tpdApplePay:(TPDApplePay *)applePay didSuccessPayment: (TPDTransactionResult *)result { NSLog(@"= NSLog(@"Apple Pay Did Success ==> Amount : %@", [result.amount stringValue]); NSLog(@"shippingContact.name : %@ %@", applePay.consumer.shippingContact.name.givenName, applePay.consumer.shippingContact.name.familyName); NSLog(@"shippingContact.emailAddress : %@", applePay.consumer.shippingContact.emailAddress); NSLog(@"shippingContact.phoneNumber : %@", applePay.consumer.shippingContact.phoneNumber.stringValue); NSLog(@"= - (void)tpdApplePay:(TPDApplePay *)applePay didFailurePayment: (TPDTransactionResult *)result { NSLog(@"= NSLog(@"Apple Pay Did Failure ==> Message : %@, ErrorCode : %ld", result.message, (long)result.status); === NSLog(@"= - (void)tpdApplePayDidCancelPayment:(TPDApplePay *)applePay { NSLog(@"===== === NSLog(@"Apple Pay Did Cancel"); NSLog(@"= - (void)tpdApplePayDidFinishPayment:(TPDApplePay *)applePay { NSLog(@"= NSLog(@"Apple Pay Did Finish"); NSLog(@"= - (void)tpdApplePay:(TPDApplePay *)applePay didSelectShippingMethod: (PKShippingMethod *)shippingMethod { NSLog(@"= === NSLog(@"=====> didSelectShippingMethod: "); NSLog(@"Shipping Method.identifier : %@", shippingMethod.identifier); NSLog(@"Shipping Method.detail : %@", shippingMethod.detail); === \n\n"); NSLog(@"==== - (TPDCart *)tpdApplePay:(TPDApplePay *)applePay didSelectPaymentMethod: (PKPaymentMethod *)paymentMethod cart:(TPDCart *)cart { NSLog(@"= NSLog(@"=====> didSelectPaymentMethod: "); NSLog(@"= === if (paymentMethod.type == PKPaymentMethodTypeDebit) { [self.cart addPaymentItem:[TPDPaymentItem paymentItemWithItemName:@"Discount" withAmount:[NSDecimalNumber decimalNumberWithString:@"-1.00"]]]; return self.cart; } - (BOOL)tpdApplePay:(TPDApplePay *)applePay canAuthorizePaymentWithShippingContact:(PKContact *)shippingContact { === NSLog(@"= NSLog(@"=====> canAuthorizePaymentWithShippingContact "); NSLog(@"shippingContact.name : %@ %@", applePay.consumer.shippingContact.name.givenName, applePay.consumer.shippingContact.name.familyName); NSLog(@"shippingContact.emailAddress : %@", shippingContact.emailAddress); NSLog(@"shippingContact.phoneNumber : %@", shippingContact.phoneNumber.stringValue); NSLog(@"= return YES; - (void)tpdApplePay:(TPDApplePay *)applePay didReceivePrime:(NSString *)prime withExpiryMillis:(long)expiryMillis withCardInfo:(TPDCardInfo *)cardInfo withMerchantReferenceInfo:(NSDictionary *)merchantReferenceInfo { // 1. Send Your 'Prime' To Your Server, And Handle Payment With Result // ... NSLog(@"= ___ NSLog(@"=====> didReceivePrime "); NSLog(@"Prime : %@", prime); NSLog(@"apple pay %lu", expiryMillis); NSLog(@"totalAmount : %@",applePay.cart.totalAmount); NSLog(@"Client  IP : %@",applePay.consumer.clientIP); NSLog(@"shippingContact.name : %@ %@", applePay.consumer.shippingContact.name.givenName, applePay.consumer.shippingContact.name.familyName); NSLog(@"shippingContact.emailAddress : %@", applePay.consumer.shippingContact.emailAddress); NSLog(@"shippingContact.phoneNumber : %@", applePay.consumer.shippingContact.phoneNumber.stringValue); PKPaymentMethod * paymentMethod = applePay.consumer.paymentMethod; l Kr cymentMethod.type);
NSLog(@"Type : %ld", (long)paymentMethod.network);
NSLog(@"Network : %@", paymentMethod.type); NSLog(@"Display Name : %@", paymentMethod.displayName); NSLog(@"= // 2. If Payment Success, applePay. BOOL paymentResult = YES; [applePay showPaymentResult:paymentResult]; extension ViewController :TPDApplePayDelegate { func tpdApplePayDidStartPayment(_ applePay: TPDApplePay!) { === print( print("Apple Pay On Start") print(" === func tpdApplePay(_ applePay: TPDApplePay!, didSuccessPayment result: TPDTransactionResult!) { print(" print("Apple Pay Did Success ==> Amount : \(result.amount.stringValue)") print("shippingContact.name : \ (applePay.consumer.shippingContact?.name?.givenName) \ ( applePay.consumer.shippingContact?.name?.familyName)") print("shippingContact.emailAddress : \ (applePay.consumer.shippingContact?.emailAddress)") print("shippingContact.phoneNumber : \ (applePay.consumer.shippingContact?.phoneNumber?.stringValue)") print("Shipping Method.identifier : \(applePay.cart.shippingMethod.identifier)") print("Shipping Method.detail : \(applePay.cart.shippingMethod.detail)") print(" } func tpdApplePay(_ applePay: TPDApplePay!, didFailurePayment result: TPDTransactionResult!) { print(" =======") print("Apple Pay Did Failure ==> Message : \(result.message), ErrorCode : \ (result.status)") print(" func tpdApplePayDidCancelPayment(_ applePay: TPDApplePay!) { ---------") === print("= print("Apple Pay Did Cancel") print(" func tpdApplePayDidFinishPayment(_ applePay: TPDApplePay!) { print(" print("Apple Pay Did Finish") print(" } func tpdApplePay(_ applePay: TPDApplePay!, didSelect shippingMethod: PKShippingMethod!) { print(" print("=====> didSelectShippingMethod: ") print("Shipping Method.identifier : \(shippingMethod.identifier)") print("Shipping Method.detail : \(shippingMethod.detail)") print(" func tpdApplePay(_ applePay: TPDApplePay!, didSelect paymentMethod: PKPaymentMethod!, cart: TPDCart!) -> TPDCart! { === print(" print("=====> didSelectPaymentMethod: "); ===\n\n"); print(" if paymentMethod type == .debit { self.cart.add(TPDPaymentItem(itemName: "Discount", withAmount: NSDecimalNumber(string: "-1.00"))) } return self.cart; } func tpdApplePay(_ applePay: TPDApplePay!, canAuthorizePaymentWithShippingContact shippingContact: PKContact!) -> Bool { print(" print("=====> canAuthorizePaymentWithShippingContact ") print("shippingContact.name : \ (applePay.consumer.shippingContact?.name?.givenName) \ ( applePay.consumer.shippingContact?.name?.familyName)") print("shippingContact.emailAddress : \(shippingContact.emailAddress)") print("shippingContact.phoneNumber : \(shippingContact.phoneNumber?.stringValue)") print(" return true; } tpdApplePay(_ applePay: TPDApplePay!, didReceivePrime prime: String!, withExpiryMillis expiryMillis: Int, withCardInfo cardInfo: TPDCardInfo, withMerchantReferenceInfo merchantReferenceInfo: [AnyHashable : Any]!) { // 1. Send Your Prime To Your Server, And Handle Payment With Result // ... print(" === print("=====> didReceivePrime"); print("Prime : \(prime!)"); print("Expiry Millis : \(expiryMillis)"); print("total Amount :   \(applePay.cart.totalAmount!)") print("Client IP : \(applePay.consumer.clientIP!)") print("shippingContact.name : \ (applePay.consumer.shippingContact?.name?.givenName) \ (applePay.consumer.shippingContact?.name?.familyName)"); print("shippingContact.emailAddress : \ (applePay.consumer.shippingContact?.emailAddress)"); print("shippingContact.phoneNumber : \ (applePay.consumer.shippingContact?.phoneNumber?.stringValue)"); let paymentMethod = self.consumer.paymentMethod! print("type : \(paymentMethod.type.rawValue)") print("Network : \(paymentMethod.network!.rawValue)") print("Display Name : \(paymentMethod.displayName!)") print(" // 2. If Payment Success, applePay. let paymentResult = true; applePay.showPaymentResult(paymentResult) } }

iOS-objC
@interface ViewController () <TPDApplePayDelegate> @property (nonatomic, strong) PKPaymentButton *applePayButton; @end
iOS-Swift
class ViewController: UlViewController { var applePayButton : PKPaymentButton! You should check if the card or the device supports Apple Pay before setting up the payment button.
iOS-objC
[TPDApplePay canMakePaymentsUsingNetworks:(NSArray<PKPaymentNetwork> *)] Check support cart network. TPDApplePay setupWthMerchant:(TPDMerchant *) withConsumer:(TPDConsumer *) withCart:(TPDCart *) withDelegate:(id) Use TPDMerchant, TPDConsumer, TPDCart to initial Apple Pay Instance. startPayment Start Apple Pay Payment Sheet */ - (void)paymentButtonSetting { // Check if the card can use Apple Pay. if ([TPDApplePay canMakePaymentsUsingNetworks:self.merchant.supportedNetworks]) ( self.applePayButton = [PKPaymentButton buttonWithType:PKPaymentButtonTypeBuy style:PKPaymentButtonStyleBlack]; }else{ self.applePayButton = [PKPaymentButton buttonWithType:PKPaymentButtonTypeSetUp style:PKPaymentButtonStyleBlack]; } [self.view addSubview:self.applePayButton]; self.applePayButton.center = self.view.center; [self.applePayButton addTarget:self action:@selector(didClickButton:) forControlEvents:UlControlEventTouchUpInside]; } - (void)didClickButton:(PKPaymentButton *)sender { self.applePay = [TPDApplePay setupWthMerchant:self.merchant withConsumer:self.consumer withCart:self.cart withDelegate:self]; [self.applePay startPayment];
iOS-Swift
/** TPDApplePay.canMakePayments(usingNetworks: [PKPaymentNetwork]!) Check support cart network. TPDApplePay.setupWthMerchant(TPDMerchant!, with: TPDConsumer!, with: TPDCart!, withDelegate: Any!) Use TPDMerchant, TPDConsumer, TPDCart to initial Apple Pay Instance. startPayment Start Apple Pay Payment Sheet */ func paymentButtonSetting() { // Check if the card can use Apple Pay. if (TPDApplePay.canMakePayments(usingNetworks: self.merchant.supportedNetworks)) { applePayButton = PKPaymentButton.init(paymentButtonType:  .buy, paymentButtonStyle: .black) } else { applePayButton = PKPaymentButton.init(paymentButtonType: .setUp, paymentButtonStyle: .black) } view.addSubview(applePayButton) applePayButton.center = view.center applePayButton.addTarget(self, action: #selector(ViewController.didClickBuyButton(sender:)), for: .touchUpInside) } @objc func didClickBuyButton(sender:PKPaymentButton) { applePay = TPDApplePay.setupWthMerchant(merchant, with: consumer, with: cart, withDelegate: self) applePay.startPayment() }
iOS-objC @interface ViewController () <TPDApplePayDelegate> @property (nonatomic, strong) TPDMerchant *merchant; @end
iOS-Swift
class ViewController: UlViewController { var merchant : TPDMerchant! }
iOS-objC
self.merchant = [TPDMerchant new]; = @"TapPay!"; self.merchant.merchantName self.merchant.merchantCapability = PKMerchantCapability3DS; self.merchant.applePayMerchantIdentifier = @"merchant.apple.pay"; self.merchant.countryCode = @"TW"; = @"TWD"; self.merchant.currencyCode = @[PKPaymentNetworkAmex, self.merchant.supportedNetworks PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkJCB];
iOS-Swift
merchant = TPDMerchant() merchant.merchantName = "TapPay!"; merchant.merchantCapability = .capability3DS; merchant.applePayMerchantIdentifier = "merchant.apple.pay"; merchant.countryCode = "TW"; = "TWD"; merchant.currencyCode = [.amex, .masterCard, .visa, .JCB] merchant.supportedNetworks
supportedNetworks card network supported version

TPDConsumer
iOS-objC
@interface ViewController () <TPDApplePayDelegate> @property (nonatomic, strong) TPDConsumer *consumer; @end
iOS-Swift
class ViewController: UlViewController { var consumer : TPDConsumer! }
iOS-objC
self.consumer = [TPDConsumer new]; self.consumer.requiredShippingAddressFields  = PKAddressFieldEmail | PKAddressFieldName | PKAddressFieldPhone; self.consumer.requiredBillingAddressFields   = PKAddressFieldPostalAddress;
iOS-Swift
consumer = TPDConsumer() consumer.requiredShippingAddressFields  = [.email, .name, .phone] consumer.requiredBillingAddressFields   = [.postalAddress]
After the Apple Pay authentication is successful, you can get the card information in the didReceivePrime delegate, TPDConsumer.paymentMethod More info refer to apple pay docs PKPaymentMethod .

TPDCart
iOS-objC
@interface ViewController () <TPDApplePayDelegate> @property (nonatomic, strong) TPDCart *cart; @end iOS-Swift class ViewController: UlViewController { var cart     : TPDCart! }
iOS-objC
[cart addPaymentItem:(TPDPaymentItem *)] Add payment item to item list. */ self.cart = [TPDCart new]; TPDPaymentItem *book = [TPDPaymentItem paymentItemWithItemName:@"Book" withAmount:[NSDecimalNumber decimalNumberWithString:@"100.00"]]; [self.cart addPaymentItem:book]; self.cart.shippingType   = PKShippingTypeShipping;
iOS-Swift
/** cart.add(TPDPaymentItem!) Add payment item to item list. */ cart = TPDCart() let book = TPDPaymentItem(itemName:"Book", withAmount: NSDecimalNumber(string: "100.00")) cart.add(book) cart.shippingType   = .shipping; You can use TPDPaymentItem to add new items to TPDCart. Use paymentItemWithItemName to set up to display the amount of items. The sum of amount of items in TPDCart must be greater than zero, otherwise the program will return error code: 88016
self.cart = [TPDCart new]; self.cart.isAmountPending = YES; self.cart.isShowTotalamount = NO; TPDPaymentItem *initialCharge = [TPDPaymentItem paymentItemWithItemName:@"Initial Charge" withAmount:[NSDecimalNumber decimalNumberWithString:@"100.00"]]; [self.cart addPaymentItem:initialCharge]; TPDPaymentItem *improvementSurcharge  = [TPDPaymentItem pendingPaymentItemWithItemName:@"NT$5 per miles"]; [self.cart addPaymentItem:improvementSurcharge];
iOS-Swift
cart = TPDCart() cart.isAmountPending = true Please contact TapPay Customer Service (support@cherri.tech) to activate Apple Pay deferred payment. Once the function has been activated, the prime could live for 30 days and payment amount is set by Pay by Prime, not by SDK. The property isAmountPending of TPDCart could determine whether this transaction enables deferred payment or not. Default is false The property isShowTotalAmount of TPDCart could determine that total amount of the payment sheet shows the sum of each payment item’s amount or AMOUNT PENDING. Default is false If the property pendingPaymentItemWithItemName has been set in TPDCart, the payment item’s amount of the payment sheet will show 『・・・』, which means actual payment amount is unknown. Use deferred payment, please note the following rules

Notice
Due to total amount should be set above 0 in iOS 12 and version lower. For compatibility, iOS SDK v2.6.0 and version higher will set total amount of 1 to Apple Pay in following situation. 1. The items of TPDCart are amount pending items and total amount is set to show  『AMOUNT PENDING』(self.cart.isAmountPending = true). 2. The total amount of items of TPDCart is 0 and total amount is set to show 『AMOUNT PENDING』(self.cart.isAmountPending = true)
Example
If you have any questions, please refer our Apple Pay Example.
If you want to know the latest SDK version and the difference between each version, please refer to Github Release Page: TapPay Web Github Apple Pay JavaScript API is only available on iOS device running iOS 10 or later or Mac running macOS Sierra (10.12) or later. If you enable Apple Pay on the Web Merchant Application Service, please fill in merchant identifier which generated by TapPay (You can find it from Portal > Payment Methods > Apple Pay On The Web)
Requirements
In Apple Pay on the Web, you must meet the following requirements: 1. All pages that include Apple Pay must be served over HTTPS , In production and sandbox. In develop enviroment you can use ngrok to set up an SSH tunnel , you can refer to our Ngrok tutorial. 2. Your domain must have a valid SSL certificate.
3. Your server must support the Transport Layer Security (TLS) 1.2 protocol and 4. Your server must allow access over HTTPS (TCP over port 443) to the Apple Pay IP Addresses provided below:
Please use following html code to setup payment environment. Please be aware of the differences of each Web SDK version to avoid loading errors. https://js.tappaysdk.com/sdk/tpdirect/v5.14.0 https://js.tappaysdk.com/tpdirect/v5.13.1 Please refer to the following usage examples. <!-- i> When use web SDK version less than v5.14.0, please use the following path to include the web SDK <script src="https://js.tappaysdk.com/tpdirect/v5.13.1"></script> <script> TPDirect.setupSDK(APP_ID, 'APP_KEY', 'sandbox') </script>
Check if PaymentRequestAPI is available. Use TPDirect.paymentRequestApi.checkAvailability() to detect user's browser whether is available to use Payment Request API or not. TPDirect.paymentRequestApi.checkAvailability()
Setup Apple Pay
/** Use TPDirect.paymentRequestApi.setupApplePay to setup parameters about Apple Pay. */ TPDirect.paymentRequestApi.setupApplePay({ merchantIdentifier: 'merchant.tech.cherri', countryCode: 'TW' })
Create a paymentRequest object setup transaction info to retrieve the Prime. var paymentRequest = { supportedNetworks: ['AMEX', 'JCB', 'MASTERCARD', 'VISA'], supportedMethods: ['apple_pay'], displayItems: [{ label: 'TapPay - iPhone8', amount: { currency: 'TWD', value: '1.00' }], } total: { label: '總金額', amount: { currency: 'TWD', value : '1.00' } }, shippingOptions: [{ id: "standard", label: " see Ground Shipping (2 days)", detail: 'Estimated delivery time: 2 days', amount: { currency: "TWD", value: "5.00" } }, { id: "drone", label: " " "  Drone Express (2 hours)", detail: 'Estimated delivery time: 2 hours', amount: { currency: "TWD", value: "25.00" } options: { requestPayerEmail: true, requestPayerName: true, requestPayerPhone: true, requestShipping: true, shippingType: 'shipping' } }
After you setup payment request object, please use following method to setup Payment Request API setupPaymentRequest have a callback function, callback function have following object properties.

Deferred Payment
Please contact TapPay Customer Service (support@cherri.tech) to activate Apple Pay deferred payment. Once the function has been activated, the prime could live for 30 days and payment amount is set by Pay by Prime, not by SDK. The property total.isAmountPending of paymentRequest could determine whether this transaction enables deferred payment or not. Default is false The property total.isShowTotalAmount of paymentRequest could determine that total amount of the payment sheet shows the sum of each payment item’s amount or AMOUNT PENDING. Default is false If isAmountPending:true has been set in displayItems of paymentRequest, the payment item’s amount of the payment sheet will show 『・・・』, which means actual payment amount is unknown. Use deferred payment, please note the following rules

Notice
Due to total amount should be set above 0 in MacOS 10.14.1, iOS 12.1 and version lower. For compatibility, Web SDK v5.4.0 and version higher will set total.amount.value:1 to Apple Pay in following situation. 1. isAmountPending:true has been set in all displayItems of paymentRequest and total amount is set to show  『AMOUNT PENDING』 (total.isShowTotalAmount:false) 2. The total of displayItems’ amount is 0 and total amount is set to show 『AMOUNT PENDING』(total.isShowTotalAmount:false) 3. There is no items in displayItems and total amount is set to show『AMOUNT PENDING』(total.isShowTotalAmount:false) Besides, if you pay on Mac, but verify by fingerprint or face ID through iPhone, total amount of the payment sheet will show 1.
In paymentRequest ShippingOption without detail. shippingOptions: [{ id: "standard", label: "尋尋Ground Shipping (2 days)", amount: { currency: "TWD", value: "5.00" } }} In paymentRequest ShippingOption add detail. shippingOptions: [{ id: "standard", label: " sain Ground Shipping (2 days)", // apple pay only detail: "Estimated delivery time: 2 days", amount: { currency: "TWD", value: "5.00" } }} ● Pay
Get Prime
/** Use TPDirect.paymentRequestApi.getPrime to get prime from TapPay. */ TPDirect.paymentRequestApi.getPrime(function(result) { console.log('paymentRequestApi.getPrime result', result) if (result.status !== 0) { console.error('getPrime failed: ' + result.msg) return } var prime = result.prime })
Get Prime Result
Get the result and send the Prime back to your server to finish the transaction by calling Pay by Prime API. ( "prime": String, "total_amount": String, "status": Int, "msg": String, "client_ip": String, "payer": { "name": String, "phone": String, "email": String "shippingAddress": { "country": String, "addressLine": ArrayString, "region": String, "city": String, "dependentLocality": String, "postalCode": String, "sortingCode": String, "languageCode": String, "organization": String, "recipient": String, "phone": String "shippingOption": String, "billingAddress": { "country": String, "addressLine": ArrayString, "region": String, "city": String, "dependentLocality": String, "postalCode": String, "sortingCode": String, "languageCode": String, "organization": String, "recipient": String, "phone": String "methodName": String ("apple_pay") "requestId": String, "card": { "lastfour": String, "funding": Int, "type": Int, },
"card_info": { "bincode": String, "lastfour": String, "issuer": String, "issuer_zh_tw": String, "bank_id": String, "funding": Int, "type": Int, "level": String, "country": String, "countrycode", String, "merchant_reference_info": { "affiliate_codes": ArrayString, "prime_expiry_millis": Number }
payer format
merchant_reference_info format
Example
If you have any questions, please refer our Example or Apple’s Apple Pay Example. Keep in mind that Apple Pay JavaScript API is only available on iOS device running iOS 10 or later or Mac running macOS Sierra (10.12) or later.
Reference
If you want to integrate more payment methods, please refer to Payment Request API
Q&A
If you have to set frame-src of Content Security Policy, please set following two domains. 1. js.tappaysdk.com 2. fraud.tappaysdk.com

1. appld
An integer identifier for your application or website. This is used to activate your application or website in order to start using our services. You can find it via Portal > Developer > Application. Application

2. appKey
An authenticator key for your application or website. This is used to activate your application or website in order to start using our services. You can find it via Portal > Developer > Application. Application

3. Amount
Total price for a particular transaction. For refunds, a smaller than original amount is acceptable if partial refund is requested. TWD：Lower limit of each transaction is NTD 1, upper limit of each transaction is NTD 20,000,000. Please fill in 1 when the transaction is TWD 1. HKD：Lower limit of each transaction is HKD 0.01, upper limit of each transaction is HKD 252,500. Please fill in 101 when the transaction is HKD 1.01 MYR：Lower limit of each transaction is MYR 0.01, upper limit of each transaction is MYR 135,000. Please fill in 101 when the transaction is MYR 1.01 USD limit of each transaction is USD 0.01, upper limit of each transaction is USD 33,169. Please fill in 101 when the transaction is USD 1.01
4. Currency
The letter abbreviation for currency, following ISO 4217.

5. Partial Refund
Partial refund could only be executed after captured successfully. Payment process is as follows: Transaction happens > Payment is captured based on delay_capture_in_days > Partial refund is available only after captured successfully e.g. A transaction happened on October 9th. If the delay_capture_in_days parameter is 0, then the transaction will be captured on the same day. However, Partial refund only could be executed after captured successfully. e.g. A transaction happened on October 9th. If the delay_capture_in_days parameter is 3, then the transaction will be captured on October 12th. Therefore, partial refund is available starting from October 13th if the transaction has been successfully captured. * If it shows “capture successfully” from TapPay, but couldn’t do partial refund. Please try it again one day after due to the bank issue.
6. Production
The official environment that charges customer's cards for transactions. You product should be in this environment when it officially launches and goes live. You can specify the environment for your application during TPDSetup.initInstance(). You can specify the environment for your website during TPDirect.setupSDK(). Things to remember : 1. Register your merchants in the production environment on Portal and use the official bank’s acquirer account. 2. Register your IP in the production environment on Portal. 3. Use the production app key instead of the sandbox one. 4. When setting the Frontend environment, change the server type to production. 5. The Backend APIs should use the production domain instead of the sandbox one.(https://sandbox.tappaysdk.com/tpc/ -> https://prod.tappaysdk.com/tpc/)
7. Refund
An API that allows you to refund transaction, fully or partially. Please refer to the backend documentation: Refund API.
8. Sandbox
A type of environment that has all the functions of a production environment except no money will be charged for the transactions. You should first test your application or website in this environment before you move on to the production environment. You can specify the environment for your application during TPDSetup.initInstance(). You can specify the environment for your website during TPDirect.setupSDK().
8. shippingType
Shipping type , show on Payment Request API
1.
$ N N O $ B画11 86% 0 16:46 Payment Request Button Test :: https://0f87cc22.ngrok.io TapPay PaymentRequest Button Demo Payment Request Button Test ■ https://0f87cc22.ngrok.io X TWD $1.00
2.
छ  छ *同年の￥ 9回.41 86% 16:46 Payment Request Button Test https://0f87cc22.ngrok.io TapPay PaymentRequest Button Demo Payment Request Button Test ◾ https://0f87cc22.ngrok.io X訂單摘要付給TapPay TWD $1.00
3.

*图片图￥ 9回.41 86% 16:45
Payment Request Button Test n https://0f87cc22.ngrok.io . . . TapPay PaymentRequest Button Demo Payment Request Button Test 38 👍 https://0f87cc22.ngrok.io X訂單指要付給TapPay TWD $1.00付敵方式Android Pay ( O chrome組輯延行#poy